Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 142344cc authored by Ricky Wai's avatar Ricky Wai
Browse files

Allow current IME to start background activity

Current active IME should be always allowed to start activity,
like IME settings.

Bug: 159433730
Bug: 168397303
Test: Click home button, then click on any edit text on home screen and
open IME setting from IME, setting app is not blocked / delayed.

Change-Id: I959cdca58489701453f645a02de0c4879661029b
parent 5de129f2
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1284,6 +1284,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
+15 −0
Original line number Diff line number Diff line
@@ -123,6 +123,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 {
@@ -307,6 +308,12 @@ public class ActivityStarterTests extends WindowTestsBase {
        return prepareStarter(launchFlags, true /* mockGetLaunchStack */);
    }

    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.
     *
@@ -638,6 +645,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,