summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorAdam Bookatz <bookatz@google.com>2020-03-30 18:09:25 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-03-30 18:09:25 +0000
commit9968525afbf0e87c18ebb38cb1ee21abddd136ad (patch)
tree35d4e4cb9a4c11c12e5f40a7356291a5c1f668af /core/java
parent7f212788d1fb42f4ef970f169a672e519abae351 (diff)
parent1efd27cde359a1ff71d88519dbbdc2f7f1f1d1a4 (diff)
Merge "UserSystemPackageInstaller only (un)installs when appropriate" into rvc-dev
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/content/pm/PackageManager.java21
-rw-r--r--core/java/android/content/pm/PackageUserState.java7
2 files changed, 28 insertions, 0 deletions
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 370469ebe840..f48d78ac9cc3 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -1031,6 +1031,27 @@ public abstract class PackageManager {
*/
public static final int INSTALL_REASON_ROLLBACK = 5;
+ /** @hide */
+ @IntDef(prefix = { "UNINSTALL_REASON_" }, value = {
+ UNINSTALL_REASON_UNKNOWN,
+ UNINSTALL_REASON_USER_TYPE,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface UninstallReason {}
+
+ /**
+ * Code indicating that the reason for uninstalling this package is unknown.
+ * @hide
+ */
+ public static final int UNINSTALL_REASON_UNKNOWN = 0;
+
+ /**
+ * Code indicating that this package was uninstalled due to the type of user.
+ * See UserSystemPackageInstaller
+ * @hide
+ */
+ public static final int UNINSTALL_REASON_USER_TYPE = 1;
+
/**
* @hide
*/
diff --git a/core/java/android/content/pm/PackageUserState.java b/core/java/android/content/pm/PackageUserState.java
index 30cf4e76ba04..61b1553e28a8 100644
--- a/core/java/android/content/pm/PackageUserState.java
+++ b/core/java/android/content/pm/PackageUserState.java
@@ -74,6 +74,7 @@ public class PackageUserState {
public int appLinkGeneration;
public int categoryHint = ApplicationInfo.CATEGORY_UNDEFINED;
public int installReason;
+ public @PackageManager.UninstallReason int uninstallReason;
public String harmfulAppWarning;
public ArraySet<String> disabledComponents;
@@ -92,6 +93,7 @@ public class PackageUserState {
domainVerificationStatus =
PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED;
installReason = PackageManager.INSTALL_REASON_UNKNOWN;
+ uninstallReason = PackageManager.UNINSTALL_REASON_UNKNOWN;
}
@VisibleForTesting
@@ -112,6 +114,7 @@ public class PackageUserState {
appLinkGeneration = o.appLinkGeneration;
categoryHint = o.categoryHint;
installReason = o.installReason;
+ uninstallReason = o.uninstallReason;
disabledComponents = ArrayUtils.cloneOrNull(o.disabledComponents);
enabledComponents = ArrayUtils.cloneOrNull(o.enabledComponents);
overlayPaths =
@@ -353,6 +356,9 @@ public class PackageUserState {
if (installReason != oldState.installReason) {
return false;
}
+ if (uninstallReason != oldState.uninstallReason) {
+ return false;
+ }
if ((disabledComponents == null && oldState.disabledComponents != null)
|| (disabledComponents != null && oldState.disabledComponents == null)) {
return false;
@@ -407,6 +413,7 @@ public class PackageUserState {
hashCode = 31 * hashCode + appLinkGeneration;
hashCode = 31 * hashCode + categoryHint;
hashCode = 31 * hashCode + installReason;
+ hashCode = 31 * hashCode + uninstallReason;
hashCode = 31 * hashCode + Objects.hashCode(disabledComponents);
hashCode = 31 * hashCode + Objects.hashCode(enabledComponents);
hashCode = 31 * hashCode + Objects.hashCode(harmfulAppWarning);