Merge "Add manifest flag to clear user data at restore"

This commit is contained in:
Ruslan Tkhakokhov
2019-02-11 20:36:04 +00:00
committed by Android (Google) Code Review
5 changed files with 30 additions and 2 deletions

View File

@@ -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

View File

@@ -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 {}

View File

@@ -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);

View File

@@ -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" />
@@ -1661,7 +1661,12 @@
<!-- If {@code true} the user is prompted to keep the app's data on uninstall -->
<attr name="hasFragileUserData" />
<attr name="zygotePreloadName" />
<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

View File

@@ -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">