We pass an enum to acquireWakeLock(), symmetric to how it's done in libpower
interface.
The screen could be managed above (android) or below (ARC++) this HAL depending
on the device, so we don't mandate that full wake locks keep the screen alive.
Only requirement is that all wake locks block system suspend.
Bug:
115947180
Test: SystemSuspendV1_0UnitTest
Change-Id: I92c65371852ffb2f71f5d529b7020d256cb1ba76
* device from suspending. This method must be able to be called
* independently of enableAutosuspend().
*
+ * @param type type of the requested wake lock.
* @param debugName debug string attached to the acquired IWakeLock. Wake
* lock names are not necessarily unique.
*
* @return lock the interface for the created wake lock.
*/
- acquireWakeLock(string debugName) generates (IWakeLock lock);
+ acquireWakeLock(WakeLockType type, string debugName)
+ generates (IWakeLock lock);
};
return true;
}
-Return<sp<IWakeLock>> SystemSuspend::acquireWakeLock(const hidl_string& name) {
+Return<sp<IWakeLock>> SystemSuspend::acquireWakeLock(WakeLockType /* type */,
+ const hidl_string& name) {
IWakeLock* wl = new WakeLock{this};
{
auto l = std::lock_guard(mStatsLock);
public:
SystemSuspend(unique_fd wakeupCountFd, unique_fd stateFd);
Return<bool> enableAutosuspend() override;
- Return<sp<IWakeLock>> acquireWakeLock(const hidl_string& name) override;
+ Return<sp<IWakeLock>> acquireWakeLock(WakeLockType type, const hidl_string& name) override;
Return<bool> registerCallback(const sp<ISystemSuspendCallback>& cb) override;
Return<void> debug(const hidl_handle& handle, const hidl_vec<hidl_string>& options) override;
void serviceDied(uint64_t /* cookie */, const wp<IBase>& service);
using android::system::suspend::V1_0::IWakeLock;
using android::system::suspend::V1_0::readFd;
using android::system::suspend::V1_0::SystemSuspend;
+using android::system::suspend::V1_0::WakeLockType;
namespace android {
bool isSystemSuspendBlocked() { return isReadBlocked(stateFd); }
- sp<IWakeLock> acquireWakeLock() { return suspendService->acquireWakeLock("TestLock"); }
+ sp<IWakeLock> acquireWakeLock() {
+ return suspendService->acquireWakeLock(WakeLockType::PARTIAL, "TestLock");
+ }
SystemSuspendStats getDebugDump() {
// Index 0 corresponds to the read end of the pipe; 1 to the write end.
// Test that debug dump has correct information about acquired WakeLocks.
TEST_F(SystemSuspendTest, DebugDump) {
{
- sp<IWakeLock> wl = suspendService->acquireWakeLock("TestLock");
+ sp<IWakeLock> wl = acquireWakeLock();
SystemSuspendStats debugDump = getDebugDump();
ASSERT_EQ(debugDump.wake_lock_stats().size(), 1);
ASSERT_EQ(debugDump.wake_lock_stats().begin()->second.name(), "TestLock");
--- /dev/null
+/*
+ * Copyright (C) 2018 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.
+ */
+
+package android.system.suspend@1.0;
+
+/**
+ * Blocking CPU suspend is the only constraint that must be respected by all
+ * wake lock types. E.g. a request for a full wake lock must block CPU suspend,
+ * but not necessarily keep the screen alive.
+ */
+enum WakeLockType : uint32_t {
+ /* CPU stays on. */
+ PARTIAL,
+ /* CPU and the screen stay on. */
+ FULL
+};