diff options
| -rw-r--r-- | services/core/java/com/android/server/pm/PackageManagerService.java | 56 |
1 files changed, 26 insertions, 30 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index da59b3e9b8d4..b419384ba7f8 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -15607,13 +15607,25 @@ public class PackageManagerService extends IPackageManager.Stub if (!hasDynamicLibraries) { return null; } + final boolean isUpdatedSystemApp = pkg.isUpdatedSystemApp(); + // We may not yet have disabled the updated package yet, so be sure to grab the + // current setting if that's the case. + final PackageSetting updatedSystemPs = isUpdatedSystemApp + ? scanResult.request.disabledPkgSetting == null + ? scanResult.request.oldPkgSetting + : scanResult.request.disabledPkgSetting + : null; + if (isUpdatedSystemApp && (updatedSystemPs.pkg == null + || updatedSystemPs.pkg.libraryNames == null)) { + Slog.w(TAG, "Package " + pkg.packageName + " declares libraries that are not " + + "declared on the system image; skipping"); + return null; + } final ArrayList<SharedLibraryInfo> infos = new ArrayList<>(scanResult.dynamicSharedLibraryInfos.size()); - final boolean updatedSystemApp = pkg.isUpdatedSystemApp(); for (SharedLibraryInfo info : scanResult.dynamicSharedLibraryInfos) { - String name = info.getName(); - boolean allowed = false; - if (updatedSystemApp) { + final String name = info.getName(); + if (isUpdatedSystemApp) { // New library entries can only be added through the // system image. This is important to get rid of a lot // of nasty edge cases: for example if we allowed a non- @@ -15623,36 +15635,20 @@ public class PackageManagerService extends IPackageManager.Stub // have allowed apps on the device which aren't compatible // with it. Better to just have the restriction here, be // conservative, and create many fewer cases that can negatively - // impact the user experience. We may not yet have disabled the - // updated package yet, so be sure to grab the current setting if - // that's the case. - final PackageSetting sysPs = scanResult.request.disabledPkgSetting == null - ? scanResult.request.oldPkgSetting - : scanResult.request.disabledPkgSetting; - if (sysPs.pkg != null && sysPs.pkg.libraryNames != null) { - for (int j = 0; j < sysPs.pkg.libraryNames.size(); j++) { - if (name.equals(sysPs.pkg.libraryNames.get(j))) { - allowed = true; - break; - } - } - } - } else { - allowed = true; - } - if (allowed) { - if (sharedLibExists( - name, SharedLibraryInfo.VERSION_UNDEFINED, existingSharedLibraries)) { - Slog.w(TAG, "Package " + pkg.packageName + " library " - + name + " already exists; skipping"); + // impact the user experience. + if (!updatedSystemPs.pkg.libraryNames.contains(name)) { + Slog.w(TAG, "Package " + pkg.packageName + " declares library " + name + + " that is not declared on system image; skipping"); continue; } - infos.add(info); - } else { - Slog.w(TAG, "Package " + pkg.packageName + " declares lib " - + name + " that is not declared on system image; skipping"); + } + if (sharedLibExists( + name, SharedLibraryInfo.VERSION_UNDEFINED, existingSharedLibraries)) { + Slog.w(TAG, "Package " + pkg.packageName + " declares library " + name + + " that already exists; skipping"); continue; } + infos.add(info); } return infos; } |