diff options
14 files changed, 174 insertions, 162 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index fea6f0e18a32..e6c576825e67 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -577,7 +577,7 @@ public class Am extends BaseCommand { return; } List<ResolveInfo> activities = pm.queryIntentActivities(intent, mimeType, 0, - mUserId); + mUserId).getList(); if (activities == null || activities.size() <= 0) { System.err.println("Error: Intent does not match any activities: " + intent); diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 1bc33b81ed35..14688c1bc1b9 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -193,7 +193,7 @@ public final class ActivityThread { private ContextImpl mSystemContext; - static IPackageManager sPackageManager; + static volatile IPackageManager sPackageManager; final ApplicationThread mAppThread = new ApplicationThread(); final Looper mLooper = Looper.myLooper(); @@ -218,7 +218,7 @@ public final class ActivityThread { // set of instantiated backup agents, keyed by package name final ArrayMap<String, BackupAgent> mBackupAgents = new ArrayMap<String, BackupAgent>(); /** Reference to singleton {@link ActivityThread} */ - private static ActivityThread sCurrentActivityThread; + private static volatile ActivityThread sCurrentActivityThread; Instrumentation mInstrumentation; String mInstrumentationPackageName = null; String mInstrumentationAppDir = null; @@ -296,7 +296,7 @@ public final class ActivityThread { final GcIdler mGcIdler = new GcIdler(); boolean mGcIdlerScheduled = false; - static Handler sMainThreadHandler; // set once in main() + static volatile Handler sMainThreadHandler; // set once in main() Bundle mCoreSettings = null; diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java index 38f32f7165ed..0b44925bdd0c 100644 --- a/core/java/android/app/ApplicationPackageManager.java +++ b/core/java/android/app/ApplicationPackageManager.java @@ -275,7 +275,7 @@ public class ApplicationPackageManager extends PackageManager { public List<PermissionInfo> queryPermissionsByGroup(String group, int flags) throws NameNotFoundException { try { - List<PermissionInfo> pi = mPM.queryPermissionsByGroup(group, flags); + List<PermissionInfo> pi = mPM.queryPermissionsByGroup(group, flags).getList(); if (pi != null) { return pi; } @@ -304,7 +304,7 @@ public class ApplicationPackageManager extends PackageManager { @Override public List<PermissionGroupInfo> getAllPermissionGroups(int flags) { try { - return mPM.getAllPermissionGroups(flags); + return mPM.getAllPermissionGroups(flags).getList(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -441,7 +441,12 @@ public class ApplicationPackageManager extends PackageManager { @Override public FeatureInfo[] getSystemAvailableFeatures() { try { - return mPM.getSystemAvailableFeatures(); + final List<FeatureInfo> list = mPM.getSystemAvailableFeatures().getList(); + final FeatureInfo[] res = new FeatureInfo[list.size()]; + for (int i = 0; i < res.length; i++) { + res[i] = list.get(i); + } + return res; } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -772,7 +777,7 @@ public class ApplicationPackageManager extends PackageManager { intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), flags, - userId); + userId).getList(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -802,9 +807,10 @@ public class ApplicationPackageManager extends PackageManager { } try { - return mPM.queryIntentActivityOptions(caller, specifics, - specificTypes, intent, intent.resolveTypeIfNeeded(resolver), - flags, mContext.getUserId()); + return mPM + .queryIntentActivityOptions(caller, specifics, specificTypes, intent, + intent.resolveTypeIfNeeded(resolver), flags, mContext.getUserId()) + .getList(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -820,7 +826,7 @@ public class ApplicationPackageManager extends PackageManager { intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), flags, - userId); + userId).getList(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -851,7 +857,7 @@ public class ApplicationPackageManager extends PackageManager { intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), flags, - userId); + userId).getList(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -867,7 +873,8 @@ public class ApplicationPackageManager extends PackageManager { Intent intent, int flags, int userId) { try { return mPM.queryIntentContentProviders(intent, - intent.resolveTypeIfNeeded(mContext.getContentResolver()), flags, userId); + intent.resolveTypeIfNeeded(mContext.getContentResolver()), flags, userId) + .getList(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -926,7 +933,7 @@ public class ApplicationPackageManager extends PackageManager { public List<InstrumentationInfo> queryInstrumentation( String targetPackage, int flags) { try { - return mPM.queryInstrumentation(targetPackage, flags); + return mPM.queryInstrumentation(targetPackage, flags).getList(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1572,7 +1579,7 @@ public class ApplicationPackageManager extends PackageManager { @Override public List<IntentFilterVerificationInfo> getIntentFilterVerifications(String packageName) { try { - return mPM.getIntentFilterVerifications(packageName); + return mPM.getIntentFilterVerifications(packageName).getList(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1581,7 +1588,7 @@ public class ApplicationPackageManager extends PackageManager { @Override public List<IntentFilter> getAllIntentFilters(String packageName) { try { - return mPM.getAllIntentFilters(packageName); + return mPM.getAllIntentFilters(packageName).getList(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1892,31 +1899,21 @@ public class ApplicationPackageManager extends PackageManager { throw e.rethrowFromSystemServer(); } } + @Override public void addPackageToPreferred(String packageName) { - try { - mPM.addPackageToPreferred(packageName); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); - } + Log.w(TAG, "addPackageToPreferred() is a no-op"); } @Override public void removePackageFromPreferred(String packageName) { - try { - mPM.removePackageFromPreferred(packageName); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); - } + Log.w(TAG, "removePackageFromPreferred() is a no-op"); } @Override public List<PackageInfo> getPreferredPackages(int flags) { - try { - return mPM.getPreferredPackages(flags); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); - } + Log.w(TAG, "getPreferredPackages() is a no-op"); + return Collections.emptyList(); } @Override diff --git a/core/java/android/content/pm/AppsQueryHelper.java b/core/java/android/content/pm/AppsQueryHelper.java index e5425897afad..4c01b2783f8d 100644 --- a/core/java/android/content/pm/AppsQueryHelper.java +++ b/core/java/android/content/pm/AppsQueryHelper.java @@ -171,7 +171,7 @@ public class AppsQueryHelper { return mPackageManager.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS, userId).getList(); } catch (RemoteException e) { - throw new IllegalStateException("Package manager has died", e); + throw e.rethrowFromSystemServer(); } } @@ -181,9 +181,9 @@ public class AppsQueryHelper { return mPackageManager.queryIntentActivities(intent, null, PackageManager.GET_DISABLED_COMPONENTS | PackageManager.GET_UNINSTALLED_PACKAGES, - userId); + userId).getList(); } catch (RemoteException e) { - throw new IllegalStateException("Package manager has died", e); + throw e.rethrowFromSystemServer(); } } @@ -192,9 +192,9 @@ public class AppsQueryHelper { try { return mPackageManager.queryIntentServices(intent, null, PackageManager.GET_META_DATA - | PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS, userId); + | PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS, userId).getList(); } catch (RemoteException e) { - throw new IllegalStateException("Package manager has died", e); + throw e.rethrowFromSystemServer(); } } @@ -205,8 +205,7 @@ public class AppsQueryHelper { return mPackageManager.getPackagesHoldingPermissions(new String[]{perm}, 0, userId).getList(); } catch (RemoteException e) { - throw new IllegalStateException("Package manager has died", e); + throw e.rethrowFromSystemServer(); } } - } diff --git a/core/java/android/content/pm/IPackageManager.aidl b/core/java/android/content/pm/IPackageManager.aidl index 0389085ae0ee..b4e9f60700a3 100644 --- a/core/java/android/content/pm/IPackageManager.aidl +++ b/core/java/android/content/pm/IPackageManager.aidl @@ -71,11 +71,11 @@ interface IPackageManager { PermissionInfo getPermissionInfo(String name, int flags); - List<PermissionInfo> queryPermissionsByGroup(String group, int flags); + ParceledListSlice queryPermissionsByGroup(String group, int flags); PermissionGroupInfo getPermissionGroupInfo(String name, int flags); - List<PermissionGroupInfo> getAllPermissionGroups(int flags); + ParceledListSlice getAllPermissionGroups(int flags); ApplicationInfo getApplicationInfo(String packageName, int flags ,int userId); @@ -138,24 +138,24 @@ interface IPackageManager { boolean canForwardTo(in Intent intent, String resolvedType, int sourceUserId, int targetUserId); - List<ResolveInfo> queryIntentActivities(in Intent intent, + ParceledListSlice queryIntentActivities(in Intent intent, String resolvedType, int flags, int userId); - List<ResolveInfo> queryIntentActivityOptions( + ParceledListSlice queryIntentActivityOptions( in ComponentName caller, in Intent[] specifics, in String[] specificTypes, in Intent intent, String resolvedType, int flags, int userId); - List<ResolveInfo> queryIntentReceivers(in Intent intent, + ParceledListSlice queryIntentReceivers(in Intent intent, String resolvedType, int flags, int userId); ResolveInfo resolveService(in Intent intent, String resolvedType, int flags, int userId); - List<ResolveInfo> queryIntentServices(in Intent intent, + ParceledListSlice queryIntentServices(in Intent intent, String resolvedType, int flags, int userId); - List<ResolveInfo> queryIntentContentProviders(in Intent intent, + ParceledListSlice queryIntentContentProviders(in Intent intent, String resolvedType, int flags, int userId); /** @@ -189,7 +189,7 @@ interface IPackageManager { * @return A List<applicationInfo> containing one entry for each persistent * application. */ - List<ApplicationInfo> getPersistentApplications(int flags); + ParceledListSlice getPersistentApplications(int flags); ProviderInfo resolveContentProvider(String name, int flags, int userId); @@ -210,7 +210,7 @@ interface IPackageManager { InstrumentationInfo getInstrumentationInfo( in ComponentName className, int flags); - List<InstrumentationInfo> queryInstrumentation( + ParceledListSlice queryInstrumentation( String targetPackage, int flags); /** @deprecated Use PackageInstaller instead */ @@ -240,12 +240,6 @@ interface IPackageManager { String getInstallerPackageName(in String packageName); - void addPackageToPreferred(String packageName); - - void removePackageFromPreferred(String packageName); - - List<PackageInfo> getPreferredPackages(int flags); - void resetApplicationPreferences(int userId); ResolveInfo getLastChosenActivity(in Intent intent, @@ -406,7 +400,7 @@ interface IPackageManager { * Get a list of features that are available on the * system. */ - FeatureInfo[] getSystemAvailableFeatures(); + ParceledListSlice getSystemAvailableFeatures(); boolean hasSystemFeature(String name, int version); @@ -480,8 +474,8 @@ interface IPackageManager { void verifyIntentFilter(int id, int verificationCode, in List<String> failedDomains); int getIntentVerificationStatus(String packageName, int userId); boolean updateIntentVerificationStatus(String packageName, int status, int userId); - List<IntentFilterVerificationInfo> getIntentFilterVerifications(String packageName); - List<IntentFilter> getAllIntentFilters(String packageName); + ParceledListSlice getIntentFilterVerifications(String packageName); + ParceledListSlice getAllIntentFilters(String packageName); boolean setDefaultBrowserPackageName(String packageName, int userId); String getDefaultBrowserPackageName(int userId); diff --git a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java index 8603981ec88a..3659a40d9f6c 100644 --- a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java +++ b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java @@ -2496,7 +2496,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku return mPackageManager.queryIntentReceivers(intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), - flags, userId); + flags, userId).getList(); } catch (RemoteException re) { return Collections.emptyList(); } finally { diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 99e98630a474..8cea8ee06749 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -4374,7 +4374,7 @@ public final class ActivityManagerService extends ActivityManagerNative AppGlobals.getPackageManager().queryIntentActivities( intent, r.resolvedType, PackageManager.MATCH_DEFAULT_ONLY | STOCK_PM_FLAGS, - UserHandle.getCallingUserId()); + UserHandle.getCallingUserId()).getList(); // Look for the original activity in the list... final int N = resolves != null ? resolves.size() : 0; @@ -10857,7 +10857,7 @@ public final class ActivityManagerService extends ActivityManagerNative synchronized (this) { try { final List<ApplicationInfo> apps = AppGlobals.getPackageManager() - .getPersistentApplications(STOCK_PM_FLAGS | matchFlags); + .getPersistentApplications(STOCK_PM_FLAGS | matchFlags).getList(); for (ApplicationInfo app : apps) { if (!"android".equals(app.packageName)) { addAppLocked(app, false, null /* ABI override */); @@ -12608,7 +12608,7 @@ public final class ActivityManagerService extends ActivityManagerNative List<ResolveInfo> ris = null; try { ris = AppGlobals.getPackageManager().queryIntentReceivers( - intent, null, MATCH_SYSTEM_ONLY, UserHandle.USER_SYSTEM); + intent, null, MATCH_SYSTEM_ONLY, UserHandle.USER_SYSTEM).getList(); } catch (RemoteException e) { } if (ris == null) { @@ -16957,7 +16957,7 @@ public final class ActivityManagerService extends ActivityManagerNative continue; } List<ResolveInfo> newReceivers = AppGlobals.getPackageManager() - .queryIntentReceivers(intent, resolvedType, pmFlags, user); + .queryIntentReceivers(intent, resolvedType, pmFlags, user).getList(); if (user != UserHandle.USER_SYSTEM && newReceivers != null) { // If this is not the system user, we need to check for // any receivers that should be filtered out. diff --git a/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java b/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java index d6b59f9ab35a..9ec6da0cd148 100644 --- a/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java +++ b/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java @@ -714,7 +714,8 @@ final class DefaultPermissionGrantPolicy { private PackageParser.Package getDefaultSystemHandlerServicePackageLPr( Intent intent, int userId) { List<ResolveInfo> handlers = mService.queryIntentServices(intent, - intent.resolveType(mService.mContext.getContentResolver()), DEFAULT_FLAGS, userId); + intent.resolveType(mService.mContext.getContentResolver()), DEFAULT_FLAGS, userId) + .getList(); if (handlers == null) { return null; } diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 5562e76c024e..8d7e632646ca 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -174,7 +174,6 @@ import android.os.Looper; import android.os.Message; import android.os.Parcel; import android.os.ParcelFileDescriptor; -import android.os.Parcelable; import android.os.Process; import android.os.RemoteCallbackList; import android.os.RemoteException; @@ -2564,7 +2563,7 @@ public class PackageManagerService extends IPackageManager.Stub { private @Nullable String getRequiredButNotReallyRequiredVerifierLPr() { final Intent intent = new Intent(Intent.ACTION_PACKAGE_NEEDS_VERIFICATION); - final List<ResolveInfo> matches = queryIntentReceivers(intent, PACKAGE_MIME_TYPE, + final List<ResolveInfo> matches = queryIntentReceiversInternal(intent, PACKAGE_MIME_TYPE, MATCH_SYSTEM_ONLY | MATCH_ENCRYPTION_AWARE_AND_UNAWARE, UserHandle.USER_SYSTEM); if (matches.size() == 1) { return matches.get(0).getComponentInfo().packageName; @@ -2579,7 +2578,7 @@ public class PackageManagerService extends IPackageManager.Stub { intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setDataAndType(Uri.fromFile(new File("foo.apk")), PACKAGE_MIME_TYPE); - final List<ResolveInfo> matches = queryIntentActivities(intent, PACKAGE_MIME_TYPE, + final List<ResolveInfo> matches = queryIntentActivitiesInternal(intent, PACKAGE_MIME_TYPE, MATCH_SYSTEM_ONLY | MATCH_ENCRYPTION_AWARE_AND_UNAWARE, UserHandle.USER_SYSTEM); if (matches.size() == 1) { return matches.get(0).getComponentInfo().packageName; @@ -2591,7 +2590,7 @@ public class PackageManagerService extends IPackageManager.Stub { private @NonNull ComponentName getIntentFilterVerifierComponentNameLPr() { final Intent intent = new Intent(Intent.ACTION_INTENT_FILTER_NEEDS_VERIFICATION); - final List<ResolveInfo> matches = queryIntentReceivers(intent, PACKAGE_MIME_TYPE, + final List<ResolveInfo> matches = queryIntentReceiversInternal(intent, PACKAGE_MIME_TYPE, MATCH_SYSTEM_ONLY | MATCH_ENCRYPTION_AWARE_AND_UNAWARE, UserHandle.USER_SYSTEM); ResolveInfo best = null; final int N = matches.size(); @@ -2626,7 +2625,7 @@ public class PackageManagerService extends IPackageManager.Stub { } final Intent resolverIntent = new Intent(Intent.ACTION_RESOLVE_EPHEMERAL_PACKAGE); - final List<ResolveInfo> resolvers = queryIntentServices(resolverIntent, null, + final List<ResolveInfo> resolvers = queryIntentServicesInternal(resolverIntent, null, MATCH_SYSTEM_ONLY | MATCH_ENCRYPTION_AWARE_AND_UNAWARE, UserHandle.USER_SYSTEM); final int N = resolvers.size(); @@ -2671,7 +2670,7 @@ public class PackageManagerService extends IPackageManager.Stub { intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setDataAndType(Uri.fromFile(new File("foo.apk")), PACKAGE_MIME_TYPE); - final List<ResolveInfo> matches = queryIntentActivities(intent, PACKAGE_MIME_TYPE, + final List<ResolveInfo> matches = queryIntentActivitiesInternal(intent, PACKAGE_MIME_TYPE, MATCH_SYSTEM_ONLY | MATCH_ENCRYPTION_AWARE_AND_UNAWARE, UserHandle.USER_SYSTEM); if (matches.size() == 0) { return null; @@ -2766,7 +2765,7 @@ public class PackageManagerService extends IPackageManager.Stub { private List<String> resolveAllBrowserApps(int userId) { // Resolve the canonical browser intent and check that the handleAllWebDataURI boolean is set - List<ResolveInfo> list = queryIntentActivities(sBrowserIntent, null, + List<ResolveInfo> list = queryIntentActivitiesInternal(sBrowserIntent, null, PackageManager.MATCH_ALL, userId); final int count = list.size(); @@ -2786,7 +2785,7 @@ public class PackageManagerService extends IPackageManager.Stub { } private boolean packageIsBrowser(String packageName, int userId) { - List<ResolveInfo> list = queryIntentActivities(sBrowserIntent, null, + List<ResolveInfo> list = queryIntentActivitiesInternal(sBrowserIntent, null, PackageManager.MATCH_ALL, userId); final int N = list.size(); for (int i = 0; i < N; i++) { @@ -3035,9 +3034,15 @@ public class PackageManagerService extends IPackageManager.Stub { } @Override - public List<PermissionInfo> queryPermissionsByGroup(String group, int flags) { + public @Nullable ParceledListSlice<PermissionInfo> queryPermissionsByGroup(String group, + int flags) { // reader synchronized (mPackages) { + if (group != null && !mPermissionGroups.containsKey(group)) { + // This is thrown as NameNotFoundException + return null; + } + ArrayList<PermissionInfo> out = new ArrayList<PermissionInfo>(10); for (BasePermission p : mSettings.mPermissions.values()) { if (group == null) { @@ -3050,11 +3055,7 @@ public class PackageManagerService extends IPackageManager.Stub { } } } - - if (out.size() > 0) { - return out; - } - return mPermissionGroups.containsKey(group) ? out : null; + return new ParceledListSlice<>(out); } } @@ -3068,7 +3069,7 @@ public class PackageManagerService extends IPackageManager.Stub { } @Override - public List<PermissionGroupInfo> getAllPermissionGroups(int flags) { + public @NonNull ParceledListSlice<PermissionGroupInfo> getAllPermissionGroups(int flags) { // reader synchronized (mPackages) { final int N = mPermissionGroups.size(); @@ -3077,7 +3078,7 @@ public class PackageManagerService extends IPackageManager.Stub { for (PackageParser.PermissionGroup pg : mPermissionGroups.values()) { out.add(PackageParser.generatePermissionGroupInfo(pg, flags)); } - return out; + return new ParceledListSlice<>(out); } } @@ -3475,22 +3476,17 @@ public class PackageManagerService extends IPackageManager.Stub { } @Override - public FeatureInfo[] getSystemAvailableFeatures() { - Collection<FeatureInfo> featSet; + public @NonNull ParceledListSlice<FeatureInfo> getSystemAvailableFeatures() { synchronized (mPackages) { - featSet = mAvailableFeatures.values(); - int size = featSet.size(); - if (size > 0) { - FeatureInfo[] features = new FeatureInfo[size+1]; - featSet.toArray(features); - FeatureInfo fi = new FeatureInfo(); - fi.reqGlEsVersion = SystemProperties.getInt("ro.opengles.version", - FeatureInfo.GL_ES_VERSION_UNDEFINED); - features[size] = fi; - return features; - } + final ArrayList<FeatureInfo> res = new ArrayList<>(mAvailableFeatures.values()); + + final FeatureInfo fi = new FeatureInfo(); + fi.reqGlEsVersion = SystemProperties.getInt("ro.opengles.version", + FeatureInfo.GL_ES_VERSION_UNDEFINED); + res.add(fi); + + return new ParceledListSlice<>(res); } - return null; } @Override @@ -4570,7 +4566,8 @@ public class PackageManagerService extends IPackageManager.Stub { flags = updateFlagsForResolve(flags, userId, intent); enforceCrossUserPermission(Binder.getCallingUid(), userId, false /* requireFullPermission */, false /* checkShell */, "resolve intent"); - List<ResolveInfo> query = queryIntentActivities(intent, resolvedType, flags, userId); + final List<ResolveInfo> query = queryIntentActivitiesInternal(intent, resolvedType, flags, + userId); final ResolveInfo bestChoice = chooseBestActivity(intent, resolvedType, flags, query, userId); @@ -4602,7 +4599,8 @@ public class PackageManagerService extends IPackageManager.Stub { filter.dump(new PrintStreamPrinter(System.out), " "); } intent.setComponent(null); - List<ResolveInfo> query = queryIntentActivities(intent, resolvedType, flags, userId); + final List<ResolveInfo> query = queryIntentActivitiesInternal(intent, resolvedType, flags, + userId); // Find any earlier preferred or last chosen entries and nuke them findPreferredActivity(intent, resolvedType, flags, query, 0, false, true, false, userId); @@ -4615,7 +4613,8 @@ public class PackageManagerService extends IPackageManager.Stub { public ResolveInfo getLastChosenActivity(Intent intent, String resolvedType, int flags) { final int userId = UserHandle.getCallingUserId(); if (DEBUG_PREFERRED) Log.v(TAG, "Querying last chosen activity for " + intent); - List<ResolveInfo> query = queryIntentActivities(intent, resolvedType, flags, userId); + final List<ResolveInfo> query = queryIntentActivitiesInternal(intent, resolvedType, flags, + userId); return findPreferredActivity(intent, resolvedType, flags, query, 0, false, false, false, userId); } @@ -5026,7 +5025,13 @@ public class PackageManagerService extends IPackageManager.Stub { } @Override - public List<ResolveInfo> queryIntentActivities(Intent intent, + public @NonNull ParceledListSlice<ResolveInfo> queryIntentActivities(Intent intent, + String resolvedType, int flags, int userId) { + return new ParceledListSlice<>( + queryIntentActivitiesInternal(intent, resolvedType, flags, userId)); + } + + private @NonNull List<ResolveInfo> queryIntentActivitiesInternal(Intent intent, String resolvedType, int flags, int userId) { if (!sUserManager.exists(userId)) return Collections.emptyList(); flags = updateFlagsForResolve(flags, userId, intent); @@ -5517,7 +5522,14 @@ public class PackageManagerService extends IPackageManager.Stub { } @Override - public List<ResolveInfo> queryIntentActivityOptions(ComponentName caller, + public @NonNull ParceledListSlice<ResolveInfo> queryIntentActivityOptions(ComponentName caller, + Intent[] specifics, String[] specificTypes, Intent intent, + String resolvedType, int flags, int userId) { + return new ParceledListSlice<>(queryIntentActivityOptionsInternal(caller, specifics, + specificTypes, intent, resolvedType, flags, userId)); + } + + private @NonNull List<ResolveInfo> queryIntentActivityOptionsInternal(ComponentName caller, Intent[] specifics, String[] specificTypes, Intent intent, String resolvedType, int flags, int userId) { if (!sUserManager.exists(userId)) return Collections.emptyList(); @@ -5527,7 +5539,7 @@ public class PackageManagerService extends IPackageManager.Stub { "query intent activity options"); final String resultsAction = intent.getAction(); - List<ResolveInfo> results = queryIntentActivities(intent, resolvedType, flags + final List<ResolveInfo> results = queryIntentActivitiesInternal(intent, resolvedType, flags | PackageManager.GET_RESOLVED_FILTER, userId); if (DEBUG_INTENT_MATCHING) { @@ -5692,8 +5704,14 @@ public class PackageManagerService extends IPackageManager.Stub { } @Override - public List<ResolveInfo> queryIntentReceivers(Intent intent, String resolvedType, int flags, - int userId) { + public @NonNull ParceledListSlice<ResolveInfo> queryIntentReceivers(Intent intent, + String resolvedType, int flags, int userId) { + return new ParceledListSlice<>( + queryIntentReceiversInternal(intent, resolvedType, flags, userId)); + } + + private @NonNull List<ResolveInfo> queryIntentReceiversInternal(Intent intent, + String resolvedType, int flags, int userId) { if (!sUserManager.exists(userId)) return Collections.emptyList(); flags = updateFlagsForResolve(flags, userId, intent); ComponentName comp = intent.getComponent(); @@ -5725,7 +5743,7 @@ public class PackageManagerService extends IPackageManager.Stub { return mReceivers.queryIntentForPackage(intent, resolvedType, flags, pkg.receivers, userId); } - return null; + return Collections.emptyList(); } } @@ -5733,7 +5751,7 @@ public class PackageManagerService extends IPackageManager.Stub { public ResolveInfo resolveService(Intent intent, String resolvedType, int flags, int userId) { if (!sUserManager.exists(userId)) return null; flags = updateFlagsForResolve(flags, userId, intent); - List<ResolveInfo> query = queryIntentServices(intent, resolvedType, flags, userId); + List<ResolveInfo> query = queryIntentServicesInternal(intent, resolvedType, flags, userId); if (query != null) { if (query.size() >= 1) { // If there is more than one service with the same priority, @@ -5745,8 +5763,14 @@ public class PackageManagerService extends IPackageManager.Stub { } @Override - public List<ResolveInfo> queryIntentServices(Intent intent, String resolvedType, int flags, - int userId) { + public @NonNull ParceledListSlice<ResolveInfo> queryIntentServices(Intent intent, + String resolvedType, int flags, int userId) { + return new ParceledListSlice<>( + queryIntentServicesInternal(intent, resolvedType, flags, userId)); + } + + private @NonNull List<ResolveInfo> queryIntentServicesInternal(Intent intent, + String resolvedType, int flags, int userId) { if (!sUserManager.exists(userId)) return Collections.emptyList(); flags = updateFlagsForResolve(flags, userId, intent); ComponentName comp = intent.getComponent(); @@ -5778,12 +5802,18 @@ public class PackageManagerService extends IPackageManager.Stub { return mServices.queryIntentForPackage(intent, resolvedType, flags, pkg.services, userId); } - return null; + return Collections.emptyList(); } } @Override - public List<ResolveInfo> queryIntentContentProviders( + public @NonNull ParceledListSlice<ResolveInfo> queryIntentContentProviders(Intent intent, + String resolvedType, int flags, int userId) { + return new ParceledListSlice<>( + queryIntentContentProvidersInternal(intent, resolvedType, flags, userId)); + } + + private @NonNull List<ResolveInfo> queryIntentContentProvidersInternal( Intent intent, String resolvedType, int flags, int userId) { if (!sUserManager.exists(userId)) return Collections.emptyList(); flags = updateFlagsForResolve(flags, userId, intent); @@ -5816,7 +5846,7 @@ public class PackageManagerService extends IPackageManager.Stub { return mProviders.queryIntentForPackage( intent, resolvedType, flags, pkg.providers, userId); } - return null; + return Collections.emptyList(); } } @@ -6072,7 +6102,12 @@ public class PackageManagerService extends IPackageManager.Stub { && UserHandle.getAppId(Binder.getCallingUid()) == pkg.applicationInfo.uid; } - public List<ApplicationInfo> getPersistentApplications(int flags) { + @Override + public @NonNull ParceledListSlice<ApplicationInfo> getPersistentApplications(int flags) { + return new ParceledListSlice<>(getPersistentApplicationsInternal(flags)); + } + + private @NonNull List<ApplicationInfo> getPersistentApplicationsInternal(int flags) { final ArrayList<ApplicationInfo> finalList = new ArrayList<ApplicationInfo>(); // reader @@ -6154,11 +6189,11 @@ public class PackageManagerService extends IPackageManager.Stub { } @Override - public ParceledListSlice<ProviderInfo> queryContentProviders(String processName, + public @NonNull ParceledListSlice<ProviderInfo> queryContentProviders(String processName, int uid, int flags) { final int userId = processName != null ? UserHandle.getUserId(uid) : UserHandle.getCallingUserId(); - if (!sUserManager.exists(userId)) return null; + if (!sUserManager.exists(userId)) return ParceledListSlice.emptyList(); flags = updateFlagsForComponent(flags, userId, processName); ArrayList<ProviderInfo> finalList = null; @@ -6190,7 +6225,7 @@ public class PackageManagerService extends IPackageManager.Stub { return new ParceledListSlice<ProviderInfo>(finalList); } - return null; + return ParceledListSlice.emptyList(); } @Override @@ -6203,10 +6238,14 @@ public class PackageManagerService extends IPackageManager.Stub { } @Override - public List<InstrumentationInfo> queryInstrumentation(String targetPackage, + public @NonNull ParceledListSlice<InstrumentationInfo> queryInstrumentation( + String targetPackage, int flags) { + return new ParceledListSlice<>(queryInstrumentationInternal(targetPackage, flags)); + } + + private @NonNull List<InstrumentationInfo> queryInstrumentationInternal(String targetPackage, int flags) { - ArrayList<InstrumentationInfo> finalList = - new ArrayList<InstrumentationInfo>(); + ArrayList<InstrumentationInfo> finalList = new ArrayList<InstrumentationInfo>(); // reader synchronized (mPackages) { @@ -11081,21 +11120,22 @@ public class PackageManagerService extends IPackageManager.Stub { } @Override - public List<IntentFilterVerificationInfo> getIntentFilterVerifications(String packageName) { + public @NonNull ParceledListSlice<IntentFilterVerificationInfo> getIntentFilterVerifications( + String packageName) { synchronized (mPackages) { - return mSettings.getIntentFilterVerificationsLPr(packageName); + return new ParceledListSlice<>(mSettings.getIntentFilterVerificationsLPr(packageName)); } } @Override - public List<IntentFilter> getAllIntentFilters(String packageName) { + public @NonNull ParceledListSlice<IntentFilter> getAllIntentFilters(String packageName) { if (TextUtils.isEmpty(packageName)) { - return Collections.<IntentFilter>emptyList(); + return ParceledListSlice.emptyList(); } synchronized (mPackages) { PackageParser.Package pkg = mPackages.get(packageName); if (pkg == null || pkg.activities == null) { - return Collections.<IntentFilter>emptyList(); + return ParceledListSlice.emptyList(); } final int count = pkg.activities.size(); ArrayList<IntentFilter> result = new ArrayList<>(); @@ -11105,7 +11145,7 @@ public class PackageManagerService extends IPackageManager.Stub { result.addAll(activity.intents); } } - return result; + return new ParceledListSlice<>(result); } } @@ -11831,7 +11871,7 @@ public class PackageManagerService extends IPackageManager.Stub { verification.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); // Query all live verifiers based on current user state - final List<ResolveInfo> receivers = queryIntentReceivers(verification, + final List<ResolveInfo> receivers = queryIntentReceiversInternal(verification, PACKAGE_MIME_TYPE, 0, verifierUser.getIdentifier()); if (DEBUG_VERIFY) { @@ -15523,22 +15563,6 @@ public class PackageManagerService extends IPackageManager.Stub { return true; } - - @Override - public void addPackageToPreferred(String packageName) { - Slog.w(TAG, "addPackageToPreferred: this is now a no-op"); - } - - @Override - public void removePackageFromPreferred(String packageName) { - Slog.w(TAG, "removePackageFromPreferred: this is now a no-op"); - } - - @Override - public List<PackageInfo> getPreferredPackages(int flags) { - return new ArrayList<PackageInfo>(); - } - private int getUidTargetSdkVersionLockedLPr(int uid) { Object obj = mSettings.getUserIdLPr(uid); if (obj instanceof SharedUserSetting) { @@ -16391,7 +16415,7 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName()); intent.addCategory(Intent.CATEGORY_HOME); final int callingUserId = UserHandle.getCallingUserId(); - List<ResolveInfo> list = queryIntentActivities(intent, null, + List<ResolveInfo> list = queryIntentActivitiesInternal(intent, null, PackageManager.GET_META_DATA, callingUserId); ResolveInfo preferred = findPreferredActivity(intent, null, 0, list, 0, true, false, false, callingUserId); @@ -17387,8 +17411,9 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName()); } private String dumpDomainString(String packageName) { - List<IntentFilterVerificationInfo> iviList = getIntentFilterVerifications(packageName); - List<IntentFilter> filters = getAllIntentFilters(packageName); + List<IntentFilterVerificationInfo> iviList = getIntentFilterVerifications(packageName) + .getList(); + List<IntentFilter> filters = getAllIntentFilters(packageName).getList(); ArraySet<String> result = new ArraySet<>(); if (iviList.size() > 0) { diff --git a/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java b/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java index a3ac514ccd22..f79d6eeefbd3 100644 --- a/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java +++ b/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java @@ -16,13 +16,15 @@ package com.android.server.pm; +import static com.android.server.pm.PackageManagerService.DEBUG_DEXOPT; +import static com.android.server.pm.PackageManagerService.TAG; + import android.app.AppGlobals; import android.content.Intent; import android.content.pm.PackageParser; -import android.content.pm.PackageParser.Package; import android.content.pm.ResolveInfo; -import android.os.UserHandle; import android.os.RemoteException; +import android.os.UserHandle; import android.util.ArraySet; import android.util.Log; @@ -35,9 +37,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; -import static com.android.server.pm.PackageManagerService.DEBUG_DEXOPT; -import static com.android.server.pm.PackageManagerService.TAG; - /** * Class containing helper methods for the PackageManagerService. * @@ -49,7 +48,8 @@ public class PackageManagerServiceUtils { private static ArraySet<String> getPackageNamesForIntent(Intent intent, int userId) { List<ResolveInfo> ris = null; try { - ris = AppGlobals.getPackageManager().queryIntentReceivers(intent, null, 0, userId); + ris = AppGlobals.getPackageManager().queryIntentReceivers(intent, null, 0, userId) + .getList(); } catch (RemoteException e) { } ArraySet<String> pkgNames = new ArraySet<String>(); diff --git a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java index abee007f1c8a..ccbd8235a0d0 100644 --- a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java +++ b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java @@ -317,11 +317,7 @@ class PackageManagerShellCommand extends ShellCommand { private int runListFeatures() throws RemoteException { final PrintWriter pw = getOutPrintWriter(); - final List<FeatureInfo> list = new ArrayList<FeatureInfo>(); - final FeatureInfo[] rawList = mInterface.getSystemAvailableFeatures(); - for (int i=0; i<rawList.length; i++) { - list.add(rawList[i]); - } + final List<FeatureInfo> list = mInterface.getSystemAvailableFeatures().getList(); // sort by name Collections.sort(list, new Comparator<FeatureInfo>() { @@ -380,7 +376,7 @@ class PackageManagerShellCommand extends ShellCommand { } final List<InstrumentationInfo> list = - mInterface.queryInstrumentation(targetPackage, 0 /*flags*/); + mInterface.queryInstrumentation(targetPackage, 0 /*flags*/).getList(); // sort by target package Collections.sort(list, new Comparator<InstrumentationInfo>() { @@ -521,7 +517,7 @@ class PackageManagerShellCommand extends ShellCommand { private int runListPermissionGroups() throws RemoteException { final PrintWriter pw = getOutPrintWriter(); - final List<PermissionGroupInfo> pgs = mInterface.getAllPermissionGroups(0); + final List<PermissionGroupInfo> pgs = mInterface.getAllPermissionGroups(0).getList(); final int count = pgs.size(); for (int p = 0; p < count ; p++) { @@ -568,7 +564,7 @@ class PackageManagerShellCommand extends ShellCommand { final ArrayList<String> groupList = new ArrayList<String>(); if (groups) { final List<PermissionGroupInfo> infos = - mInterface.getAllPermissionGroups(0 /*flags*/); + mInterface.getAllPermissionGroups(0 /*flags*/).getList(); final int count = infos.size(); for (int i = 0; i < count; i++) { groupList.add(infos.get(i).name); @@ -718,7 +714,7 @@ class PackageManagerShellCommand extends ShellCommand { } try { List<ResolveInfo> result = mInterface.queryIntentActivities(intent, null, 0, - mTargetUser); + mTargetUser).getList(); PrintWriter pw = getOutPrintWriter(); if (result == null || result.size() <= 0) { pw.println("No activities found"); @@ -745,7 +741,7 @@ class PackageManagerShellCommand extends ShellCommand { } try { List<ResolveInfo> result = mInterface.queryIntentServices(intent, null, 0, - mTargetUser); + mTargetUser).getList(); PrintWriter pw = getOutPrintWriter(); if (result == null || result.size() <= 0) { pw.println("No services found"); @@ -772,7 +768,7 @@ class PackageManagerShellCommand extends ShellCommand { } try { List<ResolveInfo> result = mInterface.queryIntentReceivers(intent, null, 0, - mTargetUser); + mTargetUser).getList(); PrintWriter pw = getOutPrintWriter(); if (result == null || result.size() <= 0) { pw.println("No receivers found"); @@ -1051,7 +1047,7 @@ class PackageManagerShellCommand extends ShellCommand { prefix = " "; } List<PermissionInfo> ps = - mInterface.queryPermissionsByGroup(groupList.get(i), 0 /*flags*/); + mInterface.queryPermissionsByGroup(groupList.get(i), 0 /*flags*/).getList(); final int count = ps.size(); boolean first = true; for (int p = 0 ; p < count ; p++) { diff --git a/services/core/java/com/android/server/search/Searchables.java b/services/core/java/com/android/server/search/Searchables.java index 0046fbb9a261..6bacdfdafbda 100644 --- a/services/core/java/com/android/server/search/Searchables.java +++ b/services/core/java/com/android/server/search/Searchables.java @@ -410,7 +410,7 @@ public class Searchables { activities = mPm.queryIntentActivities(intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), - flags, mUserId); + flags, mUserId).getList(); } catch (RemoteException re) { // Local call } diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java index a0a971af0030..ccbdad276ef3 100644 --- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java @@ -1317,7 +1317,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub { List<ResolveInfo> ris = mIPackageManager.queryIntentServices(intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), - PackageManager.GET_META_DATA, serviceUserId); + PackageManager.GET_META_DATA, serviceUserId).getList(); for (int i=0; i<ris.size(); i++) { ServiceInfo rsi = ris.get(i).serviceInfo; if (rsi.name.equals(si.name) && diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index deb43314b4f5..d2c7ac9bf5a3 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -7131,7 +7131,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), PackageManager.MATCH_ENCRYPTION_AWARE_AND_UNAWARE, - parentUserId); + parentUserId).getList(); if (VERBOSE_LOG) { Slog.d(LOG_TAG, "Enabling system activities: " + activitiesToEnable); |