diff options
author | Tri Vo <trong@google.com> | 2019-12-06 10:44:31 -0800 |
---|---|---|
committer | Tri Vo <trong@google.com> | 2019-12-06 11:18:13 -0800 |
commit | c32ff4f4711bd85d72409a2cabd6f64651f9242b (patch) | |
tree | 94c857032869dcc8fc18abef44d46ee7dd2a9a5d | |
parent | 664b828cfa28a10c7f519ec6e8e046c32a579090 (diff) | |
download | cuttlefish_common-c32ff4f4711bd85d72409a2cabd6f64651f9242b.tar.gz |
cuttlefish: suspend_blocker service
suspend_blocker's purpose is to make sure device never suspends.
Once system suspend is implemented on cuttlefish, suspend_blocker will
no longer be needed.
Bug: 136800571
Test: boot cuttlefish; "suspend_blocker" wakelock present
Change-Id: I91d0cf42f5f278e4b8bb309f0fb300c3e815ffbf
-rw-r--r-- | guest/services/suspend_blocker/Android.bp | 20 | ||||
-rw-r--r-- | guest/services/suspend_blocker/suspend_blocker.cpp | 26 |
2 files changed, 46 insertions, 0 deletions
diff --git a/guest/services/suspend_blocker/Android.bp b/guest/services/suspend_blocker/Android.bp new file mode 100644 index 00000000..c87c4da9 --- /dev/null +++ b/guest/services/suspend_blocker/Android.bp @@ -0,0 +1,20 @@ +// Copyright (C) 2019 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +cc_binary { + name: "suspend_blocker", + srcs: ["suspend_blocker.cpp"], + shared_libs: ["libpower"], + defaults: ["cuttlefish_guest_product_only"], +} diff --git a/guest/services/suspend_blocker/suspend_blocker.cpp b/guest/services/suspend_blocker/suspend_blocker.cpp new file mode 100644 index 00000000..120a01b8 --- /dev/null +++ b/guest/services/suspend_blocker/suspend_blocker.cpp @@ -0,0 +1,26 @@ +/* + * Copyright 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <signal.h> +#include <wakelock/wakelock.h> + +int main() { + android::wakelock::WakeLock wl{"suspend_blocker"}; // RAII object + + sigset_t mask; + sigemptyset(&mask); + return sigsuspend(&mask); // Infinite sleep +} |