diff options
Diffstat (limited to 'src/com/android/launcher3/Utilities.java')
-rw-r--r-- | src/com/android/launcher3/Utilities.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 8ffc471a3..c7ff19f7f 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -63,6 +63,7 @@ import com.android.launcher3.settings.SettingsProvider; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; +import java.util.List; import java.util.Locale; import java.util.Set; import java.util.regex.Matcher; @@ -527,6 +528,29 @@ public final class Utilities { } } + /* + * Finds all system apks which had a broadcast receiver listening to a particular action. + * @param action intent action used to find the apk + * @return a list of pairs of apk package name and the resources. + */ + static List<Pair<String, Resources>> findSystemApks(String action, PackageManager pm) { + final Intent intent = new Intent(action); + List<Pair<String, Resources>> systemApks = new ArrayList<Pair<String, Resources>>(); + for (ResolveInfo info : pm.queryBroadcastReceivers(intent, 0)) { + if (info.activityInfo != null && + (info.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { + final String packageName = info.activityInfo.packageName; + try { + final Resources res = pm.getResourcesForApplication(packageName); + systemApks.add(Pair.create(packageName, res)); + } catch (NameNotFoundException e) { + Log.w(TAG, "Failed to find resources for " + packageName); + } + } + } + return systemApks; + } + /** * Returns a widget with category {@link AppWidgetProviderInfo#WIDGET_CATEGORY_SEARCHBOX} * provided by the same package which is set to be global search activity. |