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

Commit 8e3022c1 authored by Ming-Shin Lu's avatar Ming-Shin Lu Committed by Automerger Merge Worker
Browse files

Merge "Consolidate disabling fixed-rotation when IME may visible on activity"...

Merge "Consolidate disabling fixed-rotation when IME may visible on activity" into sc-dev am: 5c095fbc

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14920751

Change-Id: I753b937b5c69b17cdc0e8f87adf3a4080151e6d3
parents bd350dfc 5c095fbc
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -665,6 +665,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    private boolean mLastContainsDismissKeyguardWindow;
    private boolean mLastContainsTurnScreenOnWindow;

    /** Whether the IME is showing when transitioning away from this activity. */
    boolean mLastImeShown;

    /**
     * A flag to determine if this AR is in the process of closing or entering PIP. This is needed
     * to help AR know that the app is in the process of closing but hasn't yet started closing on
@@ -4843,6 +4846,15 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            setClientVisible(visible);
        }

        if (!visible) {
            final InsetsControlTarget imeInputTarget = mDisplayContent.getImeTarget(
                    DisplayContent.IME_TARGET_INPUT);
            mLastImeShown = imeInputTarget != null && imeInputTarget.getWindow() != null
                    && imeInputTarget.getWindow().mActivityRecord == this
                    && mDisplayContent.mInputMethodWindow != null
                    && mDisplayContent.mInputMethodWindow.isVisible();
        }

        final DisplayContent displayContent = getDisplayContent();
        if (!displayContent.mClosingApps.contains(this)
                && !displayContent.mOpeningApps.contains(this)) {
+22 −3
Original line number Diff line number Diff line
@@ -63,6 +63,8 @@ import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
import static android.view.WindowManager.LayoutParams.FLAG_SPLIT_TOUCH;
import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
import static android.view.WindowManager.LayoutParams.TYPE_BOOT_PROGRESS;
@@ -208,6 +210,7 @@ import android.view.Surface.Rotation;
import android.view.SurfaceControl;
import android.view.SurfaceControl.Transaction;
import android.view.SurfaceSession;
import android.view.View;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.WindowManager.DisplayImePolicy;
@@ -1558,9 +1561,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            // to cover the activity configuration change.
            return false;
        }
        if ((r.mStartingData != null && r.mStartingData.hasImeSurface())
                || (mInsetsStateController.getImeSourceProvider()
                        .getSource().getVisibleFrame() != null)) {
        if (r.attachedToProcess() && mayImeShowOnLaunchingActivity(r)) {
            // Currently it is unknown that when will IME window be ready. Reject the case to
            // avoid flickering by showing IME in inconsistent orientation.
            return false;
@@ -1616,6 +1617,24 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        return true;
    }

    /** Returns {@code true} if the IME is possible to show on the launching activity. */
    private boolean mayImeShowOnLaunchingActivity(@NonNull ActivityRecord r) {
        final WindowState win = r.findMainWindow();
        if (win == null) {
            return false;
        }
        // See InputMethodManagerService#shouldRestoreImeVisibility that we expecting the IME
        // should be hidden when the window set the hidden softInputMode.
        final int softInputMode = win.mAttrs.softInputMode;
        switch (softInputMode & WindowManager.LayoutParams.SOFT_INPUT_MASK_STATE) {
            case SOFT_INPUT_STATE_ALWAYS_HIDDEN:
            case SOFT_INPUT_STATE_HIDDEN:
                return false;
        }
        return r.mLastImeShown && mInputMethodWindow != null && mInputMethodWindow.mHasSurface
                && mInputMethodWindow.mViewVisibility == View.VISIBLE;
    }

    /** Returns {@code true} if the top activity is transformed with the new rotation of display. */
    boolean hasTopFixedRotationLaunchingApp() {
        return mFixedRotationLaunchingApp != null
+2 −1
Original line number Diff line number Diff line
@@ -443,7 +443,8 @@ class TaskSnapshotController {
        } else {
            excludeLayers = new SurfaceControl[0];
        }
        builder.setHasImeSurface(!excludeIme && imeWindow != null && imeWindow.isDrawn());
        builder.setHasImeSurface(!excludeIme && imeWindow != null && imeWindow.isVisible());

        final SurfaceControl.ScreenshotHardwareBuffer screenshotBuffer =
                SurfaceControl.captureLayersExcluding(
                        task.getSurfaceControl(), mTmpRect, scaleFraction,
+2 −2
Original line number Diff line number Diff line
@@ -214,8 +214,8 @@ public class TaskSnapshotControllerTest extends WindowTestsBase {
        spyOn(mDisplayContent);
        spyOn(mDisplayContent.mInputMethodWindow);
        when(task.getDisplayContent().shouldImeAttachedToApp()).thenReturn(true);
        // Intentionally set the IME window is in drawn state.
        doReturn(true).when(mDisplayContent.mInputMethodWindow).isDrawn();
        // Intentionally set the IME window is in visible state.
        doReturn(true).when(mDisplayContent.mInputMethodWindow).isVisible();
        // Verify no NPE happens when calling createTaskSnapshot.
        try {
            final TaskSnapshot.Builder builder = new TaskSnapshot.Builder();