Loading services/core/java/com/android/server/wm/ActivityStarter.java +9 −0 Original line number Diff line number Diff line Loading @@ -1281,6 +1281,15 @@ class ActivityStarter { return false; } // IME should always be allowed to start activity, like IME settings. final WindowState imeWindow = mRootWindowContainer.getCurrentInputMethodWindow(); if (imeWindow != null && callingAppId == imeWindow.mOwnerUid) { if (DEBUG_ACTIVITY_STARTS) { Slog.d(TAG, "Activity start allowed for active ime (" + callingUid + ")"); } return false; } // App switching will be allowed if BAL app switching flag is not enabled, or if // its app switching rule allows it. // This is used to block background activity launch even if the app is still Loading services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java +15 −0 Original line number Diff line number Diff line Loading @@ -126,6 +126,7 @@ public class ActivityStarterTests extends WindowTestsBase { private static final String FAKE_CALLING_PACKAGE = "com.whatever.dude"; private static final int UNIMPORTANT_UID = 12345; private static final int UNIMPORTANT_UID2 = 12346; private static final int CURRENT_IME_UID = 12347; @Before public void setUp() throws Exception { Loading Loading @@ -315,6 +316,12 @@ public class ActivityStarterTests extends WindowTestsBase { return prepareStarter(launchFlags, mockGetLaunchStack, LAUNCH_MULTIPLE); } private void setupImeWindow() { final WindowState imeWindow = createWindow(null, W_INPUT_METHOD, "mImeWindow", CURRENT_IME_UID); mDisplayContent.mInputMethodWindow = imeWindow; } /** * Creates a {@link ActivityStarter} with default parameters and necessary mocks. * Loading Loading @@ -654,6 +661,14 @@ public class ActivityStarterTests extends WindowTestsBase { UNIMPORTANT_UID, false, PROCESS_STATE_TOP + 1, UNIMPORTANT_UID2, false, PROCESS_STATE_TOP + 1, false, false, false, false, true); setupImeWindow(); runAndVerifyBackgroundActivityStartsSubtest( "disallowed_callingPackageNameIsIme_notAborted", false, CURRENT_IME_UID, false, PROCESS_STATE_TOP + 1, UNIMPORTANT_UID2, false, PROCESS_STATE_TOP + 1, false, false, false, false, false); } private void runAndVerifyBackgroundActivityStartsSubtest(String name, boolean shouldHaveAborted, Loading Loading
services/core/java/com/android/server/wm/ActivityStarter.java +9 −0 Original line number Diff line number Diff line Loading @@ -1281,6 +1281,15 @@ class ActivityStarter { return false; } // IME should always be allowed to start activity, like IME settings. final WindowState imeWindow = mRootWindowContainer.getCurrentInputMethodWindow(); if (imeWindow != null && callingAppId == imeWindow.mOwnerUid) { if (DEBUG_ACTIVITY_STARTS) { Slog.d(TAG, "Activity start allowed for active ime (" + callingUid + ")"); } return false; } // App switching will be allowed if BAL app switching flag is not enabled, or if // its app switching rule allows it. // This is used to block background activity launch even if the app is still Loading
services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java +15 −0 Original line number Diff line number Diff line Loading @@ -126,6 +126,7 @@ public class ActivityStarterTests extends WindowTestsBase { private static final String FAKE_CALLING_PACKAGE = "com.whatever.dude"; private static final int UNIMPORTANT_UID = 12345; private static final int UNIMPORTANT_UID2 = 12346; private static final int CURRENT_IME_UID = 12347; @Before public void setUp() throws Exception { Loading Loading @@ -315,6 +316,12 @@ public class ActivityStarterTests extends WindowTestsBase { return prepareStarter(launchFlags, mockGetLaunchStack, LAUNCH_MULTIPLE); } private void setupImeWindow() { final WindowState imeWindow = createWindow(null, W_INPUT_METHOD, "mImeWindow", CURRENT_IME_UID); mDisplayContent.mInputMethodWindow = imeWindow; } /** * Creates a {@link ActivityStarter} with default parameters and necessary mocks. * Loading Loading @@ -654,6 +661,14 @@ public class ActivityStarterTests extends WindowTestsBase { UNIMPORTANT_UID, false, PROCESS_STATE_TOP + 1, UNIMPORTANT_UID2, false, PROCESS_STATE_TOP + 1, false, false, false, false, true); setupImeWindow(); runAndVerifyBackgroundActivityStartsSubtest( "disallowed_callingPackageNameIsIme_notAborted", false, CURRENT_IME_UID, false, PROCESS_STATE_TOP + 1, UNIMPORTANT_UID2, false, PROCESS_STATE_TOP + 1, false, false, false, false, false); } private void runAndVerifyBackgroundActivityStartsSubtest(String name, boolean shouldHaveAborted, Loading