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

Commit 0e4a6dfb authored by Bryce Lee's avatar Bryce Lee
Browse files

Remove rotation and app bounds from Configuration diff.

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
parent f2c8a24f
Loading
Loading
Loading
Loading
+0 −20
Original line number Diff line number Diff line
@@ -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
+1 −53
Original line number Diff line number Diff line
@@ -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;
@@ -1802,24 +1778,6 @@ public final class Configuration implements Parcelable, Comparable<Configuration
        appBounds.set(left, top, right, bottom);
    }

    /**
     * @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
     *
@@ -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.
    }
}
+0 −11
Original line number Diff line number Diff line
@@ -725,17 +725,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.
+1 −7
Original line number Diff line number Diff line
@@ -131,16 +131,10 @@ 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)
     */
+0 −11
Original line number Diff line number Diff line
@@ -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;
    }
Loading