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

Commit 5d9f5477 authored by Craig Mautner's avatar Craig Mautner
Browse files

Relayout windows that handle their own config change.

If a window claims to handle its own configuration change then we
won't destroy and recreate its window on a configuration change.
Normally that recreation triggers the first layout following
orientation change because mHaveFrame is false. Windows that handle
their own configuration changes never got a relayout pass following a
change in orientation.

This change passes the configuration changes that an application
handles into the AppWindowToken. If the app says it handles
orientation or screen size changes then a relayout will occur when the
configuration has changed.

Fixes bug 11647107.

Change-Id: Ie8d49fd050442ebbdcf0b805087894e3a2fc4be9
parent c481a634
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -78,7 +78,8 @@ interface IWindowManager
    void addWindowToken(IBinder token, int type);
    void removeWindowToken(IBinder token);
    void addAppToken(int addPos, IApplicationToken token, int groupId, int stackId,
            int requestedOrientation, boolean fullscreen, boolean showWhenLocked, int userId);
            int requestedOrientation, boolean fullscreen, boolean showWhenLocked, int userId,
            int configChanges);
    void setAppGroupId(IBinder token, int groupId);
    void setAppOrientation(IApplicationToken token, int requestedOrientation);
    int getAppOrientation(IApplicationToken token);
+5 −3
Original line number Diff line number Diff line
@@ -1717,7 +1717,7 @@ final class ActivityStack {
                        mWindowManager.addAppToken(task.mActivities.indexOf(r), r.appToken,
                                r.task.taskId, mStackId, r.info.screenOrientation, r.fullscreen,
                                (r.info.flags & ActivityInfo.FLAG_SHOW_ON_LOCK_SCREEN) != 0,
                                r.userId);
                                r.userId, r.info.configChanges);
                        if (VALIDATE_TOKENS) {
                            validateAppTokensLocked();
                        }
@@ -1778,7 +1778,8 @@ final class ActivityStack {
            r.updateOptionsLocked(options);
            mWindowManager.addAppToken(task.mActivities.indexOf(r),
                    r.appToken, r.task.taskId, mStackId, r.info.screenOrientation, r.fullscreen,
                    (r.info.flags & ActivityInfo.FLAG_SHOW_ON_LOCK_SCREEN) != 0, r.userId);
                    (r.info.flags & ActivityInfo.FLAG_SHOW_ON_LOCK_SCREEN) != 0, r.userId,
                    r.info.configChanges);
            boolean doShow = true;
            if (newTask) {
                // Even though this activity is starting fresh, we still need
@@ -1821,7 +1822,8 @@ final class ActivityStack {
            // because there is nothing for it to animate on top of.
            mWindowManager.addAppToken(task.mActivities.indexOf(r), r.appToken,
                    r.task.taskId, mStackId, r.info.screenOrientation, r.fullscreen,
                    (r.info.flags & ActivityInfo.FLAG_SHOW_ON_LOCK_SCREEN) != 0, r.userId);
                    (r.info.flags & ActivityInfo.FLAG_SHOW_ON_LOCK_SCREEN) != 0, r.userId,
                    r.info.configChanges);
            ActivityOptions.abort(options);
        }
        if (VALIDATE_TOKENS) {
+1 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ class AppWindowToken extends WindowToken {
    int groupId = -1;
    boolean appFullscreen;
    int requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
    int configChanges;
    boolean showWhenLocked;

    // The input dispatching timeout for this application token in nanoseconds.
+7 −3
Original line number Diff line number Diff line
@@ -3406,7 +3406,8 @@ public class WindowManagerService extends IWindowManager.Stub

    @Override
    public void addAppToken(int addPos, IApplicationToken token, int taskId, int stackId,
            int requestedOrientation, boolean fullscreen, boolean showWhenLocked, int userId) {
            int requestedOrientation, boolean fullscreen, boolean showWhenLocked, int userId,
            int configChanges) {
        if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
                "addAppToken()")) {
            throw new SecurityException("Requires MANAGE_APP_TOKENS permission");
@@ -3438,6 +3439,7 @@ public class WindowManagerService extends IWindowManager.Stub
            atoken.appFullscreen = fullscreen;
            atoken.showWhenLocked = showWhenLocked;
            atoken.requestedOrientation = requestedOrientation;
            atoken.configChanges = configChanges;
            if (DEBUG_TOKEN_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(TAG, "addAppToken: " + atoken
                    + " to stack=" + stackId + " task=" + taskId + " at " + addPos);

@@ -8268,8 +8270,10 @@ public class WindowManagerService extends IWindowManager.Stub
            // windows, since that means "perform layout as normal,
            // just don't display").
            if (!gone || !win.mHaveFrame || win.mLayoutNeeded
                    || win.mAttrs.type == TYPE_KEYGUARD && win.isConfigChanged()
                    || mOpeningApps.contains(win.mAppToken)
                    || win.isConfigChanged() && (win.mAttrs.type == TYPE_KEYGUARD ||
                            (win.mAppToken != null && (win.mAppToken.configChanges &
                            (ActivityInfo.CONFIG_SCREEN_SIZE | ActivityInfo.CONFIG_ORIENTATION))
                                    != 0))
                    || win.mAttrs.type == TYPE_UNIVERSE_BACKGROUND) {
                if (!win.mLayoutAttached) {
                    if (initial) {
+1 −1
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ public class WindowManagerPermissionTests extends TestCase {
        }
        
        try {
            mWm.addAppToken(0, null, 0, 0, 0, false, false, 0);
            mWm.addAppToken(0, null, 0, 0, 0, false, false, 0, 0);
            fail("IWindowManager.addAppToken did not throw SecurityException as"
                    + " expected");
        } catch (SecurityException e) {
Loading