Add force-active command.

Add a command to allow tests to force idle states to ACTIVE.

Bug: 269341557
Test: Force light idle to IDLE, then run tests
Test: atest CtsJobSchedulerTestCases
Change-Id: I6c1c65e14629fe1f05e47c9ae5cf53f5c9325f7e
This commit is contained in:
Kweku Adams
2023-02-16 17:50:02 +00:00
parent 7137d9165d
commit f924b263fa

View File

@@ -4589,6 +4589,22 @@ public class DeviceIdleController extends SystemService
Binder.restoreCallingIdentity(token);
}
}
} else if ("force-active".equals(cmd)) {
getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,
null);
synchronized (this) {
final long token = Binder.clearCallingIdentity();
try {
mForceIdle = true;
becomeActiveLocked("force-active", Process.myUid());
pw.print("Light state: ");
pw.print(lightStateToString(mLightState));
pw.print(", deep state: ");
pw.println(stateToString(mState));
} finally {
Binder.restoreCallingIdentity(token);
}
}
} else if ("force-idle".equals(cmd)) {
getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,
null);