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

Commit eb0388fc authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fixed issue with screen rotation not working for landscape<->seascape"

parents 2c840fee 02896ab7
Loading
Loading
Loading
Loading
+5 −2
Original line number Original line Diff line number Diff line
@@ -1229,8 +1229,9 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
        case UPDATE_CONFIGURATION_TRANSACTION: {
        case UPDATE_CONFIGURATION_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            data.enforceInterface(IActivityManager.descriptor);
            Configuration config = Configuration.CREATOR.createFromParcel(data);
            Configuration config = Configuration.CREATOR.createFromParcel(data);
            updateConfiguration(config);
            final boolean updated = updateConfiguration(config);
            reply.writeNoException();
            reply.writeNoException();
            reply.writeInt(updated ? 1 : 0);
            return true;
            return true;
        }
        }


@@ -4593,7 +4594,7 @@ class ActivityManagerProxy implements IActivityManager
        data.recycle();
        data.recycle();
        return res;
        return res;
    }
    }
    public void updateConfiguration(Configuration values) throws RemoteException
    public boolean updateConfiguration(Configuration values) throws RemoteException
    {
    {
        Parcel data = Parcel.obtain();
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        Parcel reply = Parcel.obtain();
@@ -4601,8 +4602,10 @@ class ActivityManagerProxy implements IActivityManager
        values.writeToParcel(data, 0);
        values.writeToParcel(data, 0);
        mRemote.transact(UPDATE_CONFIGURATION_TRANSACTION, data, reply, 0);
        mRemote.transact(UPDATE_CONFIGURATION_TRANSACTION, data, reply, 0);
        reply.readException();
        reply.readException();
        boolean updated = reply.readInt() == 1;
        data.recycle();
        data.recycle();
        reply.recycle();
        reply.recycle();
        return updated;
    }
    }
    public void setRequestedOrientation(IBinder token, int requestedOrientation)
    public void setRequestedOrientation(IBinder token, int requestedOrientation)
            throws RemoteException {
            throws RemoteException {
+2 −1
Original line number Original line Diff line number Diff line
@@ -276,8 +276,9 @@ public interface IActivityManager extends IInterface {
     * Updates global configuration and applies changes to the entire system.
     * Updates global configuration and applies changes to the entire system.
     * @param values Update values for global configuration.
     * @param values Update values for global configuration.
     * @throws RemoteException
     * @throws RemoteException
     * @return Returns true if the configuration was updated.
     */
     */
    public void updateConfiguration(Configuration values) throws RemoteException;
    public boolean updateConfiguration(Configuration values) throws RemoteException;


    public void setRequestedOrientation(IBinder token,
    public void setRequestedOrientation(IBinder token,
            int requestedOrientation) throws RemoteException;
            int requestedOrientation) throws RemoteException;
+39 −6
Original line number Original line Diff line number Diff line
@@ -1136,6 +1136,20 @@ public final class ActivityManagerService extends ActivityManagerNative
     */
     */
    private Configuration mTempGlobalConfig = new Configuration();
    private Configuration mTempGlobalConfig = new Configuration();
    private final UpdateConfigurationResult mTmpUpdateConfigurationResult =
            new UpdateConfigurationResult();
    private static final class UpdateConfigurationResult {
        // Configuration changes that were updated.
        int changes;
        // If the activity was relaunched to match the new configuration.
        boolean activityRelaunched;
        void reset() {
            changes = 0;
            activityRelaunched = false;
        }
    }
    boolean mSuppressResizeConfigChanges;
    boolean mSuppressResizeConfigChanges;
    /**
    /**
@@ -18872,7 +18886,7 @@ public final class ActivityManagerService extends ActivityManagerNative
    }
    }
    @Override
    @Override
    public void updateConfiguration(Configuration values) {
    public boolean updateConfiguration(Configuration values) {
        enforceCallingPermission(android.Manifest.permission.CHANGE_CONFIGURATION,
        enforceCallingPermission(android.Manifest.permission.CHANGE_CONFIGURATION,
                "updateConfiguration()");
                "updateConfiguration()");
@@ -18887,13 +18901,20 @@ public final class ActivityManagerService extends ActivityManagerNative
            }
            }
            final long origId = Binder.clearCallingIdentity();
            final long origId = Binder.clearCallingIdentity();
            try {
                if (values != null) {
                if (values != null) {
                    Settings.System.clearConfiguration(values);
                    Settings.System.clearConfiguration(values);
                }
                }
            updateConfigurationLocked(values, null, false);
                updateConfigurationLocked(values, null, false, false /* persistent */,
                        UserHandle.USER_NULL, false /* deferResume */,
                        mTmpUpdateConfigurationResult);
                return mTmpUpdateConfigurationResult.changes != 0;
            } finally {
                Binder.restoreCallingIdentity(origId);
                Binder.restoreCallingIdentity(origId);
            }
            }
        }
        }
    }
    void updateUserConfigurationLocked() {
    void updateUserConfigurationLocked() {
        final Configuration configuration = new Configuration(mGlobalConfiguration);
        final Configuration configuration = new Configuration(mGlobalConfiguration);
@@ -18919,6 +18940,12 @@ public final class ActivityManagerService extends ActivityManagerNative
    // To cache the list of supported system locales
    // To cache the list of supported system locales
    private String[] mSupportedSystemLocales = null;
    private String[] mSupportedSystemLocales = null;
    private boolean updateConfigurationLocked(Configuration values, ActivityRecord starting,
            boolean initLocale, boolean persistent, int userId, boolean deferResume) {
        return updateConfigurationLocked(values, starting, initLocale, persistent, userId,
                deferResume, null /* result */);
    }
    /**
    /**
     * Do either or both things: (1) change the current configuration, and (2)
     * Do either or both things: (1) change the current configuration, and (2)
     * make sure the given activity is running with the (now) current
     * make sure the given activity is running with the (now) current
@@ -18930,7 +18957,8 @@ public final class ActivityManagerService extends ActivityManagerNative
     *               for that particular user
     *               for that particular user
     */
     */
    private boolean updateConfigurationLocked(Configuration values, ActivityRecord starting,
    private boolean updateConfigurationLocked(Configuration values, ActivityRecord starting,
            boolean initLocale, boolean persistent, int userId, boolean deferResume) {
            boolean initLocale, boolean persistent, int userId, boolean deferResume,
            UpdateConfigurationResult result) {
        int changes = 0;
        int changes = 0;
        boolean kept = true;
        boolean kept = true;
@@ -18949,6 +18977,11 @@ public final class ActivityManagerService extends ActivityManagerNative
                mWindowManager.continueSurfaceLayout();
                mWindowManager.continueSurfaceLayout();
            }
            }
        }
        }
        if (result != null) {
            result.changes = changes;
            result.activityRelaunched = !kept;
        }
        return kept;
        return kept;
    }
    }
