From f9ccf0175dc56049abfa067704dbd81af16331cc Mon Sep 17 00:00:00 2001 From: vadimt Date: Fri, 14 May 2021 11:04:41 -0700 Subject: [PATCH] Revert "Removing workaround for battery defender" This reverts commit f4bb052ca076fc2fb8d6f29140252b6154c984e1. Reason: we have new episodes of phone locking during the test. https://flakes-clusters.corp.google.com/#?androidAtpBranch=git_sc-dev&androidAtpModule=com.google.android.apps.nexuslauncher.out_of_proc_tests&d=3&maxResults=10 https://flakes-clusters.corp.google.com/#?androidAtpBranch=git_sc-dev&androidAtpModule=com.google.android.apps.nexuslauncher.tests&d=3&maxResults=10 Search for "Phone is locked" and "Keyguard is visible". Also, for new devices, the phone is locked consistently, see for example Redfin here: https://blackbox.googleplex.com/dashboard/Launcher3Main_new_devices/testsuite/git_master/nexuslauncher_oop_tests_platform/2/bramble-userdebug/0 Reverting to see whether this helps. Bug: 151613234 Test: presubmit Change-Id: I44a94f9722deaa21d89fdfd79646ae661ebe972d --- .../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 ca463e6042..cbd948035c 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -247,12 +247,26 @@ 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 { mLauncher.onTestStart(); - Assert.assertTrue("Keyguard is visible, which is likely caused by a crash in SysUI", + 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", TestHelpers.wait( Until.gone(By.res(SYSTEMUI_PACKAGE, "keyguard_status_view")), 60000)); + Log.d(TAG, "Keyguard is not visible"); final String launcherPackageName = mDevice.getLauncherPackageName(); try {