diff options
Diffstat (limited to 'block_suspend.cpp')
-rw-r--r-- | block_suspend.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/block_suspend.cpp b/block_suspend.cpp index 99341b8..d780904 100644 --- a/block_suspend.cpp +++ b/block_suspend.cpp @@ -14,6 +14,8 @@ * limitations under the License. */ +#include <unistd.h> + #include <iostream> #include <wakelock/wakelock.h> @@ -32,8 +34,12 @@ int main(int argc, char ** /* argv */) { return 0; } - android::wakelock::WakeLock wl{gWakeLockName}; // RAII object - while (true) {}; + auto wl = android::wakelock::WakeLock::tryGet(gWakeLockName); // RAII object + if (!wl.has_value()) { + return EXIT_FAILURE; + } + + while (true) { sleep(1000000); }; std::abort(); // should never reach here return 0; } |