aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Kulakov <akulakov@google.com>2024-05-14 17:16:02 +0000
committerAnton Kulakov <akulakov@google.com>2024-05-15 15:41:41 +0000
commit31a811faa14346862f4fec0418e8310348c5c67c (patch)
treed8e24044b74f379cb020d7301f82d2c1247b6005
parent5e0b24a0eab14ea6d4628cd641153ea0e34b17ef (diff)
downloadmodules-utils-master.tar.gz
Make Privacy Sandbox Sdk Libs dexoptable.HEADmastermain
After recent changes in PackageManager, these libraries have appId = -1. This CL re-enables dexopt for them. Bug: 324537096 Test: PrimaryDexopterParameterizedTest, DumpHelperTest Change-Id: Ia9789d5ddc5355a08e3a52685ef57c12abe198ae
-rw-r--r--java/com/android/modules/utils/pm/PackageStateModulesUtils.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/java/com/android/modules/utils/pm/PackageStateModulesUtils.java b/java/com/android/modules/utils/pm/PackageStateModulesUtils.java
index 34fd16b..2944592 100644
--- a/java/com/android/modules/utils/pm/PackageStateModulesUtils.java
+++ b/java/com/android/modules/utils/pm/PackageStateModulesUtils.java
@@ -22,6 +22,7 @@ import android.text.TextUtils;
import androidx.annotation.RequiresApi;
+import com.android.server.pm.pkg.AndroidPackage;
import com.android.server.pm.pkg.AndroidPackageSplit;
import com.android.server.pm.pkg.PackageState;
@@ -35,8 +36,7 @@ public class PackageStateModulesUtils {
*/
@RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
public static boolean isDexoptable(@NonNull PackageState packageState) {
- if (packageState.isApex() || "android".equals(packageState.getPackageName())
- || packageState.getAppId() <= 0) {
+ if (packageState.isApex() || "android".equals(packageState.getPackageName())) {
return false;
}
@@ -45,6 +45,10 @@ public class PackageStateModulesUtils {
return false;
}
+ if ((packageState.getAppId() <= 0) && !isSdkLibrary(pkg)) {
+ return false;
+ }
+
List<AndroidPackageSplit> splits = pkg.getSplits();
for (int index = 0; index < splits.size(); index++) {
if (splits.get(index).isHasCode()) {
@@ -76,7 +80,7 @@ public class PackageStateModulesUtils {
return true;
}
- if (!TextUtils.isEmpty(pkg.getSdkLibraryName())) {
+ if (isSdkLibrary(pkg)) {
return true;
}
@@ -86,4 +90,9 @@ public class PackageStateModulesUtils {
return !codeOnly && pkg.isResourceOverlay();
}
+
+ @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
+ private static boolean isSdkLibrary(AndroidPackage pkg) {
+ return !TextUtils.isEmpty(pkg.getSdkLibraryName());
+ }
}