From 999b8a9f332fbd4247c3cefc3cc470cb6b0234a7 Mon Sep 17 00:00:00 2001 From: Pawan Wagh Date: Tue, 2 Jul 2024 22:59:56 +0000 Subject: [PATCH] Fix flaky test for persistent notifications Persistent notifications test sometimes fails due to setup activity doesn't exit due to failed intent. Adding setup exit command when on device tests are starting and adding timeout for transition. Test: m Settings && adb install -r $ANDROID_PRODUCT_OUT/system_ext/priv-app/Settings/Settings.apk Flag: EXEMPT bugfix Bug: 349820489 Change-Id: Iaf1c1f481612367bbce919b27e89f88a24abb582 --- .../settings/development/PageAgnosticNotificationService.java | 2 +- tests/Enable16KbTests/src/com/android/test/Enable16KbTest.java | 2 ++ .../settings/development/test/Enable16KbDeviceTest.java | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/development/PageAgnosticNotificationService.java b/src/com/android/settings/development/PageAgnosticNotificationService.java index 40dff0c8dbf..1bdda410d69 100644 --- a/src/com/android/settings/development/PageAgnosticNotificationService.java +++ b/src/com/android/settings/development/PageAgnosticNotificationService.java @@ -134,6 +134,6 @@ public class PageAgnosticNotificationService extends Service { // No updates should be allowed in page-agnostic mode disableAutomaticUpdates(); - return Service.START_NOT_STICKY; + return Service.START_REDELIVER_INTENT; } } diff --git a/tests/Enable16KbTests/src/com/android/test/Enable16KbTest.java b/tests/Enable16KbTests/src/com/android/test/Enable16KbTest.java index b611d617907..e4ebdefb1a5 100644 --- a/tests/Enable16KbTests/src/com/android/test/Enable16KbTest.java +++ b/tests/Enable16KbTests/src/com/android/test/Enable16KbTest.java @@ -76,11 +76,13 @@ public class Enable16KbTest extends BaseHostJUnit4Test { installTestApp(); // Enable developer option and switch to 16kb kernel and Check page size + getDevice().enableAdbRoot(); runTestAndWait(SWITCH_TO_16KB); result = getDevice().executeShellCommand("getconf PAGE_SIZE"); assertEquals("16384", result.strip()); // switch back to 4kb kernel and check page size + getDevice().enableAdbRoot(); runTestAndWait(SWITCH_TO_4KB); result = getDevice().executeShellCommand("getconf PAGE_SIZE"); assertEquals("4096", result.strip()); diff --git a/tests/Enable16KbTests/test_16kb_app/src/com/android/settings/development/test/Enable16KbDeviceTest.java b/tests/Enable16KbTests/test_16kb_app/src/com/android/settings/development/test/Enable16KbDeviceTest.java index e5ccbb92da0..9e489cf4115 100644 --- a/tests/Enable16KbTests/test_16kb_app/src/com/android/settings/development/test/Enable16KbDeviceTest.java +++ b/tests/Enable16KbTests/test_16kb_app/src/com/android/settings/development/test/Enable16KbDeviceTest.java @@ -68,6 +68,8 @@ public class Enable16KbDeviceTest { throw new RuntimeException("failed to freeze device orientation", e); } + mDevice.executeShellCommand("am start -a com.android.setupwizard.FOUR_CORNER_EXIT"); + mDevice.waitForWindowUpdate(null, TIMEOUT); mDevice.executeShellCommand("input keyevent KEYCODE_WAKEUP"); mDevice.executeShellCommand("wm dismiss-keyguard"); } @@ -150,6 +152,7 @@ public class Enable16KbDeviceTest { private void openPersistentNotification(String title) { mDevice.openNotification(); + mDevice.waitForWindowUpdate(null, TIMEOUT); verifyTextOnScreen(title); mDevice.wait(Until.findObject(By.text(title)), TIMEOUT).click(); mDevice.waitForWindowUpdate(null, TIMEOUT);