Merge "Allow current IME to start background activity"
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
@@ -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.
|
||||
*
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user