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

Commit 75674858 authored by Ruslan Tkhakokhov's avatar Ruslan Tkhakokhov
Browse files

Add manifest flag to clear user data at restore

Currently there are 2 functionalities guarded by the same flag
(FLAG_ALLOW_CLEAR_USER_DATA):

1. Allowing users to clear the app's data from settings
2. Allowing the system to clear the app's data if a restore operation
fails.

The purpose of this CL is to introduce a new flag
(FLAG_ALLOW_CLEAR_USER_DATA_ON_FAILED_RESTORE) for (2)

Bug: 120267643
Test: N/A
Change-Id: I4ee315e311049c55ed26e7cf121f7e0c59eabd55
parent 9b5f31b8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -205,6 +205,7 @@ package android {
  }
  public static final class R.attr {
    field public static final int allowClearUserDataOnFailedRestore = 16844198; // 0x10105a6
    field public static final int inheritShowWhenLocked = 16844194; // 0x10105a2
    field public static final int isVrOnly = 16844152; // 0x1010578
    field public static final int requiredSystemPropertyName = 16844133; // 0x1010565
+13 −0
Original line number Diff line number Diff line
@@ -650,6 +650,18 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     */
    public static final int PRIVATE_FLAG_USE_EMBEDDED_DEX = 1 << 25;

    /**
     * Value for {@link #privateFlags}: indicates whether this application's data will be cleared
     * on a failed restore.
     *
     * <p>Comes from the
     * android.R.styleable#AndroidManifestApplication_allowClearUserDataOnFailedRestore attribute
     * of the &lt;application&gt; tag.
     *
     * @hide
     */
    public static final int PRIVATE_FLAG_ALLOW_CLEAR_USER_DATA_ON_FAILED_RESTORE = 1 << 26;

    /** @hide */
    @IntDef(flag = true, prefix = { "PRIVATE_FLAG_" }, value = {
            PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE,
@@ -676,6 +688,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
            PRIVATE_FLAG_VENDOR,
            PRIVATE_FLAG_VIRTUAL_PRELOAD,
            PRIVATE_FLAG_HAS_FRAGILE_USER_DATA,
            PRIVATE_FLAG_ALLOW_CLEAR_USER_DATA_ON_FAILED_RESTORE
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface ApplicationInfoPrivateFlags {}
+7 −0
Original line number Diff line number Diff line
@@ -3747,6 +3747,13 @@ public class PackageParser {
            ai.privateFlags |= PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION;
        }

        if (sa.getBoolean(
                com.android.internal.R.styleable
                        .AndroidManifestApplication_allowClearUserDataOnFailedRestore,
                true)) {
            ai.privateFlags |= ApplicationInfo.PRIVATE_FLAG_ALLOW_CLEAR_USER_DATA_ON_FAILED_RESTORE;
        }

        ai.maxAspectRatio = sa.getFloat(R.styleable.AndroidManifestApplication_maxAspectRatio, 0);
        ai.minAspectRatio = sa.getFloat(R.styleable.AndroidManifestApplication_minAspectRatio, 0);

+7 −2
Original line number Diff line number Diff line
@@ -118,7 +118,7 @@
    <attr name="manageSpaceActivity" format="string" />

    <!-- Option to let applications specify that user data can/cannot be
         cleared. This flag is turned on by default.
         cleared by the user in Settings. This flag is turned on by default.
         <em>This attribute is usable only by applications
         included in the system image. Third-party apps cannot use it.</em> -->
    <attr name="allowClearUserData" format="boolean" />
@@ -1662,6 +1662,11 @@
        <attr name="hasFragileUserData" />

        <attr name="zygotePreloadName" />

        <!-- If {@code true} the system will clear app's data if a restore operation fails.
             This flag is turned on by default. <em>This attribute is usable only by system apps.
             </em> -->
        <attr name="allowClearUserDataOnFailedRestore"/>
    </declare-styleable>
    <!-- The <code>permission</code> tag declares a security permission that can be
         used to control access from other packages to specific components or
+2 −0
Original line number Diff line number Diff line
@@ -2939,6 +2939,8 @@
        <public name="zygotePreloadName" />
        <public name="useEmbeddedDex" />
        <public name="forceUriPermissions" />
        <!-- @hide @SystemApi -->
        <public name="allowClearUserDataOnFailedRestore"/>
    </public-group>

    <public-group type="drawable" first-id="0x010800b4">