Merge "Attach SharedLibraryInfo to a Package."
am: 711941c64d
Change-Id: I5979f37f99127a51434649efd4ea1bba71f6272e
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 7b076f6..7aea261 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -6317,6 +6317,7 @@
public ArrayList<String> usesOptionalLibraries = null;
@UnsupportedAppUsage
public String[] usesLibraryFiles = null;
+ public ArrayList<SharedLibraryInfo> usesLibraryInfos = null;
public ArrayList<ActivityIntentInfo> preferredActivityFilters = null;
@@ -6846,6 +6847,8 @@
internStringArrayList(usesOptionalLibraries);
usesLibraryFiles = dest.readStringArray();
+ usesLibraryInfos = dest.createTypedArrayList(SharedLibraryInfo.CREATOR);
+
final int libCount = dest.readInt();
if (libCount > 0) {
usesStaticLibraries = new ArrayList<>(libCount);
@@ -6996,6 +6999,7 @@
dest.writeStringList(usesLibraries);
dest.writeStringList(usesOptionalLibraries);
dest.writeStringArray(usesLibraryFiles);
+ dest.writeTypedList(usesLibraryInfos);
if (ArrayUtils.isEmpty(usesStaticLibraries)) {
dest.writeInt(-1);
@@ -7456,6 +7460,10 @@
&& p.usesLibraryFiles != null) {
return true;
}
+ if ((flags & PackageManager.GET_SHARED_LIBRARY_FILES) != 0
+ && p.usesLibraryInfos != null) {
+ return true;
+ }
if (p.staticSharedLibName != null) {
return true;
}
diff --git a/core/java/android/content/pm/SharedLibraryInfo.java b/core/java/android/content/pm/SharedLibraryInfo.java
index 33bc951..a8bbeab 100644
--- a/core/java/android/content/pm/SharedLibraryInfo.java
+++ b/core/java/android/content/pm/SharedLibraryInfo.java
@@ -19,6 +19,7 @@
import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;
@@ -69,6 +70,8 @@
*/
public static final int VERSION_UNDEFINED = -1;
+ private final String mPath;
+ private final String mPackageName;
private final String mName;
private final long mVersion;
@@ -87,8 +90,10 @@
*
* @hide
*/
- public SharedLibraryInfo(String name, long version, int type,
+ public SharedLibraryInfo(String path, String packageName, String name, long version, int type,
VersionedPackage declaringPackage, List<VersionedPackage> dependentPackages) {
+ mPath = path;
+ mPackageName = packageName;
mName = name;
mVersion = version;
mType = type;
@@ -97,8 +102,8 @@
}
private SharedLibraryInfo(Parcel parcel) {
- this(parcel.readString(), parcel.readLong(), parcel.readInt(),
- parcel.readParcelable(null), parcel.readArrayList(null));
+ this(parcel.readString(), parcel.readString(), parcel.readString(), parcel.readLong(),
+ parcel.readInt(), parcel.readParcelable(null), parcel.readArrayList(null));
}
/**
@@ -121,6 +126,30 @@
}
/**
+ * If the shared library is a jar file, returns the path of that jar. Null otherwise.
+ * Only libraries with TYPE_BUILTIN are in jar files.
+ *
+ * @return The path.
+ *
+ * @hide
+ */
+ public @Nullable String getPath() {
+ return mPath;
+ }
+
+ /**
+ * If the shared library is an apk, returns the package name. Null otherwise.
+ * Only libraries with TYPE_DYNAMIC or TYPE_STATIC are in apks.
+ *
+ * @return The package name.
+ *
+ * @hide
+ */
+ public @Nullable String getPackageName() {
+ return mPackageName;
+ }
+
+ /**
* @deprecated Use {@link #getLongVersion()} instead.
*/
@Deprecated
@@ -196,6 +225,8 @@
@Override
public void writeToParcel(Parcel parcel, int flags) {
+ parcel.writeString(mPath);
+ parcel.writeString(mPackageName);
parcel.writeString(mName);
parcel.writeLong(mVersion);
parcel.writeInt(mType);
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index f279f0e..724d207 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -901,23 +901,9 @@
final ParallelPackageParserCallback mParallelPackageParserCallback =
new ParallelPackageParserCallback();
- public static final class SharedLibraryEntry {
- public final @Nullable String path;
- public final @Nullable String apk;
- public final @NonNull SharedLibraryInfo info;
-
- SharedLibraryEntry(String _path, String _apk, String name, long version, int type,
- String declaringPackageName, long declaringPackageVersionCode) {
- path = _path;
- apk = _apk;
- info = new SharedLibraryInfo(name, version, type, new VersionedPackage(
- declaringPackageName, declaringPackageVersionCode), null);
- }
- }
-
// Currently known shared libraries.
- final ArrayMap<String, LongSparseArray<SharedLibraryEntry>> mSharedLibraries = new ArrayMap<>();
- final ArrayMap<String, LongSparseArray<SharedLibraryEntry>> mStaticLibsByDeclaringPackage =
+ final ArrayMap<String, LongSparseArray<SharedLibraryInfo>> mSharedLibraries = new ArrayMap<>();
+ final ArrayMap<String, LongSparseArray<SharedLibraryInfo>> mStaticLibsByDeclaringPackage =
new ArrayMap<>();
// All available activities, for your resolving pleasure.
@@ -3512,11 +3498,15 @@
private @NonNull String getRequiredSharedLibraryLPr(String name, int version) {
synchronized (mPackages) {
- SharedLibraryEntry libraryEntry = getSharedLibraryEntryLPr(name, version);
- if (libraryEntry == null) {
+ SharedLibraryInfo libraryInfo = getSharedLibraryInfoLPr(name, version);
+ if (libraryInfo == null) {
throw new IllegalStateException("Missing required shared library:" + name);
}
- return libraryEntry.apk;
+ String packageName = libraryInfo.getPackageName();
+ if (packageName == null) {
+ throw new IllegalStateException("Expected a package for shared library " + name);
+ }
+ return packageName;
}
}
@@ -4249,9 +4239,9 @@
return false;
}
- final SharedLibraryEntry libEntry = getSharedLibraryEntryLPr(ps.pkg.staticSharedLibName,
+ final SharedLibraryInfo libraryInfo = getSharedLibraryInfoLPr(ps.pkg.staticSharedLibName,
ps.pkg.staticSharedLibVersion);
- if (libEntry == null) {
+ if (libraryInfo == null) {
return false;
}
@@ -4268,11 +4258,11 @@
PackageSetting uidPs = mSettings.getPackageLPr(uidPackageName);
if (uidPs != null) {
final int index = ArrayUtils.indexOf(uidPs.usesStaticLibraries,
- libEntry.info.getName());
+ libraryInfo.getName());
if (index < 0) {
continue;
}
- if (uidPs.pkg.usesStaticLibrariesVersions[index] == libEntry.info.getLongVersion()) {
+ if (uidPs.pkg.usesStaticLibrariesVersions[index] == libraryInfo.getLongVersion()) {
return false;
}
}
@@ -4668,14 +4658,14 @@
final int[] allUsers = sUserManager.getUserIds();
final int libCount = mSharedLibraries.size();
for (int i = 0; i < libCount; i++) {
- final LongSparseArray<SharedLibraryEntry> versionedLib
+ final LongSparseArray<SharedLibraryInfo> versionedLib
= mSharedLibraries.valueAt(i);
if (versionedLib == null) {
continue;
}
final int versionCount = versionedLib.size();
for (int j = 0; j < versionCount; j++) {
- SharedLibraryInfo libInfo = versionedLib.valueAt(j).info;
+ SharedLibraryInfo libInfo = versionedLib.valueAt(j);
// Skip packages that are not static shared libs.
if (!libInfo.isStatic()) {
break;
@@ -5041,14 +5031,14 @@
final int libCount = mSharedLibraries.size();
for (int i = 0; i < libCount; i++) {
- LongSparseArray<SharedLibraryEntry> versionedLib = mSharedLibraries.valueAt(i);
+ LongSparseArray<SharedLibraryInfo> versionedLib = mSharedLibraries.valueAt(i);
if (versionedLib == null) {
continue;
}
final int versionCount = versionedLib.size();
for (int j = 0; j < versionCount; j++) {
- SharedLibraryInfo libInfo = versionedLib.valueAt(j).info;
+ SharedLibraryInfo libInfo = versionedLib.valueAt(j);
if (!canSeeStaticLibraries && libInfo.isStatic()) {
break;
}
@@ -5064,10 +5054,10 @@
Binder.restoreCallingIdentity(identity);
}
- SharedLibraryInfo resLibInfo = new SharedLibraryInfo(libInfo.getName(),
- libInfo.getLongVersion(), libInfo.getType(),
- libInfo.getDeclaringPackage(), getPackagesUsingSharedLibraryLPr(libInfo,
- flags, userId));
+ SharedLibraryInfo resLibInfo = new SharedLibraryInfo(libInfo.getPath(),
+ libInfo.getPackageName(), libInfo.getName(), libInfo.getLongVersion(),
+ libInfo.getType(), libInfo.getDeclaringPackage(),
+ getPackagesUsingSharedLibraryLPr(libInfo, flags, userId));
if (result == null) {
result = new ArrayList<>();
@@ -5182,28 +5172,28 @@
Set<String> libs = null;
final int libCount = mSharedLibraries.size();
for (int i = 0; i < libCount; i++) {
- LongSparseArray<SharedLibraryEntry> versionedLib = mSharedLibraries.valueAt(i);
+ LongSparseArray<SharedLibraryInfo> versionedLib = mSharedLibraries.valueAt(i);
if (versionedLib == null) {
continue;
}
final int versionCount = versionedLib.size();
for (int j = 0; j < versionCount; j++) {
- SharedLibraryEntry libEntry = versionedLib.valueAt(j);
- if (!libEntry.info.isStatic()) {
+ SharedLibraryInfo libraryInfo = versionedLib.valueAt(j);
+ if (!libraryInfo.isStatic()) {
if (libs == null) {
libs = new ArraySet<>();
}
- libs.add(libEntry.info.getName());
+ libs.add(libraryInfo.getName());
break;
}
- PackageSetting ps = mSettings.getPackageLPr(libEntry.apk);
+ PackageSetting ps = mSettings.getPackageLPr(libraryInfo.getPackageName());
if (ps != null && !filterSharedLibPackageLPr(ps, Binder.getCallingUid(),
UserHandle.getUserId(Binder.getCallingUid()),
PackageManager.MATCH_STATIC_SHARED_LIBRARIES)) {
if (libs == null) {
libs = new ArraySet<>();
}
- libs.add(libEntry.info.getName());
+ libs.add(libraryInfo.getName());
break;
}
}
@@ -9451,24 +9441,24 @@
private PackageParser.Package findSharedNonSystemLibrary(String name, long version) {
synchronized (mPackages) {
- SharedLibraryEntry libEntry = getSharedLibraryEntryLPr(name, version);
- if (libEntry != null) {
- return mPackages.get(libEntry.apk);
+ SharedLibraryInfo libraryInfo = getSharedLibraryInfoLPr(name, version);
+ if (libraryInfo != null) {
+ return mPackages.get(libraryInfo.getPackageName());
}
return null;
}
}
- private SharedLibraryEntry getSharedLibraryEntryLPr(String name, long version) {
- LongSparseArray<SharedLibraryEntry> versionedLib = mSharedLibraries.get(name);
+ private SharedLibraryInfo getSharedLibraryInfoLPr(String name, long version) {
+ LongSparseArray<SharedLibraryInfo> versionedLib = mSharedLibraries.get(name);
if (versionedLib == null) {
return null;
}
return versionedLib.get(version);
}
- private SharedLibraryEntry getLatestSharedLibraVersionLPr(PackageParser.Package pkg) {
- LongSparseArray<SharedLibraryEntry> versionedLib = mSharedLibraries.get(
+ private SharedLibraryInfo getLatestSharedLibraVersionLPr(PackageParser.Package pkg) {
+ LongSparseArray<SharedLibraryInfo> versionedLib = mSharedLibraries.get(
pkg.staticSharedLibName);
if (versionedLib == null) {
return null;
@@ -9701,14 +9691,15 @@
}
private void addSharedLibraryLPr(Set<String> usesLibraryFiles,
- SharedLibraryEntry file,
+ SharedLibraryInfo file,
PackageParser.Package changingLib) {
- if (file.path != null) {
- usesLibraryFiles.add(file.path);
+
+ if (file.getPath() != null) {
+ usesLibraryFiles.add(file.getPath());
return;
}
- PackageParser.Package p = mPackages.get(file.apk);
- if (changingLib != null && changingLib.packageName.equals(file.apk)) {
+ PackageParser.Package p = mPackages.get(file.getPackageName());
+ if (changingLib != null && changingLib.packageName.equals(file.getPackageName())) {
// If we are doing this while in the middle of updating a library apk,
// then we need to make sure to use that new apk for determining the
// dependencies here. (We haven't yet finished committing the new apk
@@ -9733,42 +9724,52 @@
// The collection used here must maintain the order of addition (so
// that libraries are searched in the correct order) and must have no
// duplicates.
- Set<String> usesLibraryFiles = null;
+ ArrayList<SharedLibraryInfo> usesLibraryInfos = null;
if (pkg.usesLibraries != null) {
- usesLibraryFiles = addSharedLibrariesLPw(pkg.usesLibraries,
- null, null, pkg.packageName, changingLib, true,
+ usesLibraryInfos = addSharedLibrariesLPw(pkg.usesLibraries,
+ null, null, pkg.packageName, true,
pkg.applicationInfo.targetSdkVersion, null);
}
if (pkg.usesStaticLibraries != null) {
- usesLibraryFiles = addSharedLibrariesLPw(pkg.usesStaticLibraries,
+ usesLibraryInfos = addSharedLibrariesLPw(pkg.usesStaticLibraries,
pkg.usesStaticLibrariesVersions, pkg.usesStaticLibrariesCertDigests,
- pkg.packageName, changingLib, true,
- pkg.applicationInfo.targetSdkVersion, usesLibraryFiles);
+ pkg.packageName, true,
+ pkg.applicationInfo.targetSdkVersion, usesLibraryInfos);
}
if (pkg.usesOptionalLibraries != null) {
- usesLibraryFiles = addSharedLibrariesLPw(pkg.usesOptionalLibraries,
- null, null, pkg.packageName, changingLib, false,
- pkg.applicationInfo.targetSdkVersion, usesLibraryFiles);
+ usesLibraryInfos = addSharedLibrariesLPw(pkg.usesOptionalLibraries,
+ null, null, pkg.packageName, false,
+ pkg.applicationInfo.targetSdkVersion, usesLibraryInfos);
}
- if (!ArrayUtils.isEmpty(usesLibraryFiles)) {
+ if (usesLibraryInfos != null) {
+ pkg.usesLibraryInfos = usesLibraryInfos;
+ // Use LinkedHashSet to preserve the order of files added to
+ // usesLibraryFiles while eliminating duplicates.
+ Set<String> usesLibraryFiles = new LinkedHashSet<>();
+ for (SharedLibraryInfo libInfo : usesLibraryInfos) {
+ addSharedLibraryLPr(usesLibraryFiles, libInfo, changingLib);
+ }
pkg.usesLibraryFiles = usesLibraryFiles.toArray(new String[usesLibraryFiles.size()]);
} else {
+ pkg.usesLibraryInfos = null;
pkg.usesLibraryFiles = null;
}
}
- private Set<String> addSharedLibrariesLPw(@NonNull List<String> requestedLibraries,
+ @GuardedBy("mPackages")
+ private ArrayList<SharedLibraryInfo> addSharedLibrariesLPw(
+ @NonNull List<String> requestedLibraries,
@Nullable long[] requiredVersions, @Nullable String[][] requiredCertDigests,
- @NonNull String packageName, @Nullable PackageParser.Package changingLib,
- boolean required, int targetSdk, @Nullable Set<String> outUsedLibraries)
+ @NonNull String packageName, boolean required, int targetSdk,
+ @Nullable ArrayList<SharedLibraryInfo> outUsedLibraries)
throws PackageManagerException {
final int libCount = requestedLibraries.size();
for (int i = 0; i < libCount; i++) {
final String libName = requestedLibraries.get(i);
final long libVersion = requiredVersions != null ? requiredVersions[i]
: SharedLibraryInfo.VERSION_UNDEFINED;
- final SharedLibraryEntry libEntry = getSharedLibraryEntryLPr(libName, libVersion);
- if (libEntry == null) {
+ final SharedLibraryInfo libraryInfo = getSharedLibraryInfoLPr(libName, libVersion);
+ if (libraryInfo == null) {
if (required) {
throw new PackageManagerException(INSTALL_FAILED_MISSING_SHARED_LIBRARY,
"Package " + packageName + " requires unavailable shared library "
@@ -9780,14 +9781,14 @@
}
} else {
if (requiredVersions != null && requiredCertDigests != null) {
- if (libEntry.info.getLongVersion() != requiredVersions[i]) {
+ if (libraryInfo.getLongVersion() != requiredVersions[i]) {
throw new PackageManagerException(INSTALL_FAILED_MISSING_SHARED_LIBRARY,
"Package " + packageName + " requires unavailable static shared"
+ " library " + libName + " version "
- + libEntry.info.getLongVersion() + "; failing!");
+ + libraryInfo.getLongVersion() + "; failing!");
}
- PackageParser.Package libPkg = mPackages.get(libEntry.apk);
+ PackageParser.Package libPkg = mPackages.get(libraryInfo.getPackageName());
if (libPkg == null) {
throw new PackageManagerException(INSTALL_FAILED_MISSING_SHARED_LIBRARY,
"Package " + packageName + " requires unavailable static shared"
@@ -9844,11 +9845,9 @@
}
if (outUsedLibraries == null) {
- // Use LinkedHashSet to preserve the order of files added to
- // usesLibraryFiles while eliminating duplicates.
- outUsedLibraries = new LinkedHashSet<>();
+ outUsedLibraries = new ArrayList<>();
}
- addSharedLibraryLPr(outUsedLibraries, libEntry, changingLib);
+ outUsedLibraries.add(libraryInfo);
}
}
return outUsedLibraries;
@@ -10230,9 +10229,9 @@
// library in order to compare signatures.
PackageSetting signatureCheckPs = pkgSetting;
if (pkg.applicationInfo.isStaticSharedLibrary()) {
- SharedLibraryEntry libraryEntry = getLatestSharedLibraVersionLPr(pkg);
- if (libraryEntry != null) {
- signatureCheckPs = mSettings.getPackageLPr(libraryEntry.apk);
+ SharedLibraryInfo libraryInfo = getLatestSharedLibraVersionLPr(pkg);
+ if (libraryInfo != null) {
+ signatureCheckPs = mSettings.getPackageLPr(libraryInfo.getPackageName());
}
}
@@ -11061,12 +11060,12 @@
long minVersionCode = Long.MIN_VALUE;
long maxVersionCode = Long.MAX_VALUE;
- LongSparseArray<SharedLibraryEntry> versionedLib = mSharedLibraries.get(
+ LongSparseArray<SharedLibraryInfo> versionedLib = mSharedLibraries.get(
pkg.staticSharedLibName);
if (versionedLib != null) {
final int versionCount = versionedLib.size();
for (int i = 0; i < versionCount; i++) {
- SharedLibraryInfo libInfo = versionedLib.valueAt(i).info;
+ SharedLibraryInfo libInfo = versionedLib.valueAt(i);
final long libVersionCode = libInfo.getDeclaringPackage()
.getLongVersionCode();
if (libInfo.getLongVersion() < pkg.staticSharedLibVersion) {
@@ -11254,7 +11253,7 @@
private boolean addSharedLibraryLPw(String path, String apk, String name, long version,
int type, String declaringPackageName, long declaringVersionCode) {
- LongSparseArray<SharedLibraryEntry> versionedLib = mSharedLibraries.get(name);
+ LongSparseArray<SharedLibraryInfo> versionedLib = mSharedLibraries.get(name);
if (versionedLib == null) {
versionedLib = new LongSparseArray<>();
mSharedLibraries.put(name, versionedLib);
@@ -11264,14 +11263,15 @@
} else if (versionedLib.indexOfKey(version) >= 0) {
return false;
}
- SharedLibraryEntry libEntry = new SharedLibraryEntry(path, apk, name,
- version, type, declaringPackageName, declaringVersionCode);
- versionedLib.put(version, libEntry);
+ SharedLibraryInfo libraryInfo = new SharedLibraryInfo(path, apk, name,
+ version, type, new VersionedPackage(declaringPackageName, declaringVersionCode),
+ null);
+ versionedLib.put(version, libraryInfo);
return true;
}
private boolean removeSharedLibraryLPw(String name, long version) {
- LongSparseArray<SharedLibraryEntry> versionedLib = mSharedLibraries.get(name);
+ LongSparseArray<SharedLibraryInfo> versionedLib = mSharedLibraries.get(name);
if (versionedLib == null) {
return false;
}
@@ -11279,12 +11279,12 @@
if (libIdx < 0) {
return false;
}
- SharedLibraryEntry libEntry = versionedLib.valueAt(libIdx);
+ SharedLibraryInfo libraryInfo = versionedLib.valueAt(libIdx);
versionedLib.remove(version);
if (versionedLib.size() <= 0) {
mSharedLibraries.remove(name);
- if (libEntry.info.getType() == SharedLibraryInfo.TYPE_STATIC) {
- mStaticLibsByDeclaringPackage.remove(libEntry.info.getDeclaringPackage()
+ if (libraryInfo.getType() == SharedLibraryInfo.TYPE_STATIC) {
+ mStaticLibsByDeclaringPackage.remove(libraryInfo.getDeclaringPackage()
.getPackageName());
}
}
@@ -17330,9 +17330,9 @@
// the package setting for the latest library version.
PackageSetting signatureCheckPs = ps;
if (pkg.applicationInfo.isStaticSharedLibrary()) {
- SharedLibraryEntry libraryEntry = getLatestSharedLibraVersionLPr(pkg);
- if (libraryEntry != null) {
- signatureCheckPs = mSettings.getPackageLPr(libraryEntry.apk);
+ SharedLibraryInfo libraryInfo = getLatestSharedLibraVersionLPr(pkg);
+ if (libraryInfo != null) {
+ signatureCheckPs = mSettings.getPackageLPr(libraryInfo.getPackageName());
}
}
@@ -18024,7 +18024,7 @@
packageName = normalizedPackageName != null ? normalizedPackageName : packageName;
// Is this a static library?
- LongSparseArray<SharedLibraryEntry> versionedLib =
+ LongSparseArray<SharedLibraryInfo> versionedLib =
mStaticLibsByDeclaringPackage.get(packageName);
if (versionedLib == null || versionedLib.size() <= 0) {
return packageName;
@@ -18036,7 +18036,7 @@
if (callingAppId != Process.SYSTEM_UID && callingAppId != Process.SHELL_UID
&& callingAppId != Process.ROOT_UID) {
versionsCallerCanSee = new LongSparseLongArray();
- String libName = versionedLib.valueAt(0).info.getName();
+ String libName = versionedLib.valueAt(0).getName();
String[] uidPackages = getPackagesForUid(Binder.getCallingUid());
if (uidPackages != null) {
for (String uidPackage : uidPackages) {
@@ -18056,29 +18056,29 @@
}
// Find the version the caller can see and the app version code
- SharedLibraryEntry highestVersion = null;
+ SharedLibraryInfo highestVersion = null;
final int versionCount = versionedLib.size();
for (int i = 0; i < versionCount; i++) {
- SharedLibraryEntry libEntry = versionedLib.valueAt(i);
+ SharedLibraryInfo libraryInfo = versionedLib.valueAt(i);
if (versionsCallerCanSee != null && versionsCallerCanSee.indexOfKey(
- libEntry.info.getLongVersion()) < 0) {
+ libraryInfo.getLongVersion()) < 0) {
continue;
}
- final long libVersionCode = libEntry.info.getDeclaringPackage().getLongVersionCode();
+ final long libVersionCode = libraryInfo.getDeclaringPackage().getLongVersionCode();
if (versionCode != PackageManager.VERSION_CODE_HIGHEST) {
if (libVersionCode == versionCode) {
- return libEntry.apk;
+ return libraryInfo.getPackageName();
}
} else if (highestVersion == null) {
- highestVersion = libEntry;
- } else if (libVersionCode > highestVersion.info
+ highestVersion = libraryInfo;
+ } else if (libVersionCode > highestVersion
.getDeclaringPackage().getLongVersionCode()) {
- highestVersion = libEntry;
+ highestVersion = libraryInfo;
}
}
if (highestVersion != null) {
- return highestVersion.apk;
+ return highestVersion.getPackageName();
}
return packageName;
@@ -18240,19 +18240,19 @@
allUsers = sUserManager.getUserIds();
if (pkg != null && pkg.staticSharedLibName != null) {
- SharedLibraryEntry libEntry = getSharedLibraryEntryLPr(pkg.staticSharedLibName,
+ SharedLibraryInfo libraryInfo = getSharedLibraryInfoLPr(pkg.staticSharedLibName,
pkg.staticSharedLibVersion);
- if (libEntry != null) {
+ if (libraryInfo != null) {
for (int currUserId : allUsers) {
if (removeUser != UserHandle.USER_ALL && removeUser != currUserId) {
continue;
}
List<VersionedPackage> libClientPackages = getPackagesUsingSharedLibraryLPr(
- libEntry.info, 0, currUserId);
+ libraryInfo, 0, currUserId);
if (!ArrayUtils.isEmpty(libClientPackages)) {
Slog.w(TAG, "Not removing package " + pkg.manifestPackageName
- + " hosting lib " + libEntry.info.getName() + " version "
- + libEntry.info.getLongVersion() + " used by " + libClientPackages
+ + " hosting lib " + libraryInfo.getName() + " version "
+ + libraryInfo.getLongVersion() + " used by " + libClientPackages
+ " for user " + currUserId);
return PackageManager.DELETE_FAILED_USED_SHARED_LIBRARY;
}
@@ -21593,14 +21593,14 @@
final Iterator<String> it = mSharedLibraries.keySet().iterator();
while (it.hasNext()) {
String libName = it.next();
- LongSparseArray<SharedLibraryEntry> versionedLib
+ LongSparseArray<SharedLibraryInfo> versionedLib
= mSharedLibraries.get(libName);
if (versionedLib == null) {
continue;
}
final int versionCount = versionedLib.size();
for (int i = 0; i < versionCount; i++) {
- SharedLibraryEntry libEntry = versionedLib.valueAt(i);
+ SharedLibraryInfo libraryInfo = versionedLib.valueAt(i);
if (!checkin) {
if (!printedHeader) {
if (dumpState.onTitlePrinted())
@@ -21612,19 +21612,19 @@
} else {
pw.print("lib,");
}
- pw.print(libEntry.info.getName());
- if (libEntry.info.isStatic()) {
- pw.print(" version=" + libEntry.info.getLongVersion());
+ pw.print(libraryInfo.getName());
+ if (libraryInfo.isStatic()) {
+ pw.print(" version=" + libraryInfo.getLongVersion());
}
if (!checkin) {
pw.print(" -> ");
}
- if (libEntry.path != null) {
+ if (libraryInfo.getPath() != null) {
pw.print(" (jar) ");
- pw.print(libEntry.path);
+ pw.print(libraryInfo.getPath());
} else {
pw.print(" (apk) ");
- pw.print(libEntry.apk);
+ pw.print(libraryInfo.getPackageName());
}
pw.println();
}
@@ -22024,22 +22024,24 @@
final int count = mSharedLibraries.size();
for (int i = 0; i < count; i++) {
final String libName = mSharedLibraries.keyAt(i);
- LongSparseArray<SharedLibraryEntry> versionedLib = mSharedLibraries.get(libName);
+ LongSparseArray<SharedLibraryInfo> versionedLib = mSharedLibraries.get(libName);
if (versionedLib == null) {
continue;
}
final int versionCount = versionedLib.size();
for (int j = 0; j < versionCount; j++) {
- final SharedLibraryEntry libEntry = versionedLib.valueAt(j);
+ final SharedLibraryInfo libraryInfo = versionedLib.valueAt(j);
final long sharedLibraryToken =
proto.start(PackageServiceDumpProto.SHARED_LIBRARIES);
- proto.write(PackageServiceDumpProto.SharedLibraryProto.NAME, libEntry.info.getName());
- final boolean isJar = (libEntry.path != null);
+ proto.write(PackageServiceDumpProto.SharedLibraryProto.NAME, libraryInfo.getName());
+ final boolean isJar = (libraryInfo.getPath() != null);
proto.write(PackageServiceDumpProto.SharedLibraryProto.IS_JAR, isJar);
if (isJar) {
- proto.write(PackageServiceDumpProto.SharedLibraryProto.PATH, libEntry.path);
+ proto.write(PackageServiceDumpProto.SharedLibraryProto.PATH,
+ libraryInfo.getPath());
} else {
- proto.write(PackageServiceDumpProto.SharedLibraryProto.APK, libEntry.apk);
+ proto.write(PackageServiceDumpProto.SharedLibraryProto.APK,
+ libraryInfo.getPackageName());
}
proto.end(sharedLibraryToken);
}
diff --git a/services/tests/servicestests/src/com/android/server/pm/PackageParserTest.java b/services/tests/servicestests/src/com/android/server/pm/PackageParserTest.java
index 2f6e2c2..952abfa 100644
--- a/services/tests/servicestests/src/com/android/server/pm/PackageParserTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/PackageParserTest.java
@@ -24,6 +24,7 @@
import android.content.pm.PackageParser;
import android.content.pm.ProviderInfo;
import android.content.pm.ServiceInfo;
+import android.content.pm.SharedLibraryInfo;
import android.content.pm.Signature;
import android.os.Bundle;
import android.os.Parcel;
@@ -487,6 +488,9 @@
pkg.usesLibraryFiles = new String[] { "foo13"};
+ pkg.usesLibraryInfos = new ArrayList<>();
+ pkg.usesLibraryInfos.add(new SharedLibraryInfo(null, null, null, 0L, 0, null, null));
+
pkg.mOriginalPackages = new ArrayList<>();
pkg.mOriginalPackages.add("foo14");