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

Commit 20ebc021 authored by Rhed Jao's avatar Rhed Jao
Browse files

Reset component enabled settings when clearing app data

Introduces a new attriubte named resetEnabledSettingsOnAppDataCleared
for the components in the manifest such as activity, receiver,
provider and service. If the value is true, the enabled settings of
components in the application will be reset to the default value when
the application's user data is cleared.

Bug: 148803217
Test: atest PackageManagerTest
Test: atest AndroidPackageTest
Change-Id: Id10ae9768835b20619122a6435442fbdaefb9318
parent 8181f28f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1204,6 +1204,7 @@ package android {
    field public static final int requiredSplitTypes;
    field public static final int requiresFadingEdge = 16843685; // 0x10103a5
    field public static final int requiresSmallestWidthDp = 16843620; // 0x1010364
    field public static final int resetEnabledSettingsOnAppDataCleared;
    field public static final int resizeClip = 16843983; // 0x10104cf
    field public static final int resizeMode = 16843619; // 0x1010363
    field public static final int resizeable = 16843405; // 0x101028d
+3 −0
Original line number Diff line number Diff line
@@ -362,6 +362,9 @@ public interface ParsingPackage extends ParsingPackageRead {

    ParsingPackage setAttributionsAreUserVisible(boolean attributionsAreUserVisible);

    ParsingPackage setResetEnabledSettingsOnAppDataCleared(
            boolean resetEnabledSettingsOnAppDataCleared);

    // TODO(b/135203078): This class no longer has access to ParsedPackage, find a replacement
    //  for moving to the next step
    @CallSuper
+14 −0
Original line number Diff line number Diff line
@@ -517,6 +517,7 @@ public class ParsingPackageImpl implements ParsingPackage, ParsingPackageHidden,
        private static final long DISALLOW_PROFILING = 1L << 45;
        private static final long REQUEST_FOREGROUND_SERVICE_EXEMPTION = 1L << 46;
        private static final long ATTRIBUTIONS_ARE_USER_VISIBLE = 1L << 47;
        private static final long RESET_ENABLED_SETTINGS_ON_APP_DATA_CLEARED = 1L << 48;
    }

    private ParsingPackageImpl setBoolean(@Booleans.Values long flag, boolean value) {
@@ -2215,6 +2216,11 @@ public class ParsingPackageImpl implements ParsingPackage, ParsingPackageHidden,
        return getBoolean(Booleans.ATTRIBUTIONS_ARE_USER_VISIBLE);
    }

    @Override
    public boolean isResetEnabledSettingsOnAppDataCleared() {
        return getBoolean(Booleans.RESET_ENABLED_SETTINGS_ON_APP_DATA_CLEARED);
    }

    @Override
    public ParsingPackageImpl setBaseRevisionCode(int value) {
        baseRevisionCode = value;
@@ -2771,4 +2777,12 @@ public class ParsingPackageImpl implements ParsingPackage, ParsingPackageHidden,
        setBoolean(Booleans.ATTRIBUTIONS_ARE_USER_VISIBLE, attributionsAreUserVisible);
        return this;
    }

    @Override
    public ParsingPackage setResetEnabledSettingsOnAppDataCleared(
            boolean resetEnabledSettingsOnAppDataCleared) {
        setBoolean(Booleans.RESET_ENABLED_SETTINGS_ON_APP_DATA_CLEARED,
                resetEnabledSettingsOnAppDataCleared);
        return this;
    }
}
+8 −0
Original line number Diff line number Diff line
@@ -297,4 +297,12 @@ public interface ParsingPackageRead extends PkgWithoutStateAppInfo, PkgWithoutSt
     * @see R.styleable#AndroidManifestService_visibleToInstantApps
     */
    boolean isVisibleToInstantApps();

    /**
     * Whether the enabled settings of components in the application should be reset to the default,
     * when the application's user data is cleared.
     *
     * @see R.styleable#AndroidManifestApplication_resetEnabledSettingsOnAppDataCleared
     */
    boolean isResetEnabledSettingsOnAppDataCleared();
}
+3 −0
Original line number Diff line number Diff line
@@ -2288,6 +2288,9 @@ public class ParsingPackageUtils {
                .setVmSafeMode(bool(false, R.styleable.AndroidManifestApplication_vmSafeMode, sa))
                .setAutoRevokePermissions(anInt(R.styleable.AndroidManifestApplication_autoRevokePermissions, sa))
                .setAttributionsAreUserVisible(bool(false, R.styleable.AndroidManifestApplication_attributionsAreUserVisible, sa))
                .setResetEnabledSettingsOnAppDataCleared(bool(false,
                    R.styleable.AndroidManifestApplication_resetEnabledSettingsOnAppDataCleared,
                    sa))
                // targetSdkVersion gated
                .setAllowAudioPlaybackCapture(bool(targetSdk >= Build.VERSION_CODES.Q, R.styleable.AndroidManifestApplication_allowAudioPlaybackCapture, sa))
                .setBaseHardwareAccelerated(bool(targetSdk >= Build.VERSION_CODES.ICE_CREAM_SANDWICH, R.styleable.AndroidManifestApplication_hardwareAccelerated, sa))
Loading