OSDN Git Service

Remove rotation and app bounds from Configuration diff.
authorBryce Lee <brycelee@google.com>
Thu, 27 Jul 2017 21:06:22 +0000 (14:06 -0700)
committerBryce Lee <brycelee@google.com>
Fri, 28 Jul 2017 14:49:01 +0000 (07:49 -0700)
The presence of these new flags leads to issues with application that
do not expect their presence. Since these flags can appear at
critical times, such as on orientation change, these issues are
brought to the surface often.

This CL remedies this problem by first removing the rotation
property. It is not used and the original issue of orientation and
Configuration alignment has been addressed. For app bounds, the CL
reverts the behavior back to identifying diffs as a screen size
change.

Fixes: 64004417
Test: bit FrameworksServicesTests:com.android.server.wm.AppBoundsTests
Test: go/wm-smoke

Change-Id: I1fabb564dfb5c13d897336708523cf7cd5099fa0

core/java/android/content/pm/ActivityInfo.java
core/java/android/content/res/Configuration.java
core/java/android/view/Display.java
core/java/android/view/Surface.java
services/core/java/com/android/server/am/ActivityRecord.java
services/core/java/com/android/server/wm/DisplayContent.java
services/tests/servicestests/src/com/android/server/wm/AppBoundsTests.java

index 16c834d..18f9e53 100644 (file)
@@ -763,26 +763,6 @@ public class ActivityInfo extends ComponentInfo
      * constant starts at the high bits.
      */
     public static final int CONFIG_FONT_SCALE = 0x40000000;
-    /**
-     * Bit in {@link #configChanges} that indicates that the activity
-     * can itself handle changes to the rotation.  Set from the
-     * {@link android.R.attr#configChanges} attribute.  This is
-     * not a core resource configuration, but a higher-level value, so its
-     * constant starts at the high bits.
-     * @hide We do not want apps to handle this. It will eventually be moved out of
-     * {@link Configuration}.
-     */
-    public static final int CONFIG_ROTATION = 0x20000000;
-    /**
-     * Bit in {@link #configChanges} that indicates that the activity
-     * can itself handle changes to the app bounds.  Set from the
-     * {@link android.R.attr#configChanges} attribute.  This is
-     * not a core resource configuration, but a higher-level value, so its
-     * constant starts at the high bits.
-     * @hide We do not want apps to handle this. It will eventually be moved out of
-     * {@link Configuration}.
-     */
-    public static final int CONFIG_APP_BOUNDS = 0x10000000;
 
     /** @hide
      * Unfortunately the constants for config changes in native code are
index 7b96c6a..af27131 100644 (file)
@@ -42,8 +42,6 @@ import java.lang.annotation.RetentionPolicy;
 import java.util.ArrayList;
 import java.util.Locale;
 
-import static android.view.Surface.ROTATION_0;
-import static android.view.Surface.ROTATION_UNDEFINED;
 
 /**
  * This class describes all device configuration information that can
@@ -600,13 +598,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
      */
     public int orientation;
 
