Merge tag 'android-13.0.0_r52' into int/13/fp3
Android 13.0.0 Release 52 (TQ3A.230605.012)
* tag 'android-13.0.0_r52':
suspend: De-flake suspend tests
suspend: Remove zygote wl on autosuspend enable
Specify KeyMint EC keys by curve not size
Change-Id: I2d8738c5cf4c6056beaae81bad663e71509b3e65
diff --git a/suspend/1.0/default/SystemSuspend.cpp b/suspend/1.0/default/SystemSuspend.cpp
index 5e5a745..5374ea9 100644
--- a/suspend/1.0/default/SystemSuspend.cpp
+++ b/suspend/1.0/default/SystemSuspend.cpp
@@ -56,6 +56,12 @@
static constexpr char kSysPowerWakeLock[] = "/sys/power/wake_lock";
static constexpr char kSysPowerWakeUnlock[] = "/sys/power/wake_unlock";
static constexpr char kUnknownWakeup[] = "unknown";
+// This is used to disable autosuspend when zygote is restarted
+// it allows the system to make progress before autosuspend is kicked
+// NOTE: If the name of this wakelock is changed then also update the name
+// in rootdir/init.zygote32.rc, rootdir/init.zygote64.rc, and
+// rootdir/init.zygote64_32.rc
+static constexpr char kZygoteKernelWakelock[] = "zygote_kwl";
// This function assumes that data in fd is small enough that it can be read in one go.
// We use this function instead of the ones available in libbase because it doesn't block
@@ -150,10 +156,11 @@
if (mWakeLockFd < 0) {
PLOG(ERROR) << "error opening " << kSysPowerWakeLock;
}
- mWakeUnlockFd.reset(TEMP_FAILURE_RETRY(open(kSysPowerWakeUnlock, O_CLOEXEC | O_RDWR)));
- if (mWakeUnlockFd < 0) {
- PLOG(ERROR) << "error opening " << kSysPowerWakeUnlock;
- }
+ }
+
+ mWakeUnlockFd.reset(TEMP_FAILURE_RETRY(open(kSysPowerWakeUnlock, O_CLOEXEC | O_RDWR)));
+ if (mWakeUnlockFd < 0) {
+ PLOG(ERROR) << "error opening " << kSysPowerWakeUnlock;
}
}
@@ -161,6 +168,14 @@
auto tokensLock = std::lock_guard(mAutosuspendClientTokensLock);
auto autosuspendLock = std::lock_guard(mAutosuspendLock);
+ // Disable zygote kernel wakelock, since explicitly attempting to
+ // enable autosuspend. This should be done even if autosuspend is
+ // already enabled, since it could be the case that the framework
+ // is restarting and connecting to the existing suspend service.
+ if (!WriteStringToFd(kZygoteKernelWakelock, mWakeUnlockFd)) {
+ PLOG(ERROR) << "error writing " << kZygoteKernelWakelock << " to " << kSysPowerWakeUnlock;
+ }
+
bool hasToken = std::find(mAutosuspendClientTokens.begin(), mAutosuspendClientTokens.end(),
token) != mAutosuspendClientTokens.end();
@@ -327,7 +342,8 @@
bool success;
{
auto tokensLock = std::lock_guard(mAutosuspendClientTokensLock);
- checkAutosuspendClientsLivenessLocked();
+ // TODO: Clean up client tokens after soaking the new approach
+ // checkAutosuspendClientsLivenessLocked();
autosuspendLock.lock();
base::ScopedLockAssertion autosuspendLocked(mAutosuspendLock);
diff --git a/suspend/1.0/default/SystemSuspendUnitTest.cpp b/suspend/1.0/default/SystemSuspendUnitTest.cpp
index f6e216b..a4d58b5 100644
--- a/suspend/1.0/default/SystemSuspendUnitTest.cpp
+++ b/suspend/1.0/default/SystemSuspendUnitTest.cpp
@@ -198,8 +198,12 @@
}
virtual void TearDown() override {
+ // Allow some time for the autosuspend loop to happen, if unblocked
+ std::this_thread::sleep_for(100ms);
+
if (!isReadBlocked(wakeupCountFd)) readFd(wakeupCountFd);
- if (!isReadBlocked(stateFd)) readFd(stateFd).empty();
+ if (!isReadBlocked(stateFd)) readFd(stateFd);
+
ASSERT_TRUE(isReadBlocked(wakeupCountFd));
ASSERT_TRUE(isReadBlocked(stateFd));
}
@@ -209,7 +213,12 @@
ASSERT_TRUE(WriteStringToFd(wakeupCount, wakeupCountFd));
}
- bool isSystemSuspendBlocked(int timeout_ms = 20) { return isReadBlocked(stateFd, timeout_ms); }
+ bool isSystemSuspendBlocked(int timeout_ms = 20) {
+ // Allow some time for the autosuspend loop to happen, if unblocked
+ std::this_thread::sleep_for(100ms);
+
+ return isReadBlocked(stateFd, timeout_ms);
+ }
std::shared_ptr<IWakeLock> acquireWakeLock(const std::string& name = "TestLock") {
std::shared_ptr<IWakeLock> wl = nullptr;
@@ -305,18 +314,32 @@
// Tests that autosuspend thread can only enabled again after its been disabled.
TEST_F(SystemSuspendTest, EnableAutosuspendAfterDisableAutosuspend) {
bool enabled = false;
- unblockSystemSuspendFromWakeupCount();
- systemSuspend->disableAutosuspend();
+
+ checkLoop(1);
controlServiceInternal->enableAutosuspend(new BBinder(), &enabled);
- ASSERT_EQ(enabled, true);
+ ASSERT_FALSE(enabled);
+
+ systemSuspend->disableAutosuspend();
+ unblockSystemSuspendFromWakeupCount();
+
+ controlServiceInternal->enableAutosuspend(new BBinder(), &enabled);
+ ASSERT_TRUE(enabled);
}
TEST_F(SystemSuspendTest, DisableAutosuspendBlocksSuspend) {
checkLoop(1);
systemSuspend->disableAutosuspend();
+ unblockSystemSuspendFromWakeupCount();
ASSERT_TRUE(isSystemSuspendBlocked());
+
+ // Re-enable autosuspend
+ bool enabled = false;
+ controlServiceInternal->enableAutosuspend(new BBinder(), &enabled);
+ ASSERT_TRUE(enabled);
}
+// TODO: Clean up binder tokens after soaking new implementation
+/*
TEST_F(SystemSuspendTest, BlockAutosuspendIfBinderIsDead) {
class DeadBinder : public BBinder {
android::status_t pingBinder() override { return android::UNKNOWN_ERROR; }
@@ -385,6 +408,7 @@
ASSERT_FALSE(timedOut);
}
+*/
TEST_F(SystemSuspendTest, AutosuspendLoop) {
checkLoop(5);
@@ -417,10 +441,10 @@
std::shared_ptr<IWakeLock> wl1 = acquireWakeLock();
ASSERT_NE(wl1, nullptr);
ASSERT_TRUE(isSystemSuspendBlocked());
- unblockSystemSuspendFromWakeupCount();
{
std::shared_ptr<IWakeLock> wl2 = acquireWakeLock();
ASSERT_NE(wl2, nullptr);
+ unblockSystemSuspendFromWakeupCount();
ASSERT_TRUE(isSystemSuspendBlocked());
}
ASSERT_TRUE(isSystemSuspendBlocked());