+36 −19
Original line number Original line Diff line number Diff line
@@ -213,7 +213,6 @@ import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_BOOT;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_BOOT;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_CONFIGURATION;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_DRAG;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_DRAG;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_FOCUS;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_FOCUS;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_FOCUS_LIGHT;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_FOCUS_LIGHT;
@@ -222,12 +221,10 @@ import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_KEYGUARD;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_KEEP_SCREEN_ON;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_KEEP_SCREEN_ON;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ORIENTATION;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ORIENTATION;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_RESIZE;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_SCREENSHOT;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_SCREENSHOT;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_SCREEN_ON;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_SCREEN_ON;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STACK;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STACK;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STARTING_WINDOW;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STARTING_WINDOW;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_SURFACE_TRACE;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TASK_POSITIONING;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TASK_POSITIONING;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TOKEN_MOVEMENT;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TOKEN_MOVEMENT;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY;
@@ -5441,26 +5438,31 @@ public class WindowManagerService extends IWindowManager.Stub
        }
        }
    }
    }


    public void updateRotationUnchecked(boolean alwaysSendConfiguration, boolean forceRelayout) {
    private void updateRotationUnchecked(boolean alwaysSendConfiguration,
        if(DEBUG_ORIENTATION) Slog.v(TAG_WM, "updateRotationUnchecked("
            boolean forceRelayout) {
                   + "alwaysSendConfiguration=" + alwaysSendConfiguration + ")");
        if(DEBUG_ORIENTATION) Slog.v(TAG_WM, "updateRotationUnchecked:"
                + " alwaysSendConfiguration=" + alwaysSendConfiguration
                + " forceRelayout=" + forceRelayout);


        long origId = Binder.clearCallingIdentity();
        long origId = Binder.clearCallingIdentity();
        boolean changed;

        try {
            final boolean rotationChanged;
            synchronized (mWindowMap) {
            synchronized (mWindowMap) {
            changed = updateRotationUncheckedLocked(false);
                rotationChanged = updateRotationUncheckedLocked(false);
            if (!changed || forceRelayout) {
                if (!rotationChanged || forceRelayout) {
                    getDefaultDisplayContentLocked().setLayoutNeeded();
                    getDefaultDisplayContentLocked().setLayoutNeeded();
                    mWindowPlacerLocked.performSurfacePlacement();
                    mWindowPlacerLocked.performSurfacePlacement();
                }
                }
            }
            }


        if (changed || alwaysSendConfiguration) {
            if (rotationChanged || alwaysSendConfiguration) {
                sendNewConfiguration();
                sendNewConfiguration();
            }
            }

        } finally {
            Binder.restoreCallingIdentity(origId);
            Binder.restoreCallingIdentity(origId);
        }
        }
    }




    // TODO(multidisplay): Rotate any display?
    // TODO(multidisplay): Rotate any display?
