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

Commit bc7386c2 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Fix issue #4539687: At least one compatibility-mode app (Androminion)...

...will only launch when held in portrait mode.

There was a bug in the window manager that caused all of the careful code to
update the configuration in sync with movements between activities to break.
Now it is fixed, so this app works, and we no longer see the bad slow orientation
changes when switching between activities that want to be in different
orientations.

Change-Id: I5d93f99649849bdaca2e8bebade6b91b8b6cf645
parent b16b020d
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -90,7 +90,6 @@ import android.os.FileObserver;
import android.os.FileUtils;
import android.os.FileUtils;
import android.os.Handler;
import android.os.Handler;
import android.os.IBinder;
import android.os.IBinder;
import android.os.IInterface;
import android.os.IPermissionController;
import android.os.IPermissionController;
import android.os.Looper;
import android.os.Looper;
import android.os.Message;
import android.os.Message;
+30 −13
Original line number Original line Diff line number Diff line
@@ -153,6 +153,7 @@ public class WindowManagerService extends IWindowManager.Stub
    static final boolean DEBUG_WINDOW_MOVEMENT = false;
    static final boolean DEBUG_WINDOW_MOVEMENT = false;
    static final boolean DEBUG_TOKEN_MOVEMENT = false;
    static final boolean DEBUG_TOKEN_MOVEMENT = false;
    static final boolean DEBUG_ORIENTATION = false;
    static final boolean DEBUG_ORIENTATION = false;
    static final boolean DEBUG_APP_ORIENTATION = false;
    static final boolean DEBUG_CONFIGURATION = false;
    static final boolean DEBUG_CONFIGURATION = false;
    static final boolean DEBUG_APP_TRANSITIONS = false;
    static final boolean DEBUG_APP_TRANSITIONS = false;
    static final boolean DEBUG_STARTING_WINDOW = false;
    static final boolean DEBUG_STARTING_WINDOW = false;
@@ -427,6 +428,7 @@ public class WindowManagerService extends IWindowManager.Stub
    boolean mWindowsFreezingScreen = false;
    boolean mWindowsFreezingScreen = false;
    long mFreezeGcPending = 0;
    long mFreezeGcPending = 0;
    int mAppsFreezingScreen = 0;
    int mAppsFreezingScreen = 0;
    int mLastWindowForcedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;


    int mLayoutSeq = 0;
    int mLayoutSeq = 0;
    
    
