mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-12-14 02:14:34 -05:00
47 lines
2.4 KiB
Diff
47 lines
2.4 KiB
Diff
|
From ddc8e8afabfd0956ddd646f57e7b10670a9309a8 Mon Sep 17 00:00:00 2001
|
||
|
From: lpeter <lpeter@google.com>
|
||
|
Date: Tue, 6 Aug 2024 09:22:12 +0000
|
||
|
Subject: [PATCH] Disallow device admin package and protected packages to be
|
||
|
reinstalled as instant.
|
||
|
|
||
|
We should prevent the following types of apps from being reinstalled with
|
||
|
--install-existing as an instant.
|
||
|
(1)device admin package
|
||
|
(2)protected packages
|
||
|
|
||
|
Flag: EXEMPT bugfix
|
||
|
|
||
|
Bug: 341256043
|
||
|
Test: Manual test
|
||
|
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:77c5ebbd2a83e060577dd584aed7802452339ca5)
|
||
|
Merged-In: I4e913a12477fd4a64990033eaae533e30863e2a2
|
||
|
Change-Id: I4e913a12477fd4a64990033eaae533e30863e2a2
|
||
|
---
|
||
|
.../java/com/android/server/pm/PackageManagerService.java | 6 +++++-
|
||
|
1 file changed, 5 insertions(+), 1 deletion(-)
|
||
|
|
||
|
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
|
||
|
index 893268da7f361..19245c4f7e0f9 100644
|
||
|
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
|
||
|
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
|
||
|
@@ -14284,6 +14284,9 @@ public int installExistingPackageAsUser(String packageName, int userId, int inst
|
||
|
(installFlags & PackageManager.INSTALL_INSTANT_APP) != 0;
|
||
|
final boolean fullApp =
|
||
|
(installFlags & PackageManager.INSTALL_FULL_APP) != 0;
|
||
|
+ final boolean isPackageDeviceAdmin = isPackageDeviceAdmin(packageName, userId);
|
||
|
+ final boolean isProtectedPackage = mProtectedPackages != null
|
||
|
+ && mProtectedPackages.isPackageStateProtected(userId, packageName);
|
||
|
|
||
|
// writer
|
||
|
synchronized (mPackages) {
|
||
|
@@ -14291,7 +14294,8 @@ public int installExistingPackageAsUser(String packageName, int userId, int inst
|
||
|
if (pkgSetting == null) {
|
||
|
return PackageManager.INSTALL_FAILED_INVALID_URI;
|
||
|
}
|
||
|
- if (instantApp && (pkgSetting.isSystem() || isUpdatedSystemApp(pkgSetting))) {
|
||
|
+ if (instantApp && (pkgSetting.isSystem() || isUpdatedSystemApp(pkgSetting)
|
||
|
+ || isPackageDeviceAdmin || isProtectedPackage)) {
|
||
|
return PackageManager.INSTALL_FAILED_INVALID_URI;
|
||
|
}
|
||
|
if (!canViewInstantApps(callingUid, UserHandle.getUserId(callingUid))) {
|