@@ -5470,7 +5472,7 @@ public class WindowManagerService extends IWindowManager.Stub
     * Returns true if the rotation has been changed.  In this case YOU
     * Returns true if the rotation has been changed.  In this case YOU
     * MUST CALL sendNewConfiguration() TO UNFREEZE THE SCREEN.
     * MUST CALL sendNewConfiguration() TO UNFREEZE THE SCREEN.
     */
     */
    public boolean updateRotationUncheckedLocked(boolean inTransaction) {
    boolean updateRotationUncheckedLocked(boolean inTransaction) {
        if (mDeferredRotationPauseCount > 0) {
        if (mDeferredRotationPauseCount > 0) {
            // Rotation updates have been paused temporarily.  Defer the update until
            // Rotation updates have been paused temporarily.  Defer the update until
            // updates have been resumed.
            // updates have been resumed.
@@ -6121,10 +6123,25 @@ public class WindowManagerService extends IWindowManager.Stub
    /**
    /**
     * Instruct the Activity Manager to fetch new configurations, update global configuration
     * Instruct the Activity Manager to fetch new configurations, update global configuration
     * and broadcast changes to config-changed listeners if appropriate.
     * and broadcast changes to config-changed listeners if appropriate.
     * NOTE: Can't be called with the window manager lock held since it call into activity manager.
     */
     */
    void sendNewConfiguration() {
    void sendNewConfiguration() {
        try {
        try {
            mActivityManager.updateConfiguration(null);
            final boolean configUpdated = mActivityManager.updateConfiguration(null);
            if (!configUpdated) {
                // Something changed (E.g. device rotation), but no configuration update is needed.
                // E.g. changing device rotation by 180 degrees. Go ahead and perform surface
                // placement to unfreeze the display since we froze it when the rotation was updated
                // in updateRotationUncheckedLocked.
                synchronized (mWindowMap) {
                    if (mWaitingForConfig) {
                        mWaitingForConfig = false;
                        mLastFinishedFreezeSource = "config-unchanged";
                        getDefaultDisplayContentLocked().setLayoutNeeded();
                        mWindowPlacerLocked.performSurfacePlacement();
                    }
                }
            }
        } catch (RemoteException e) {
        } catch (RemoteException e) {
        }
        }
    }
    }