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

Commit 0b3f22b2 authored by Benjamin Franz's avatar Benjamin Franz Committed by Android (Google) Code Review
Browse files

Merge "Create per-app treatment for overriding minimum aspect ratio" into sc-dev

parents 8c3041d1 c4a55ff6
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -730,6 +730,11 @@ package android.content.pm {
    method public static boolean isTranslucentOrFloating(android.content.res.TypedArray);
    field public static final long FORCE_NON_RESIZE_APP = 181136395L; // 0xacbec0bL
    field public static final long FORCE_RESIZE_APP = 174042936L; // 0xa5faf38L
    field public static final long OVERRIDE_MIN_ASPECT_RATIO = 174042980L; // 0xa5faf64L
    field public static final long OVERRIDE_MIN_ASPECT_RATIO_LARGE = 180326787L; // 0xabf9183L
    field public static final float OVERRIDE_MIN_ASPECT_RATIO_LARGE_VALUE = 1.7777778f;
    field public static final long OVERRIDE_MIN_ASPECT_RATIO_MEDIUM = 180326845L; // 0xabf91bdL
    field public static final float OVERRIDE_MIN_ASPECT_RATIO_MEDIUM_VALUE = 1.5f;
    field public static final int RESIZE_MODE_RESIZEABLE = 2; // 0x2
  }

+1 −1
Original line number Diff line number Diff line
@@ -253,7 +253,7 @@ public class LaunchActivityItem extends ClientTransactionItem {
            return other == null;
        }
        return other != null && mInfo.flags == other.flags
                && mInfo.maxAspectRatio == other.maxAspectRatio
                && mInfo.getMaxAspectRatio() == other.getMaxAspectRatio()
                && Objects.equals(mInfo.launchToken, other.launchToken)
                && Objects.equals(mInfo.getComponentName(), other.getComponentName());
    }
