diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2014-08-06 09:55:36 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2014-08-12 14:13:18 -0700 |
commit | 0fe505bf82a265e51c556d7204976651cde7f55c (patch) | |
tree | 218880b925a9c2abcd4399ce55eb41190f7beb97 /src/com/android/launcher3/Utilities.java | |
parent | e3a55a9f4253e77c770f376c00366774cec2bead (diff) | |
download | android_packages_apps_Trebuchet-0fe505bf82a265e51c556d7204976651cde7f55c.tar.gz android_packages_apps_Trebuchet-0fe505bf82a265e51c556d7204976651cde7f55c.tar.bz2 android_packages_apps_Trebuchet-0fe505bf82a265e51c556d7204976651cde7f55c.zip |
Autoinstalls loading xml
> Launcher checkes for an apk in the system image with a broadcast
receiver for action:
com.android.launcher3.action.LAUNCHER_CUSTOMIZATION
> Default layout is parsed from that apk, which can also contain
icons and string resources used in the layout config
Change-Id: I44fc9e7c3134f525f7b5db29f4e8bb56e17ce445
Diffstat (limited to 'src/com/android/launcher3/Utilities.java')
-rw-r--r-- | src/com/android/launcher3/Utilities.java | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 87c2d7515..60185c658 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -38,8 +38,8 @@ import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.PaintDrawable; import android.os.Build; -import android.util.DisplayMetrics; import android.util.Log; +import android.util.Pair; import android.util.SparseArray; import android.view.View; import android.widget.Toast; @@ -328,9 +328,6 @@ public final class Utilities { private static void initStatics(Context context) { final Resources resources = context.getResources(); - final DisplayMetrics metrics = resources.getDisplayMetrics(); - final float density = metrics.density; - sIconWidth = sIconHeight = (int) resources.getDimension(R.dimen.app_icon_size); sIconTextureWidth = sIconTextureHeight = sIconWidth; } @@ -474,4 +471,26 @@ public final class Utilities { } return bestColor; } + + /* + * Finds a system apk which had a broadcast receiver listening to a particular action. + * @param action intent action used to find the apk + * @return a pair of apk package name and the resources. + */ + static Pair<String, Resources> findSystemApk(String action, PackageManager pm) { + final Intent intent = new Intent(action); + 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); + return Pair.create(packageName, res); + } catch (NameNotFoundException e) { + Log.w(TAG, "Failed to find resources for " + packageName); + } + } + } + return null; + } } |