Merge "Allow app to specify the rollback data policy in the manifest (1/n)"
This commit is contained in:
@@ -1165,6 +1165,7 @@ package android {
|
||||
field public static final int right = 16843183; // 0x10101af
|
||||
field public static final int ringtonePreferenceStyle = 16842899; // 0x1010093
|
||||
field public static final int ringtoneType = 16843257; // 0x10101f9
|
||||
field public static final int rollbackDataPolicy = 16844314; // 0x101061a
|
||||
field public static final int rotation = 16843558; // 0x1010326
|
||||
field public static final int rotationAnimation = 16844090; // 0x101053a
|
||||
field public static final int rotationX = 16843559; // 0x1010327
|
||||
|
||||
@@ -473,6 +473,7 @@ public class PackageParser {
|
||||
public final String targetPackageName;
|
||||
public final boolean overlayIsStatic;
|
||||
public final int overlayPriority;
|
||||
public final int rollbackDataPolicy;
|
||||
|
||||
public ApkLite(String codePath, String packageName, String splitName,
|
||||
boolean isFeatureSplit,
|
||||
@@ -483,7 +484,7 @@ public class PackageParser {
|
||||
boolean debuggable, boolean multiArch, boolean use32bitAbi,
|
||||
boolean useEmbeddedDex, boolean extractNativeLibs, boolean isolatedSplits,
|
||||
String targetPackageName, boolean overlayIsStatic, int overlayPriority,
|
||||
int minSdkVersion, int targetSdkVersion) {
|
||||
int minSdkVersion, int targetSdkVersion, int rollbackDataPolicy) {
|
||||
this.codePath = codePath;
|
||||
this.packageName = packageName;
|
||||
this.splitName = splitName;
|
||||
@@ -509,6 +510,7 @@ public class PackageParser {
|
||||
this.overlayPriority = overlayPriority;
|
||||
this.minSdkVersion = minSdkVersion;
|
||||
this.targetSdkVersion = targetSdkVersion;
|
||||
this.rollbackDataPolicy = rollbackDataPolicy;
|
||||
}
|
||||
|
||||
public long getLongVersionCode() {
|
||||
@@ -1586,6 +1588,7 @@ public class PackageParser {
|
||||
String targetPackage = null;
|
||||
boolean overlayIsStatic = false;
|
||||
int overlayPriority = 0;
|
||||
int rollbackDataPolicy = 0;
|
||||
|
||||
String requiredSystemPropertyName = null;
|
||||
String requiredSystemPropertyValue = null;
|
||||
@@ -1652,6 +1655,9 @@ public class PackageParser {
|
||||
if ("useEmbeddedDex".equals(attr)) {
|
||||
useEmbeddedDex = attrs.getAttributeBooleanValue(i, false);
|
||||
}
|
||||
if (attr.equals("rollbackDataPolicy")) {
|
||||
rollbackDataPolicy = attrs.getAttributeIntValue(i, 0);
|
||||
}
|
||||
}
|
||||
} else if (PackageParser.TAG_OVERLAY.equals(parser.getName())) {
|
||||
for (int i = 0; i < attrs.getAttributeCount(); ++i) {
|
||||
@@ -1709,7 +1715,8 @@ public class PackageParser {
|
||||
configForSplit, usesSplitName, isSplitRequired, versionCode, versionCodeMajor,
|
||||
revisionCode, installLocation, verifiers, signingDetails, coreApp, debuggable,
|
||||
multiArch, use32bitAbi, useEmbeddedDex, extractNativeLibs, isolatedSplits,
|
||||
targetPackage, overlayIsStatic, overlayPriority, minSdkVersion, targetSdkVersion);
|
||||
targetPackage, overlayIsStatic, overlayPriority, minSdkVersion, targetSdkVersion,
|
||||
rollbackDataPolicy);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -292,6 +292,7 @@ public class ApkLiteParseUtils {
|
||||
String targetPackage = null;
|
||||
boolean overlayIsStatic = false;
|
||||
int overlayPriority = 0;
|
||||
int rollbackDataPolicy = 0;
|
||||
|
||||
String requiredSystemPropertyName = null;
|
||||
String requiredSystemPropertyValue = null;
|
||||
@@ -369,6 +370,9 @@ public class ApkLiteParseUtils {
|
||||
case "useEmbeddedDex":
|
||||
useEmbeddedDex = attrs.getAttributeBooleanValue(i, false);
|
||||
break;
|
||||
case "rollbackDataPolicy":
|
||||
rollbackDataPolicy = attrs.getAttributeIntValue(i, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (PackageParser.TAG_OVERLAY.equals(parser.getName())) {
|
||||
@@ -428,7 +432,7 @@ public class ApkLiteParseUtils {
|
||||
versionCodeMajor, revisionCode, installLocation, verifiers, signingDetails,
|
||||
coreApp, debuggable, multiArch, use32bitAbi, useEmbeddedDex, extractNativeLibs,
|
||||
isolatedSplits, targetPackage, overlayIsStatic, overlayPriority, minSdkVersion,
|
||||
targetSdkVersion);
|
||||
targetSdkVersion, rollbackDataPolicy);
|
||||
}
|
||||
|
||||
public static VerifierInfo parseVerifier(AttributeSet attrs) {
|
||||
|
||||
@@ -1835,6 +1835,16 @@
|
||||
<enum name="discouraged" value="1" />
|
||||
<enum name="disallowed" value="2" />
|
||||
</attr>
|
||||
|
||||
<!-- Declare the policy to deal with user data when rollback is committed. -->
|
||||
<attr name="rollbackDataPolicy">
|
||||
<!-- User data will be restored during rollback. -->
|
||||
<enum name="restore" value="0" />
|
||||
<!-- User data will be wiped out during rollback. -->
|
||||
<enum name="wipe" value="1" />
|
||||
<!-- User data will remain unchanged during rollback. -->
|
||||
<enum name="retain" value="2" />
|
||||
</attr>
|
||||
</declare-styleable>
|
||||
|
||||
<!-- An attribution is a logical part of an app and is identified by a tag.
|
||||
|
||||
@@ -3022,6 +3022,7 @@
|
||||
<public name="gwpAsanMode" />
|
||||
<!-- @hide -->
|
||||
<public name="scrollCaptureHint" />
|
||||
<public name="rollbackDataPolicy" />
|
||||
</public-group>
|
||||
|
||||
<public-group type="drawable" first-id="0x010800b5">
|
||||
|
||||
@@ -37,6 +37,7 @@ import android.content.pm.PackageParser;
|
||||
import android.content.pm.ParceledListSlice;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.content.pm.VersionedPackage;
|
||||
import android.content.pm.parsing.ApkLiteParseUtils;
|
||||
import android.content.rollback.IRollbackManager;
|
||||
import android.content.rollback.RollbackInfo;
|
||||
import android.content.rollback.RollbackManager;
|
||||
@@ -835,9 +836,9 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
|
||||
}
|
||||
|
||||
// Get information about the package to be installed.
|
||||
PackageParser.PackageLite newPackage;
|
||||
PackageParser.ApkLite newPackage;
|
||||
try {
|
||||
newPackage = PackageParser.parsePackageLite(new File(session.resolvedBaseCodePath), 0);
|
||||
newPackage = ApkLiteParseUtils.parseApkLite(new File(session.resolvedBaseCodePath), 0);
|
||||
} catch (PackageParser.PackageParserException e) {
|
||||
Slog.e(TAG, "Unable to parse new package", e);
|
||||
return false;
|
||||
@@ -845,7 +846,8 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
|
||||
|
||||
String packageName = newPackage.packageName;
|
||||
Slog.i(TAG, "Enabling rollback for install of " + packageName
|
||||
+ ", session:" + session.sessionId);
|
||||
+ ", session:" + session.sessionId
|
||||
+ ", rollbackDataPolicy=" + newPackage.rollbackDataPolicy);
|
||||
|
||||
String installerPackageName = session.getInstallerPackageName();
|
||||
if (!enableRollbackAllowed(installerPackageName, packageName)) {
|
||||
|
||||
Reference in New Issue
Block a user