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 a594fd9f9..1e8bc2f73 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -50,6 +50,7 @@ import android.view.View; import android.widget.Toast; import java.util.ArrayList; +import java.util.List; /** * Various utilities shared amongst the Launcher's classes. @@ -561,6 +562,29 @@ public final class Utilities { return null; } + /* + * 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; + } + public static float convertDpToPixel(float dp, Context context){ Resources resources = context.getResources(); DisplayMetrics metrics = resources.getDisplayMetrics(); |