summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-04-28 20:24:39 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-04-28 20:24:39 +0000
commite2e58c29fac6cc79205cbfef7d5da827b8cc42a6 (patch)
treeec5604cdfa592ae2fddde685442d1c3fee0a6408
parent2dc4e14be14b9c34628fbbc70f86c4d46ddc901f (diff)
parent36c48e4023f7b62ac02cda2df3716575b180ea3e (diff)
downloadlibhardware_legacy-q_tzdata_aml_297100300.tar.gz
Change-Id: Ib101564ac117def835e1edb30fa7d71365f8ee92
-rw-r--r--Android.bp6
-rw-r--r--audio/Android.bp1
-rw-r--r--include/wakelock/wakelock.h37
-rw-r--r--power.cpp36
-rw-r--r--power_test.cpp67
5 files changed, 6 insertions, 141 deletions
diff --git a/Android.bp b/Android.bp
index bc453fe..133073d 100644
--- a/Android.bp
+++ b/Android.bp
@@ -35,12 +35,8 @@ cc_test {
defaults: ["libpower_defaults"],
srcs: ["power_test.cpp"],
static_libs: ["libpower"],
- shared_libs: [
- "android.system.suspend@1.0",
- "suspend_control_aidl_interface-cpp",
- ],
+ shared_libs: ["android.system.suspend@1.0"],
test_suites: ["device-tests"],
- require_root: true,
}
cc_library_shared {
diff --git a/audio/Android.bp b/audio/Android.bp
index b4c0799..a7c51af 100644
--- a/audio/Android.bp
+++ b/audio/Android.bp
@@ -21,7 +21,6 @@ cc_library_static {
],
header_libs: [
- "libaudioclient_headers",
"libbase_headers",
"libhardware_legacy_headers",
],
diff --git a/include/wakelock/wakelock.h b/include/wakelock/wakelock.h
deleted file mode 100644
index 75a7c72..0000000
--- a/include/wakelock/wakelock.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.
- */
-
-#pragma once
-
-#include <memory>
-#include <string>
-
-namespace android {
-namespace wakelock {
-
-// RAII-style wake lock implementation
-class WakeLock {
- public:
- WakeLock(const std::string& name);
- ~WakeLock();
-
- private:
- class WakeLockImpl;
- std::unique_ptr<WakeLockImpl> mImpl;
-};
-
-} // namespace wakelock
-} // namespace android
diff --git a/power.cpp b/power.cpp
index 16ed961..e9b6ccd 100644
--- a/power.cpp
+++ b/power.cpp
@@ -17,11 +17,9 @@
#define LOG_TAG "power"
#define ATRACE_TAG ATRACE_TAG_POWER
-#include <hardware_legacy/power.h>
-#include <wakelock/wakelock.h>
-
#include <android-base/logging.h>
#include <android/system/suspend/1.0/ISystemSuspend.h>
+#include <hardware_legacy/power.h>
#include <utils/Trace.h>
#include <mutex>
@@ -46,7 +44,6 @@ int acquire_wake_lock(int, const char* id) {
ATRACE_CALL();
const auto& suspendService = getSystemSuspendServiceOnce();
if (!suspendService) {
- LOG(ERROR) << "ISystemSuspend::getService() failed.";
return -1;
}
@@ -80,34 +77,3 @@ int release_wake_lock(const char* id) {
}
return -1;
}
-
-namespace android {
-namespace wakelock {
-
-class WakeLock::WakeLockImpl {
- public:
- WakeLockImpl(const std::string& name);
- ~WakeLockImpl();
-
- private:
- sp<IWakeLock> mWakeLock;
-};
-
-WakeLock::WakeLock(const std::string& name) : mImpl(std::make_unique<WakeLockImpl>(name)) {}
-
-WakeLock::~WakeLock() = default;
-
-WakeLock::WakeLockImpl::WakeLockImpl(const std::string& name) : mWakeLock(nullptr) {
- static sp<ISystemSuspend> suspendService = ISystemSuspend::getService();
- mWakeLock = suspendService->acquireWakeLock(WakeLockType::PARTIAL, name);
-}
-
-WakeLock::WakeLockImpl::~WakeLockImpl() {
- auto ret = mWakeLock->release();
- if (!ret.isOk()) {
- LOG(ERROR) << "IWakeLock::release() call failed: " << ret.description();
- }
-}
-
-} // namespace wakelock
-} // namespace android
diff --git a/power_test.cpp b/power_test.cpp
index d6e414d..601df64 100644
--- a/power_test.cpp
+++ b/power_test.cpp
@@ -14,11 +14,7 @@
* limitations under the License.
*/
-#include <android/system/suspend/ISuspendControlService.h>
-#include <binder/IServiceManager.h>
-#include <gtest/gtest.h>
#include <hardware_legacy/power.h>
-#include <wakelock/wakelock.h>
#include <csignal>
#include <cstdlib>
@@ -26,9 +22,8 @@
#include <thread>
#include <vector>
-using android::sp;
-using android::system::suspend::ISuspendControlService;
-using android::system::suspend::WakeLockInfo;
+#include <gtest/gtest.h>
+
using namespace std::chrono_literals;
namespace android {
@@ -78,10 +73,8 @@ TEST(LibpowerTest, WakeLockStressTest) {
for (int j = 0; j < numLocks; j++) {
// We want ids to be unique.
std::string id = std::to_string(i) + "/" + std::to_string(j);
- ASSERT_EQ(acquire_wake_lock(PARTIAL_WAKE_LOCK, id.c_str()), 0)
- << "id: " << id;
- ASSERT_EQ(release_wake_lock(id.c_str()), 0)
- << "id: " << id;;
+ ASSERT_EQ(acquire_wake_lock(PARTIAL_WAKE_LOCK, id.c_str()), 0);
+ ASSERT_EQ(release_wake_lock(id.c_str()), 0);
}
});
}
@@ -90,56 +83,4 @@ TEST(LibpowerTest, WakeLockStressTest) {
}
}
-class WakeLockTest : public ::testing::Test {
- public:
- virtual void SetUp() override {
- sp<IBinder> control =
- android::defaultServiceManager()->getService(android::String16("suspend_control"));
- ASSERT_NE(control, nullptr) << "failed to get the suspend control service";
- controlService = interface_cast<ISuspendControlService>(control);
- }
-
- // Returns true iff found.
- bool findWakeLockInfoByName(const sp<ISuspendControlService>& service, const std::string& name,
- WakeLockInfo* info) {
- std::vector<WakeLockInfo> wlStats;
- service->getWakeLockStats(&wlStats);
- auto it = std::find_if(wlStats.begin(), wlStats.end(),
- [&name](const auto& x) { return x.name == name; });
- if (it != wlStats.end()) {
- *info = *it;
- return true;
- }
- return false;
- }
-
- // All userspace wake locks are registered with system suspend.
- sp<ISuspendControlService> controlService;
-};
-
-// Test RAII properties of WakeLock destructor.
-TEST_F(WakeLockTest, WakeLockDestructor) {
- auto name = std::to_string(rand());
- {
- android::wakelock::WakeLock wl{name};
-
- WakeLockInfo info;
- auto success = findWakeLockInfoByName(controlService, name, &info);
- ASSERT_TRUE(success);
- ASSERT_EQ(info.name, name);
- ASSERT_EQ(info.pid, getpid());
- ASSERT_TRUE(info.isActive);
- }
-
- // SystemSuspend receives wake lock release requests on hwbinder thread, while stats requests
- // come on binder thread. Sleep to make sure that stats are reported *after* wake lock release.
- std::this_thread::sleep_for(1ms);
- WakeLockInfo info;
- auto success = findWakeLockInfoByName(controlService, name, &info);
- ASSERT_TRUE(success);
- ASSERT_EQ(info.name, name);
- ASSERT_EQ(info.pid, getpid());
- ASSERT_FALSE(info.isActive);
-}
-
} // namespace android