From c0ef31e38f2b73ca2d585f4eb7cb86ef97108e09 Mon Sep 17 00:00:00 2001 From: Vadim Tryshev Date: Sat, 31 Oct 2020 01:50:29 +0000 Subject: [PATCH] Revert "Removing workaround for battery defender" This reverts commit ff39fd3e14329db22ef34da32b9116fbe39af6f1. Reason for revert: The CL coincided with a start of flakes "phone is locked". Let's revert and see if it fixed that. https://flakes-clusters.corp.google.com/#/?androidAtpBranch=git_master&androidAtpModule=com.google.android.apps.nexuslauncher.out_of_proc_tests&d=30&cid=9fd6b65c-e48c-4bc3-b19b-f5c610a1999a&maxResults=20 Change-Id: I90f8abbb1794c19593ed8a235a82c0e53030c0a2 --- .../launcher3/ui/AbstractLauncherUiTest.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index d3fc89e6be..e118481570 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -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 {