Add MATCH_APEX flag to getInstalledPackages.
If set, PackageManager will query apexservice and ask for activated
packages.
Test: wrote a small app to test the new query.
Bug: 117589375
Change-Id: I498bd97896f3eab65c88e9684874a30713be585e
diff --git a/core/java/android/content/pm/PackageInfo.java b/core/java/android/content/pm/PackageInfo.java
index 9e20503..ecdd810 100644
--- a/core/java/android/content/pm/PackageInfo.java
+++ b/core/java/android/content/pm/PackageInfo.java
@@ -18,6 +18,7 @@
import android.annotation.Nullable;
import android.annotation.UnsupportedAppUsage;
+import android.apex.ApexInfo;
import android.os.Parcel;
import android.os.Parcelable;
@@ -390,6 +391,11 @@
@Nullable
public String compileSdkVersionCodename;
+ /**
+ * Whether the package is an APEX package.
+ */
+ public boolean isApex;
+
public PackageInfo() {
}
@@ -472,6 +478,7 @@
} else {
dest.writeInt(0);
}
+ dest.writeBoolean(isApex);
}
public static final Parcelable.Creator<PackageInfo> CREATOR
@@ -533,7 +540,7 @@
if (hasSigningInfo != 0) {
signingInfo = SigningInfo.CREATOR.createFromParcel(source);
}
-
+ isApex = source.readBoolean();
// The component lists were flattened with the redundant ApplicationInfo
// instances omitted. Distribute the canonical one here as appropriate.
if (applicationInfo != null) {
@@ -544,6 +551,15 @@
}
}
+ /**
+ * @hide
+ */
+ public PackageInfo(ApexInfo apexInfo) {
+ packageName = apexInfo.packageName;
+ setLongVersionCode(apexInfo.versionCode);
+ isApex = true;
+ }
+
private void propagateApplicationInfo(ApplicationInfo appInfo, ComponentInfo[] components) {
if (components != null) {
for (ComponentInfo ci : components) {