@@ -3187,6 +3189,15 @@ public class WindowManagerService extends IWindowManager.Stub
    }
    }


    public int getOrientationFromWindowsLocked() {
    public int getOrientationFromWindowsLocked() {
        if (mDisplayFrozen || mOpeningApps.size() > 0 || mClosingApps.size() > 0) {
            // If the display is frozen, some activities may be in the middle
            // of restarting, and thus have removed their old window.  If the
            // window has the flag to hide the lock screen, then the lock screen
            // can re-appear and inflict its own orientation on us.  Keep the
            // orientation stable until this all settles down.
            return mLastWindowForcedOrientation;
        }

        int pos = mWindows.size() - 1;
        int pos = mWindows.size() - 1;
        while (pos >= 0) {
        while (pos >= 0) {
            WindowState wtoken = mWindows.get(pos);
            WindowState wtoken = mWindows.get(pos);
@@ -3194,7 +3205,7 @@ public class WindowManagerService extends IWindowManager.Stub
            if (wtoken.mAppToken != null) {
            if (wtoken.mAppToken != null) {
                // We hit an application window. so the orientation will be determined by the
                // We hit an application window. so the orientation will be determined by the
                // app window. No point in continuing further.
                // app window. No point in continuing further.
                return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
                return (mLastWindowForcedOrientation=ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
            }
            }
            if (!wtoken.isVisibleLw() || !wtoken.mPolicyVisibilityAfterAnim) {
            if (!wtoken.isVisibleLw() || !wtoken.mPolicyVisibilityAfterAnim) {
                continue;
                continue;
@@ -3204,10 +3215,10 @@ public class WindowManagerService extends IWindowManager.Stub
                    (req == ActivityInfo.SCREEN_ORIENTATION_BEHIND)){
                    (req == ActivityInfo.SCREEN_ORIENTATION_BEHIND)){
                continue;
                continue;
            } else {
            } else {
                return req;
                return (mLastWindowForcedOrientation=req);
            }
            }
        }
        }
        return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
        return (mLastWindowForcedOrientation=ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    }
    }


    public int getOrientationFromAppTokensLocked() {
    public int getOrientationFromAppTokensLocked() {
@@ -3220,16 +3231,23 @@ public class WindowManagerService extends IWindowManager.Stub
        while (pos >= 0) {
        while (pos >= 0) {
            AppWindowToken wtoken = mAppTokens.get(pos);
            AppWindowToken wtoken = mAppTokens.get(pos);
            pos--;
            pos--;

            if (DEBUG_APP_ORIENTATION) Slog.v(TAG, "Checking app orientation: " + wtoken);

            // if we're about to tear down this window and not seek for
            // if we're about to tear down this window and not seek for
            // the behind activity, don't use it for orientation
            // the behind activity, don't use it for orientation
            if (!findingBehind
            if (!findingBehind
                    && (!wtoken.hidden && wtoken.hiddenRequested)) {
                    && (!wtoken.hidden && wtoken.hiddenRequested)) {
                if (DEBUG_ORIENTATION) Slog.v(TAG, "Skipping " + wtoken
                        + " -- going to hide");
                continue;
                continue;
            }
            }


            if (!haveGroup) {
            if (!haveGroup) {
                // We ignore any hidden applications on the top.
                // We ignore any hidden applications on the top.
                if (wtoken.hiddenRequested || wtoken.willBeHidden) {
                if (wtoken.hiddenRequested || wtoken.willBeHidden) {
                    if (DEBUG_ORIENTATION) Slog.v(TAG, "Skipping " + wtoken
                            + " -- hidden on top");
                    continue;
                    continue;
                }
                }
                haveGroup = true;
                haveGroup = true;
@@ -3243,6 +3261,8 @@ public class WindowManagerService extends IWindowManager.Stub
                // user's orientation.
                // user's orientation.
                if (lastOrientation != ActivityInfo.SCREEN_ORIENTATION_BEHIND
                if (lastOrientation != ActivityInfo.SCREEN_ORIENTATION_BEHIND
                        && lastFullscreen) {
                        && lastFullscreen) {
                    if (DEBUG_ORIENTATION) Slog.v(TAG, "Done at " + wtoken
                            + " -- end of group, return " + lastOrientation);
                    return lastOrientation;
                    return lastOrientation;
                }
                }
            }
            }
@@ -3253,16 +3273,21 @@ public class WindowManagerService extends IWindowManager.Stub
            lastFullscreen = wtoken.appFullscreen;
            lastFullscreen = wtoken.appFullscreen;
            if (lastFullscreen
            if (lastFullscreen
                    && or != ActivityInfo.SCREEN_ORIENTATION_BEHIND) {
                    && or != ActivityInfo.SCREEN_ORIENTATION_BEHIND) {
                if (DEBUG_ORIENTATION) Slog.v(TAG, "Done at " + wtoken
                        + " -- full screen, return " + or);
                return or;
                return or;
            }
            }
            // If this application has requested an explicit orientation,
            // If this application has requested an explicit orientation,
            // then use it.
            // then use it.
            if (or != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
            if (or != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
                    && or != ActivityInfo.SCREEN_ORIENTATION_BEHIND) {
                    && or != ActivityInfo.SCREEN_ORIENTATION_BEHIND) {
                if (DEBUG_ORIENTATION) Slog.v(TAG, "Done at " + wtoken
                        + " -- explicitly set, return " + or);
                return or;
                return or;
            }
            }
            findingBehind |= (or == ActivityInfo.SCREEN_ORIENTATION_BEHIND);
            findingBehind |= (or == ActivityInfo.SCREEN_ORIENTATION_BEHIND);
        }
        }
        if (DEBUG_ORIENTATION) Slog.v(TAG, "No app is requesting an orientation");
        return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
        return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
    }
    }


@@ -3335,15 +3360,6 @@ public class WindowManagerService extends IWindowManager.Stub
     * android.os.IBinder)
     * android.os.IBinder)
     */
     */
    boolean updateOrientationFromAppTokensLocked(boolean inTransaction) {
    boolean updateOrientationFromAppTokensLocked(boolean inTransaction) {
        if (mDisplayFrozen || mOpeningApps.size() > 0 || mClosingApps.size() > 0) {
            // If the display is frozen, some activities may be in the middle
            // of restarting, and thus have removed their old window.  If the
            // window has the flag to hide the lock screen, then the lock screen
            // can re-appear and inflict its own orientation on us.  Keep the
            // orientation stable until this all settles down.
            return false;
        }

        boolean changed = false;
        boolean changed = false;
        long ident = Binder.clearCallingIdentity();
        long ident = Binder.clearCallingIdentity();
        try {
        try {
@@ -8934,9 +8950,10 @@ public class WindowManagerService extends IWindowManager.Stub
                    pw.print(" mAppsFreezingScreen="); pw.print(mAppsFreezingScreen);
                    pw.print(" mAppsFreezingScreen="); pw.print(mAppsFreezingScreen);
                    pw.print(" mWaitingForConfig="); pw.println(mWaitingForConfig);
                    pw.print(" mWaitingForConfig="); pw.println(mWaitingForConfig);
            pw.print("  mRotation="); pw.print(mRotation);
            pw.print("  mRotation="); pw.print(mRotation);
                    pw.print(" mForcedAppOrientation="); pw.print(mForcedAppOrientation);
                    pw.print(" mRequestedRotation="); pw.print(mRequestedRotation);
                    pw.print(" mRequestedRotation="); pw.print(mRequestedRotation);
                    pw.print(" mAltOrientation="); pw.println(mAltOrientation);
                    pw.print(" mAltOrientation="); pw.println(mAltOrientation);
            pw.print("  mLastWindowForcedOrientation"); pw.print(mLastWindowForcedOrientation);
                    pw.print(" mForcedAppOrientation="); pw.println(mForcedAppOrientation);
            pw.print("  mDeferredRotation="); pw.print(mDeferredRotation);
            pw.print("  mDeferredRotation="); pw.print(mDeferredRotation);
                    pw.print(", mDeferredRotationAnimFlags="); pw.println(mDeferredRotationAnimFlags);
                    pw.print(", mDeferredRotationAnimFlags="); pw.println(mDeferredRotationAnimFlags);
            pw.print("  mAnimationPending="); pw.print(mAnimationPending);
            pw.print("  mAnimationPending="); pw.print(mAnimationPending);