Dont throw an exception for non-system apps when enabling system apps.
In EnableSystemAppWithIntent: if a non-system app matches the intent:
ignore it instead of throwing an exception.
Change-Id: I64dc9a0bbc1a6bc5e2159a33b7273464ed2518c5
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index b8f0d072..05c37d1 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -5045,15 +5045,14 @@
if (activitiesToEnable != null) {
for (ResolveInfo info : activitiesToEnable) {
if (info.activityInfo != null) {
-
- if (!isSystemApp(pm, info.activityInfo.packageName, primaryUser.id)) {
- throw new IllegalArgumentException(
- "Only system apps can be enabled this way.");
+ String packageName = info.activityInfo.packageName;
+ if (isSystemApp(pm, packageName, primaryUser.id)) {
+ numberOfAppsInstalled++;
+ pm.installExistingPackageAsUser(packageName, userId);
+ } else {
+ Slog.d(LOG_TAG, "Not enabling " + packageName + " since is not a"
+ + " system app");
}
-
-
- numberOfAppsInstalled++;
- pm.installExistingPackageAsUser(info.activityInfo.packageName, userId);
}
}
}