From 5ef07b0c26421dfa596d56a6851497c1b802ea7d Mon Sep 17 00:00:00 2001 From: Achim Thesmann Date: Wed, 25 Jan 2023 04:39:24 +0000 Subject: [PATCH] Explicitly set DeviceConfig for BAL This tests behavior depends on the state of the DeviceConfig, so to flip the value the DeviceConfig needs to be set explicitly in the test. Test: atest ActivityStarterTests Bug: 266015587 Change-Id: Ia296083c8606614e7e3c0d1deae232f980f660df --- .../server/wm/ActivityStarterTests.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java index 1deb58e9cefb9..2baa54cac21f4 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java @@ -99,6 +99,7 @@ import android.os.IBinder; import android.os.Process; import android.os.RemoteException; import android.platform.test.annotations.Presubmit; +import android.provider.DeviceConfig; import android.service.voice.IVoiceInteractionSession; import android.util.Pair; import android.util.Size; @@ -108,10 +109,12 @@ import android.window.TaskFragmentOrganizerToken; import androidx.test.filters.SmallTest; +import com.android.compatibility.common.util.DeviceConfigStateHelper; import com.android.server.pm.pkg.AndroidPackage; import com.android.server.wm.LaunchParamsController.LaunchParamsModifier; import com.android.server.wm.utils.MockTracker; +import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -130,10 +133,9 @@ import java.util.Set; @Presubmit @RunWith(WindowTestRunner.class) public class ActivityStarterTests extends WindowTestsBase { - private ActivityStartController mController; - private ActivityMetricsLogger mActivityMetricsLogger; - private PackageManagerInternal mMockPackageManager; + private static final String ENABLE_DEFAULT_RESCIND_BAL_PRIVILEGES_FROM_PENDING_INTENT_SENDER = + "enable_default_rescind_bal_privileges_from_pending_intent_sender"; private static final int PRECONDITION_NO_CALLER_APP = 1; private static final int PRECONDITION_NO_INTENT_COMPONENT = 1 << 1; private static final int PRECONDITION_NO_ACTIVITY_INFO = 1 << 2; @@ -144,7 +146,6 @@ public class ActivityStarterTests extends WindowTestsBase { private static final int PRECONDITION_DIFFERENT_UID = 1 << 7; private static final int PRECONDITION_ACTIVITY_SUPPORTS_INTENT_EXCEPTION = 1 << 8; private static final int PRECONDITION_CANNOT_START_ANY_ACTIVITY = 1 << 9; - private static final int FAKE_CALLING_UID = 666; private static final int FAKE_REAL_CALLING_UID = 667; private static final String FAKE_CALLING_PACKAGE = "com.whatever.dude"; @@ -152,6 +153,13 @@ public class ActivityStarterTests extends WindowTestsBase { private static final int UNIMPORTANT_UID2 = 12346; private static final int CURRENT_IME_UID = 12347; + protected final DeviceConfigStateHelper mDeviceConfig = new DeviceConfigStateHelper( + DeviceConfig.NAMESPACE_WINDOW_MANAGER); + + private ActivityStartController mController; + private ActivityMetricsLogger mActivityMetricsLogger; + private PackageManagerInternal mMockPackageManager; + @Before public void setUp() throws Exception { mController = mock(ActivityStartController.class); @@ -160,6 +168,13 @@ public class ActivityStarterTests extends WindowTestsBase { doReturn(balController).when(mController).getBackgroundActivityLaunchController(); mActivityMetricsLogger = mock(ActivityMetricsLogger.class); clearInvocations(mActivityMetricsLogger); + mDeviceConfig.set(ENABLE_DEFAULT_RESCIND_BAL_PRIVILEGES_FROM_PENDING_INTENT_SENDER, + String.valueOf(true)); + } + + @After + public void tearDown() throws Exception { + mDeviceConfig.close(); } @Test