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

Commit b95199a2 authored by Charles Chen's avatar Charles Chen
Browse files

Avoid IMS uses overridden configuration

When IMS switches to a secondary display, the WPC will be overriden
to ImeCOntainer's config on the secondary display.
It may lead to the IMS uses wrong config initially.

This CL removes the logic to register IME container's configuration
listener. It is not needed since we change to use
WindowProviderService to listen to IME container update instead.

It also add more logs to collect more information if this approach
is not helpful.

Test: presubmit
Bug: 327766144
Change-Id: Id1d8035a4ca46d08ee0ca7cf6822bb57b49fac63
parent 924041dd
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -165,7 +165,8 @@ public class WindowTokenClient extends Binder {
            Log.d(TAG, "Configuration not dispatch to IME because configuration is up"
                    + " to date. Current config=" + context.getResources().getConfiguration()
                    + ", reported config=" + currentConfig
                    + ", updated config=" + newConfig);
                    + ", updated config=" + newConfig
                    + ", updated display ID=" + newDisplayId);
        }
        // Update display first. In case callers want to obtain display information(
        // ex: DisplayMetrics) in #onConfigurationChanged callback.
@@ -190,13 +191,18 @@ public class WindowTokenClient extends Binder {
            if (mShouldDumpConfigForIme) {
                if (!shouldReportConfigChange) {
                    Log.d(TAG, "Only apply configuration update to Resources because "
                            + "shouldReportConfigChange is false.\n" + Debug.getCallers(5));
                            + "shouldReportConfigChange is false. "
                            + "context=" + context
                            + ", config=" + context.getResources().getConfiguration()
                            + ", display ID=" + context.getDisplayId() + "\n"
                            + Debug.getCallers(5));
                } else if (diff == 0) {
                    Log.d(TAG, "Configuration not dispatch to IME because configuration has no "
                            + " public difference with updated config. "
                            + " Current config=" + context.getResources().getConfiguration()
                            + ", reported config=" + currentConfig
                            + ", updated config=" + newConfig);
                            + ", updated config=" + newConfig
                            + ", display ID=" + context.getDisplayId());
                }
            }
        }
+0 −23
Original line number Diff line number Diff line
@@ -5682,29 +5682,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        throw e;
    }

    /**
     * Sets the corresponding {@link DisplayArea} information for the process global
     * configuration. To be called when we need to show IME on a different {@link DisplayArea}
     * or display.
     *
     * @param pid The process id associated with the IME window.
     * @param imeContainer The DisplayArea that contains the IME window.
     */
    void onImeWindowSetOnDisplayArea(final int pid, @NonNull final DisplayArea imeContainer) {
        if (pid == MY_PID || pid < 0) {
            ProtoLog.w(WM_DEBUG_CONFIGURATION,
                    "Trying to update display configuration for system/invalid process.");
            return;
        }
        final WindowProcessController process = mProcessMap.getProcess(pid);
        if (process == null) {
            ProtoLog.w(WM_DEBUG_CONFIGURATION, "Trying to update display "
                    + "configuration for invalid process, pid=%d", pid);
            return;
        }
        process.registerDisplayAreaConfigurationListener(imeContainer);
    }

    @Override
    public void setRunningRemoteTransitionDelegate(IApplicationThread delegate) {
        final TransitionController controller = getTransitionController();
+0 −5
Original line number Diff line number Diff line
@@ -4195,11 +4195,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
     */
    void setInputMethodWindowLocked(WindowState win) {
        mInputMethodWindow = win;
        // Update display configuration for IME process.
        if (mInputMethodWindow != null) {
            final int imePid = mInputMethodWindow.mSession.mPid;
            mAtmService.onImeWindowSetOnDisplayArea(imePid, mImeWindowsContainer);
        }
        mInsetsStateController.getImeSourceProvider().setWindowContainer(win,
                mDisplayPolicy.getImeSourceFrameProvider(), null);
        computeImeTarget(true /* updateImeTarget */);
+0 −10
Original line number Diff line number Diff line
@@ -1068,16 +1068,6 @@ public class DisplayContentTests extends WindowTestsBase {
                mDisplayContent.getImeTarget(IME_TARGET_LAYERING));
    }

    @SetupWindows(addWindows = W_INPUT_METHOD)
    @Test
    public void testInputMethodSet_listenOnDisplayAreaConfigurationChanged() {
        spyOn(mAtm);
        mDisplayContent.setInputMethodWindowLocked(mImeWindow);

        verify(mAtm).onImeWindowSetOnDisplayArea(
                mImeWindow.mSession.mPid, mDisplayContent.getImeContainer());
    }

    @Test
    public void testAllowsTopmostFullscreenOrientation() {
        final DisplayContent dc = createNewDisplay();