+120 −13
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.annotation.TestApi;
import android.app.compat.CompatChanges;
import android.compat.annotation.ChangeId;
import android.compat.annotation.Disabled;
import android.compat.annotation.Overridable;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.ComponentName;
import android.content.Intent;
@@ -254,7 +255,7 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
     * @See {@link android.R.attr#maxAspectRatio}.
     * @hide
     */
    public float maxAspectRatio;
    private float mMaxAspectRatio;

    /**
     * Value indicating the minimum aspect ratio the activity supports.
@@ -263,7 +264,7 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
     * @See {@link android.R.attr#minAspectRatio}.
     * @hide
     */
    public float minAspectRatio;
    private float mMinAspectRatio;

    /**
     * Indicates that the activity works well with size changes like display changing size.
@@ -947,6 +948,57 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
    @Retention(RetentionPolicy.SOURCE)
    public @interface SizeChangesSupportMode {}

    /**
     * This change id is the gatekeeper for all treatments that force a given min aspect ratio.
     * Enabling this change will allow the following min aspect ratio treatments to be applied:
     * OVERRIDE_MIN_ASPECT_RATIO_MEDIUM
     * OVERRIDE_MIN_ASPECT_RATIO_LARGE
     *
     * If OVERRIDE_MIN_ASPECT_RATIO is applied, the min aspect ratio given in the app's
     * manifest will be overridden to the largest enabled aspect ratio treatment unless the app's
     * manifest value is higher.
     * @hide
     */
    @ChangeId
    @Overridable
    @Disabled
    @TestApi
    public static final long OVERRIDE_MIN_ASPECT_RATIO = 174042980L; // buganizer id

    /**
     * This change id sets the activity's min aspect ratio to a medium value as defined by
     * OVERRIDE_MIN_ASPECT_RATIO_MEDIUM_VALUE.
     *
     * This treatment only takes effect if OVERRIDE_MIN_ASPECT_RATIO is also enabled.
     * @hide
     */
    @ChangeId
    @Overridable
    @Disabled
    @TestApi
    public static final long OVERRIDE_MIN_ASPECT_RATIO_MEDIUM = 180326845L; // buganizer id

    /** @hide Medium override aspect ratio, currently 3:2.  */
    @TestApi
    public static final float OVERRIDE_MIN_ASPECT_RATIO_MEDIUM_VALUE = 3 / 2f;

    /**
     * This change id sets the activity's min aspect ratio to a large value as defined by
     * OVERRIDE_MIN_ASPECT_RATIO_LARGE_VALUE.
     *
     * This treatment only takes effect if OVERRIDE_MIN_ASPECT_RATIO is also enabled.
     * @hide
     */
    @ChangeId
    @Overridable
    @Disabled
    @TestApi
    public static final long OVERRIDE_MIN_ASPECT_RATIO_LARGE = 180326787L; // buganizer id

    /** @hide Large override aspect ratio, currently 16:9 */
    @TestApi
    public static final float OVERRIDE_MIN_ASPECT_RATIO_LARGE_VALUE = 16 / 9f;

    /**
     * Convert Java change bits to native.
     *
@@ -1118,8 +1170,8 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
        requestedVrComponent = orig.requestedVrComponent;
        rotationAnimation = orig.rotationAnimation;
        colorMode = orig.colorMode;
        maxAspectRatio = orig.maxAspectRatio;
        minAspectRatio = orig.minAspectRatio;
        mMaxAspectRatio = orig.mMaxAspectRatio;
        mMinAspectRatio = orig.mMinAspectRatio;
        supportsSizeChanges = orig.supportsSizeChanges;
        attributionTags = orig.attributionTags;
    }
@@ -1149,7 +1201,7 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
     * @hide
     */
    public boolean hasFixedAspectRatio() {
        return maxAspectRatio != 0 || minAspectRatio != 0;
        return getMaxAspectRatio() != 0 || getMinAspectRatio() != 0;
    }

    /**
@@ -1261,6 +1313,58 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
        return SIZE_CHANGES_UNSUPPORTED_METADATA;
    }

    /** @hide */
    public void setMaxAspectRatio(float maxAspectRatio) {
        this.mMaxAspectRatio = maxAspectRatio;
    }

    /** @hide */
    public float getMaxAspectRatio() {
        return mMaxAspectRatio;
    }

    /** @hide */
    public void setMinAspectRatio(float minAspectRatio) {
        this.mMinAspectRatio = minAspectRatio;
    }

    /**
     * Returns the min aspect ratio of this activity.
     *
     * This takes into account the minimum aspect ratio as defined in the app's manifest and
     * possible overrides as per OVERRIDE_MIN_ASPECT_RATIO.
     *
     * In the rare cases where the manifest minimum aspect ratio is required, use
     * {@code getManifestMinAspectRatio}.
     * @hide
     */
    public float getMinAspectRatio() {
        if (applicationInfo == null || !CompatChanges.isChangeEnabled(OVERRIDE_MIN_ASPECT_RATIO,
                applicationInfo.packageName,
                UserHandle.getUserHandleForUid(applicationInfo.uid))) {
            return mMinAspectRatio;
        }

        if (CompatChanges.isChangeEnabled(OVERRIDE_MIN_ASPECT_RATIO_LARGE,
                applicationInfo.packageName,
                UserHandle.getUserHandleForUid(applicationInfo.uid))) {
            return Math.max(OVERRIDE_MIN_ASPECT_RATIO_LARGE_VALUE, mMinAspectRatio);
        }

        if (CompatChanges.isChangeEnabled(OVERRIDE_MIN_ASPECT_RATIO_MEDIUM,
                applicationInfo.packageName,
                UserHandle.getUserHandleForUid(applicationInfo.uid))) {
            return Math.max(OVERRIDE_MIN_ASPECT_RATIO_MEDIUM_VALUE, mMinAspectRatio);
        }

        return mMinAspectRatio;
    }

    /** @hide */
    public float getManifestMinAspectRatio() {
        return mMinAspectRatio;
    }

    /** @hide */
    @UnsupportedAppUsage
    public static boolean isResizeableMode(int mode) {
@@ -1360,11 +1464,14 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
        if (requestedVrComponent != null) {
            pw.println(prefix + "requestedVrComponent=" + requestedVrComponent);
        }
        if (maxAspectRatio != 0) {
            pw.println(prefix + "maxAspectRatio=" + maxAspectRatio);
        if (getMaxAspectRatio() != 0) {
            pw.println(prefix + "maxAspectRatio=" + getMaxAspectRatio());
        }
        if (getMinAspectRatio() != 0) {
            pw.println(prefix + "minAspectRatio=" + getMinAspectRatio());
            if (getManifestMinAspectRatio() !=  getMinAspectRatio()) {
                pw.println(prefix + "getManifestMinAspectRatio=" + getManifestMinAspectRatio());
            }
        if (minAspectRatio != 0) {
            pw.println(prefix + "minAspectRatio=" + minAspectRatio);
        }
        if (supportsSizeChanges) {
            pw.println(prefix + "supportsSizeChanges=true");
@@ -1420,8 +1527,8 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
        dest.writeString8(requestedVrComponent);
        dest.writeInt(rotationAnimation);
        dest.writeInt(colorMode);
        dest.writeFloat(maxAspectRatio);
        dest.writeFloat(minAspectRatio);
        dest.writeFloat(mMaxAspectRatio);
        dest.writeFloat(mMinAspectRatio);
        dest.writeBoolean(supportsSizeChanges);
        dest.writeString8Array(attributionTags);
    }
@@ -1540,8 +1647,8 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
        requestedVrComponent = source.readString8();
        rotationAnimation = source.readInt();
        colorMode = source.readInt();
        maxAspectRatio = source.readFloat();
        minAspectRatio = source.readFloat();
        mMaxAspectRatio = source.readFloat();
        mMinAspectRatio = source.readFloat();
        supportsSizeChanges = source.readBoolean();
        attributionTags = source.createString8Array();
    }
+4 −4
Original line number Diff line number Diff line
@@ -4890,8 +4890,8 @@ public class PackageParser {
        info.maxRecents = target.info.maxRecents;
        info.windowLayout = target.info.windowLayout;
        info.resizeMode = target.info.resizeMode;
        info.maxAspectRatio = target.info.maxAspectRatio;
        info.minAspectRatio = target.info.minAspectRatio;
        info.setMaxAspectRatio(target.info.getMaxAspectRatio());
        info.setMinAspectRatio(target.info.getManifestMinAspectRatio());
        info.supportsSizeChanges = target.info.supportsSizeChanges;
        info.requestedVrComponent = target.info.requestedVrComponent;

@@ -8157,7 +8157,7 @@ public class PackageParser {
                return;
            }

            info.maxAspectRatio = maxAspectRatio;
            info.setMaxAspectRatio(maxAspectRatio);
            mHasMaxAspectRatio = true;
        }

@@ -8173,7 +8173,7 @@ public class PackageParser {
                return;
            }

            info.minAspectRatio = minAspectRatio;
            info.setMinAspectRatio(minAspectRatio);
            mHasMinAspectRatio = true;
        }

+2 −2
Original line number Diff line number Diff line
@@ -474,9 +474,9 @@ public class PackageInfoWithoutStateUtils {
        ai.screenOrientation = a.getScreenOrientation();
        ai.resizeMode = a.getResizeMode();
        Float maxAspectRatio = a.getMaxAspectRatio();
        ai.maxAspectRatio = maxAspectRatio != null ? maxAspectRatio : 0f;
        ai.setMaxAspectRatio(maxAspectRatio != null ? maxAspectRatio : 0f);
        Float minAspectRatio = a.getMinAspectRatio();
        ai.minAspectRatio = minAspectRatio != null ? minAspectRatio : 0f;
        ai.setMinAspectRatio(minAspectRatio != null ? minAspectRatio : 0f);
        ai.supportsSizeChanges = a.getSupportsSizeChanges();
        ai.requestedVrComponent = a.getRequestedVrComponent();
        ai.rotationAnimation = a.getRotationAnimation();
Loading