Merge "Make ext libs a part of AOSP and mandatory" into nyc-dev
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index a6fce51..b07616f 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -76,7 +76,6 @@
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.content.pm.PackageParser.PARSE_IS_PRIVILEGED;
import static android.content.pm.PackageParser.isApkFile;
-import static android.os.Process.FIRST_APPLICATION_UID;
import static android.os.Process.PACKAGE_INFO_GID;
import static android.os.Process.SYSTEM_UID;
import static android.os.Trace.TRACE_TAG_PACKAGE_MANAGER;
@@ -117,7 +116,6 @@
import android.content.IIntentReceiver;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.IntentFilter.AuthorityEntry;
import android.content.IntentSender;
import android.content.IntentSender.SendIntentException;
import android.content.ServiceConnection;
@@ -150,7 +148,6 @@
import android.content.pm.PackageManagerInternal;
import android.content.pm.PackageParser;
import android.content.pm.PackageParser.ActivityIntentInfo;
-import android.content.pm.PackageParser.IntentInfo;
import android.content.pm.PackageParser.PackageLite;
import android.content.pm.PackageParser.PackageParserException;
import android.content.pm.PackageStats;
@@ -1066,8 +1063,9 @@
| FLAG_PERMISSION_REVOKE_ON_UPGRADE;
final @Nullable String mRequiredVerifierPackage;
- final @Nullable String mRequiredInstallerPackage;
+ final @NonNull String mRequiredInstallerPackage;
final @Nullable String mSetupWizardPackage;
+ final @NonNull String mServicesSystemSharedLibraryPackageName;
private final PackageUsage mPackageUsage = new PackageUsage();
@@ -2585,11 +2583,16 @@
mIntentFilterVerifierComponent = getIntentFilterVerifierComponentNameLPr();
mIntentFilterVerifier = new IntentVerifierProxy(mContext,
mIntentFilterVerifierComponent);
+ mServicesSystemSharedLibraryPackageName = getRequiredSharedLibraryLPr(
+ PackageManager.SYSTEM_SHARED_LIBRARY_SERVICES);
+ getRequiredSharedLibraryLPr(
+ PackageManager.SYSTEM_SHARED_LIBRARY_SHARED);
} else {
mRequiredVerifierPackage = null;
mRequiredInstallerPackage = null;
mIntentFilterVerifierComponent = null;
mIntentFilterVerifier = null;
+ mServicesSystemSharedLibraryPackageName = null;
}
mInstallerService = new PackageInstallerService(context, this);
@@ -2669,6 +2672,16 @@
}
}
+ private @NonNull String getRequiredSharedLibraryLPr(String libraryName) {
+ synchronized (mPackages) {
+ SharedLibraryEntry libraryEntry = mSharedLibraries.get(libraryName);
+ if (libraryEntry == null) {
+ throw new IllegalStateException("Missing required shared library:" + libraryName);
+ }
+ return libraryEntry.apk;
+ }
+ }
+
private @NonNull String getRequiredInstallerLPr() {
final Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
intent.addCategory(Intent.CATEGORY_DEFAULT);
@@ -2678,6 +2691,10 @@
MATCH_SYSTEM_ONLY | MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE,
UserHandle.USER_SYSTEM);
if (matches.size() == 1) {
+ ResolveInfo resolveInfo = matches.get(0);
+ if (!resolveInfo.activityInfo.applicationInfo.isPrivilegedApp()) {
+ throw new RuntimeException("The installer must be a privileged app");
+ }
return matches.get(0).getComponentInfo().packageName;
} else {
throw new RuntimeException("There must be exactly one installer; found " + matches);
@@ -3560,15 +3577,10 @@
}
@Override
- public @Nullable String getServicesSystemSharedLibraryPackageName() {
+ public @NonNull String getServicesSystemSharedLibraryPackageName() {
synchronized (mPackages) {
- SharedLibraryEntry libraryEntry = mSharedLibraries.get(
- PackageManager.SYSTEM_SHARED_LIBRARY_SERVICES);
- if (libraryEntry != null) {
- return libraryEntry.apk;
- }
+ return mServicesSystemSharedLibraryPackageName;
}
- return null;
}
@Override