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

Commit 2ee6b1ec authored by Graciela Putri's avatar Graciela Putri Committed by Automerger Merge Worker
Browse files

Merge "[1/n] Add userMinAspectRatio to packageUserState" into udc-qpr-dev am:...

Merge "[1/n] Add userMinAspectRatio to packageUserState" into udc-qpr-dev am: 04a2e09f am: 3004afee

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23745935



Change-Id: Iad0342b329673126a47640c71c2df7db034be3dd
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents bdd1ce98 3004afee
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -795,6 +795,11 @@ interface IPackageManager {

    void setSplashScreenTheme(String packageName, String themeName, int userId);

    int getUserMinAspectRatio(String packageName, int userId);

    @EnforcePermission("INSTALL_PACKAGES")
    void setUserMinAspectRatio(String packageName, int userId, int aspectRatio);

    List<String> getMimeGroup(String packageName, String group);

    boolean isAutoRevokeWhitelisted(String packageName);
+58 −0
Original line number Diff line number Diff line
@@ -2351,6 +2351,64 @@ public abstract class PackageManager {
     */
    public static final int INSTALL_FAILED_SHARED_LIBRARY_BAD_CERTIFICATE_DIGEST = -130;

    /**
     * App minimum aspect ratio set by the user which will override app-defined aspect ratio.
     *
     * @hide
     */
    @IntDef(prefix = { "USER_MIN_ASPECT_RATIO_" }, value = {
            USER_MIN_ASPECT_RATIO_UNSET,
            USER_MIN_ASPECT_RATIO_SPLIT_SCREEN,
            USER_MIN_ASPECT_RATIO_DISPLAY_SIZE,
            USER_MIN_ASPECT_RATIO_4_3,
            USER_MIN_ASPECT_RATIO_16_9,
            USER_MIN_ASPECT_RATIO_3_2,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface UserMinAspectRatio {}

    /**
     * No aspect ratio override has been set by user.
     *
     * @hide
     */
    public static final int USER_MIN_ASPECT_RATIO_UNSET = 0;

    /**
     * Aspect ratio override code: user forces app to split screen aspect ratio. This is adjusted to
     * half of the screen without the split screen divider.
     *
     * @hide
     */
    public static final int USER_MIN_ASPECT_RATIO_SPLIT_SCREEN = 1;

    /**
     * Aspect ratio override code: user forces app to the aspect ratio of the device display size.
     * This will be the portrait aspect ratio of the device if the app is portrait or the landscape
     * aspect ratio of the device if the app is landscape.
     *
     * @hide
     */
    public static final int USER_MIN_ASPECT_RATIO_DISPLAY_SIZE = 2;

    /**
     * Aspect ratio override code: user forces app to 4:3 min aspect ratio
     * @hide
     */
    public static final int USER_MIN_ASPECT_RATIO_4_3 = 3;

    /**
     * Aspect ratio override code: user forces app to 16:9 min aspect ratio
     * @hide
     */
    public static final int USER_MIN_ASPECT_RATIO_16_9 = 4;

    /**
     * Aspect ratio override code: user forces app to 3:2 min aspect ratio
     * @hide
     */
    public static final int USER_MIN_ASPECT_RATIO_3_2 = 5;

    /** @hide */
    @IntDef(flag = true, prefix = { "DELETE_" }, value = {
            DELETE_KEEP_DATA,
+2 −1
Original line number Diff line number Diff line
@@ -632,7 +632,8 @@ final class DeletePackageHelper {
                    PackageManager.UNINSTALL_REASON_UNKNOWN,
                    null /*harmfulAppWarning*/,
                    null /*splashScreenTheme*/,
                    0 /*firstInstallTime*/);
                    0 /*firstInstallTime*/,
                    PackageManager.USER_MIN_ASPECT_RATIO_UNSET);
        }
        mPm.mSettings.writeKernelMappingLPr(ps);
    }
+41 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import static android.content.pm.PackageManager.MATCH_DISABLED_COMPONENTS;
import static android.content.pm.PackageManager.MATCH_FACTORY_ONLY;
import static android.content.pm.PackageManager.MATCH_SYSTEM_ONLY;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_UNSET;
import static android.os.Process.INVALID_UID;
import static android.os.Trace.TRACE_TAG_PACKAGE_MANAGER;
import static android.os.storage.StorageManager.FLAG_STORAGE_CE;
@@ -5128,6 +5129,20 @@ public class PackageManagerService implements PackageSender, TestUtilityService
                    : packageState.getUserStateOrDefault(userId).getSplashScreenTheme();
        }

        @Override
        @PackageManager.UserMinAspectRatio
        public int getUserMinAspectRatio(@NonNull String packageName, int userId) {
            final Computer snapshot = snapshotComputer();
            final int callingUid = Binder.getCallingUid();
            snapshot.enforceCrossUserPermission(
                    callingUid, userId, false /* requireFullPermission */,
                    false /* checkShell */, "getUserMinAspectRatio");
            final PackageStateInternal packageState = snapshot
                    .getPackageStateForInstalledAndFiltered(packageName, callingUid, userId);
            return packageState == null ? USER_MIN_ASPECT_RATIO_UNSET
                    : packageState.getUserStateOrDefault(userId).getMinAspectRatio();
        }

        @Override
        public Bundle getSuspendedPackageAppExtras(String packageName, int userId) {
            final int callingUid = Binder.getCallingUid();
@@ -6093,6 +6108,32 @@ public class PackageManagerService implements PackageSender, TestUtilityService
            return true;
        }

        @android.annotation.EnforcePermission(android.Manifest.permission.INSTALL_PACKAGES)
        @Override
        public void setUserMinAspectRatio(@NonNull String packageName, int userId,
                @PackageManager.UserMinAspectRatio int aspectRatio) {
            setUserMinAspectRatio_enforcePermission();
            final int callingUid = Binder.getCallingUid();
            final Computer snapshot = snapshotComputer();
            snapshot.enforceCrossUserPermission(callingUid, userId,
                    false /* requireFullPermission */, false /* checkShell */,
                    "setUserMinAspectRatio");
            enforceOwnerRights(snapshot, packageName, callingUid);

            final PackageStateInternal packageState = snapshot
                    .getPackageStateForInstalledAndFiltered(packageName, callingUid, userId);
            if (packageState == null) {
                return;
            }

            if (packageState.getUserStateOrDefault(userId).getMinAspectRatio() == aspectRatio) {
                return;
            }

            commitPackageStateMutation(null, packageName, state ->
                    state.userState(userId).setMinAspectRatio(aspectRatio));
        }

        @Override
        @SuppressWarnings("GuardedBy")
        public void setRuntimePermissionsVersion(int version, @UserIdInt int userId) {
+4 −3
Original line number Diff line number Diff line
@@ -875,7 +875,7 @@ public class PackageSetting extends SettingBase implements PackageStateInternal
            ArraySet<String> enabledComponents, ArraySet<String> disabledComponents,
            int installReason, int uninstallReason,
            String harmfulAppWarning, String splashScreenTheme,
            long firstInstallTime) {
            long firstInstallTime, int aspectRatio) {
        modifyUserState(userId)
                .setSuspendParams(suspendParams)
                .setCeDataInode(ceDataInode)
@@ -894,7 +894,8 @@ public class PackageSetting extends SettingBase implements PackageStateInternal
                .setVirtualPreload(virtualPreload)
                .setHarmfulAppWarning(harmfulAppWarning)
                .setSplashScreenTheme(splashScreenTheme)
                .setFirstInstallTimeMillis(firstInstallTime);
                .setFirstInstallTimeMillis(firstInstallTime)
                .setMinAspectRatio(aspectRatio);
        onChanged();
    }

@@ -912,7 +913,7 @@ public class PackageSetting extends SettingBase implements PackageStateInternal
                        ? null : otherState.getDisabledComponentsNoCopy().untrackedStorage(),
                otherState.getInstallReason(), otherState.getUninstallReason(),
                otherState.getHarmfulAppWarning(), otherState.getSplashScreenTheme(),
                otherState.getFirstInstallTimeMillis());
                otherState.getFirstInstallTimeMillis(), otherState.getMinAspectRatio());
    }

    WatchedArraySet<String> getEnabledComponents(int userId) {
Loading