Merge "Revert "Removing workaround for battery defender"" into ub-launcher3-master

This commit is contained in:
TreeHugger Robot
2020-11-04 18:33:42 +00:00
committed by Android (Google) Code Review
@@ -234,11 +234,25 @@ public abstract class AbstractLauncherUiTest {
return mDevice;
}
private boolean hasSystemUiObject(String resId) {
return mDevice.hasObject(By.res(SYSTEMUI_PACKAGE, resId));
}
@Before
public void setUp() throws Exception {
Assert.assertTrue("Keyguard is visible",
Log.d(TAG, "Before disabling battery defender");
mDevice.executeShellCommand("setprop vendor.battery.defender.disable 1");
Log.d(TAG, "Before enabling stay awake");
mDevice.executeShellCommand("settings put global stay_on_while_plugged_in 3");
for (int i = 0; i < 10 && hasSystemUiObject("keyguard_status_view"); ++i) {
Log.d(TAG, "Before unlocking the phone");
mDevice.executeShellCommand("input keyevent 82");
mDevice.waitForIdle();
}
Assert.assertTrue("Keyguard still visible",
mDevice.wait(
Until.gone(By.res(SYSTEMUI_PACKAGE, "keyguard_status_view")), 60000));
Log.d(TAG, "Keyguard is not visible");
final String launcherPackageName = mDevice.getLauncherPackageName();
try {