-    /**
-     * The mRotation used at the time orientation was determined.
-     * TODO(b/36812336): Move mRotation out of {@link Configuration}.
-     * {@hide}
-     */
-    private int mRotation;
-
     /** Constant for {@link #uiMode}: bits that encode the mode type. */
     public static final int UI_MODE_TYPE_MASK = 0x0f;
     /** Constant for {@link #uiMode}: a {@link #UI_MODE_TYPE_MASK}
@@ -894,7 +885,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
         navigation = o.navigation;
         navigationHidden = o.navigationHidden;
         orientation = o.orientation;
-        mRotation = o.mRotation;
         screenLayout = o.screenLayout;
         colorMode = o.colorMode;
         uiMode = o.uiMode;
@@ -1085,7 +1075,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
         navigation = NAVIGATION_UNDEFINED;
         navigationHidden = NAVIGATIONHIDDEN_UNDEFINED;
         orientation = ORIENTATION_UNDEFINED;
-        mRotation = ROTATION_UNDEFINED;
         screenLayout = SCREENLAYOUT_UNDEFINED;
         colorMode = COLOR_MODE_UNDEFINED;
         uiMode = UI_MODE_TYPE_UNDEFINED;
@@ -1194,11 +1183,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
             changed |= ActivityInfo.CONFIG_ORIENTATION;
             orientation = delta.orientation;
         }
-        if (delta.mRotation != ROTATION_UNDEFINED
-                && mRotation != delta.mRotation) {
-            changed |= ActivityInfo.CONFIG_ORIENTATION;
-            mRotation = delta.mRotation;
-        }
 
         if (((delta.screenLayout & SCREENLAYOUT_SIZE_MASK) != SCREENLAYOUT_SIZE_UNDEFINED)
                 && (delta.screenLayout & SCREENLAYOUT_SIZE_MASK)
@@ -1393,10 +1377,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
                 && orientation != delta.orientation) {
             changed |= ActivityInfo.CONFIG_ORIENTATION;
         }
-        if ((compareUndefined || delta.mRotation != ROTATION_UNDEFINED)
-                && mRotation != delta.mRotation) {
-            changed |= ActivityInfo.CONFIG_ROTATION;
-        }
         if ((compareUndefined || getScreenLayoutNoDirection(delta.screenLayout) !=
                 (SCREENLAYOUT_SIZE_UNDEFINED | SCREENLAYOUT_LONG_UNDEFINED))
                 && getScreenLayoutNoDirection(screenLayout) !=
@@ -1445,7 +1425,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
         if ((compareUndefined || delta.appBounds != null)
                 && appBounds != delta.appBounds
                 && (appBounds == null || !appBounds.equals(delta.appBounds))) {
-            changed |= ActivityInfo.CONFIG_APP_BOUNDS;
+            changed |= ActivityInfo.CONFIG_SCREEN_SIZE;
         }
 
         return changed;
@@ -1533,7 +1513,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
         dest.writeInt(navigation);
         dest.writeInt(navigationHidden);
         dest.writeInt(orientation);
-        dest.writeInt(mRotation);
         dest.writeInt(screenLayout);
         dest.writeInt(colorMode);
         dest.writeInt(uiMode);
@@ -1570,7 +1549,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
         navigation = source.readInt();
         navigationHidden = source.readInt();
         orientation = source.readInt();
-        mRotation = source.readInt();
         screenLayout = source.readInt();
         colorMode = source.readInt();
         uiMode = source.readInt();
@@ -1655,8 +1633,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
         if (n != 0) return n;
         n = this.orientation - that.orientation;
         if (n != 0) return n;
-        n = this.mRotation - that.mRotation;
-        if (n != 0) return n;
         n = this.colorMode - that.colorMode;
         if (n != 0) return n;
         n = this.screenLayout - that.screenLayout;
@@ -1805,24 +1781,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
     /**
      * @hide
      *
-     * Setter for orientation converts from {@link Surface} values to internal representation.
-     */
-    public void setRotation(int rotation) {
-        this.mRotation = rotation;
-    }
-
-    /**
-     * @hide
-     *
-     * Getter for orientation. Converts from internal representation to  {@link Surface} values.
-     */
-    public int getRotation() {
-        return mRotation != ROTATION_UNDEFINED ? mRotation : ROTATION_0;
-    }
-
-    /**
-     * @hide
-     *
      * Clears the locale without changing layout direction.
      */
     public void clearLocales() {
@@ -2253,10 +2211,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
             delta.orientation = change.orientation;
         }
 
-        if (base.mRotation != change.mRotation) {
-            base.mRotation = change.mRotation;
-        }
-
         if ((base.screenLayout & SCREENLAYOUT_SIZE_MASK) !=
                 (change.screenLayout & SCREENLAYOUT_SIZE_MASK)) {
             delta.screenLayout |= change.screenLayout & SCREENLAYOUT_SIZE_MASK;
@@ -2388,8 +2342,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
                 DENSITY_DPI_UNDEFINED);
         configOut.appBounds =
             Rect.unflattenFromString(XmlUtils.readStringAttribute(parser, XML_ATTR_APP_BOUNDS));
-        configOut.mRotation = XmlUtils.readIntAttribute(parser, XML_ATTR_ROTATION,
-                ROTATION_UNDEFINED);
 
         // For persistence, we don't care about assetsSeq, so do not read it out.
     }
@@ -2466,10 +2418,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
                 config.appBounds.flattenToString());
         }
 
-        if (config.mRotation != ROTATION_UNDEFINED) {
-            XmlUtils.writeIntAttribute(xml, XML_ATTR_ROTATION, config.mRotation);
-        }
-
         // For persistence, we do not care about assetsSeq, so do not write it out.
     }
 }
index 263d3ff..9778893 100644 (file)
@@ -726,17 +726,6 @@ public final class Display {
     }
 
     /**
-     * Returns the rotation associated with this display as used during layout. This is currently
-     * derived from the {@link Configuration}.
-     *
-     * @hide
-     */
-    @Surface.Rotation
-    public int getLayoutRotation() {
-        return mResources.getConfiguration().getRotation();
-    }
-
-    /**
      * @deprecated use {@link #getRotation}
      * @return orientation of this display.
      */
index 1b70232..4f9dbd5 100644 (file)
@@ -131,17 +131,11 @@ public class Surface implements Parcelable {
     public static final int SCALING_MODE_NO_SCALE_CROP = 3;
 
     /** @hide */
-    @IntDef({ROTATION_UNDEFINED, ROTATION_0, ROTATION_90, ROTATION_180, ROTATION_270})
+    @IntDef({ROTATION_0, ROTATION_90, ROTATION_180, ROTATION_270})
     @Retention(RetentionPolicy.SOURCE)
     public @interface Rotation {}
 
     /**
-     * Rotation constant: undefined
-     * @hide
-     */
-    public static final int ROTATION_UNDEFINED = -1;
-
-    /**
      * Rotation constant: 0 degree rotation (natural orientation)
      */
     public static final int ROTATION_0 = 0;
index c09947c..66ec520 100644 (file)
@@ -41,9 +41,7 @@ import static android.content.Intent.CATEGORY_HOME;
 import static android.content.Intent.CATEGORY_LAUNCHER;
 import static android.content.Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS;
 import static android.content.Intent.FLAG_ACTIVITY_NO_HISTORY;
-import static android.content.pm.ActivityInfo.CONFIG_APP_BOUNDS;
 import static android.content.pm.ActivityInfo.CONFIG_ORIENTATION;
-import static android.content.pm.ActivityInfo.CONFIG_ROTATION;
 import static android.content.pm.ActivityInfo.CONFIG_SCREEN_LAYOUT;
 import static android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE;
 import static android.content.pm.ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE;
@@ -2598,15 +2596,6 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
                 changes &= ~CONFIG_SMALLEST_SCREEN_SIZE;
             }
         }
-        // We don't want rotation to cause relaunches.
-        if ((changes & CONFIG_ROTATION) != 0) {
-            changes &= ~CONFIG_ROTATION;
-        }
-
-        // We don't want app bound changes to cause relaunches.
-        if ((changes & CONFIG_APP_BOUNDS) != 0) {
-            changes &= ~CONFIG_APP_BOUNDS;
-        }
 
         return changes;
     }
index a37b2e5..55c0612 100644 (file)
@@ -1183,7 +1183,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
         final int dh = displayInfo.logicalHeight;
         config.orientation = (dw <= dh) ? Configuration.ORIENTATION_PORTRAIT :
                 Configuration.ORIENTATION_LANDSCAPE;
-        config.setRotation(displayInfo.rotation);
 
         config.screenWidthDp =
                 (int)(mService.mPolicy.getConfigDisplayWidth(dw, dh, displayInfo.rotation,
index f7ea0c4..6c95bd5 100644 (file)
@@ -57,9 +57,9 @@ public class AppBoundsTests extends WindowTestsBase {
         final Configuration config = new Configuration();
         final Configuration config2 = new Configuration();
         config.appBounds = new Rect(0, 1, 1, 0);
-        config2.appBounds = new Rect(0, 2, 2, 0);
+        config2.appBounds = new Rect(1, 2, 2, 1);
 
-        assertEquals(ActivityInfo.CONFIG_APP_BOUNDS, config.diff(config2));
+        assertEquals(ActivityInfo.CONFIG_SCREEN_SIZE, config.diff(config2));
     }
 
     /**