diff options
| author | 2016-04-12 20:55:31 +0000 | |
|---|---|---|
| committer | 2016-04-12 20:55:32 +0000 | |
| commit | 1fe7dfa66aaf37045c62094438ab3db2ee5403c5 (patch) | |
| tree | 5a7ef367afc3969d410fc91ff4b51bdbce092a1e | |
| parent | 80295544c11cefc058e953090354dc4faa17d3c0 (diff) | |
| parent | 45d3e977487da262a58bbfc5650c99a2d94aba9f (diff) | |
Merge "Changing LauncherApps to resolve activity by component name" into nyc-dev
| -rw-r--r-- | api/current.txt | 1 | ||||
| -rw-r--r-- | api/system-current.txt | 1 | ||||
| -rw-r--r-- | api/test-current.txt | 1 | ||||
| -rw-r--r-- | core/java/android/content/pm/ILauncherApps.aidl | 3 | ||||
| -rw-r--r-- | core/java/android/content/pm/LauncherActivityInfo.java | 14 | ||||
| -rw-r--r-- | core/java/android/content/pm/LauncherApps.java | 13 | ||||
| -rw-r--r-- | services/core/java/com/android/server/pm/LauncherAppsService.java | 6 |
7 files changed, 16 insertions, 23 deletions
diff --git a/api/current.txt b/api/current.txt index bb7b45df59c4..5dfb0053983e 100644 --- a/api/current.txt +++ b/api/current.txt @@ -9497,7 +9497,6 @@ package android.content.pm { public class LauncherApps { method public java.util.List<android.content.pm.LauncherActivityInfo> getActivityList(java.lang.String, android.os.UserHandle); - method public android.content.pm.ApplicationInfo getApplicationInfo(java.lang.String, int, android.os.UserHandle); method public android.os.ParcelFileDescriptor getShortcutIconFd(android.content.pm.ShortcutInfo); method public android.os.ParcelFileDescriptor getShortcutIconFd(java.lang.String, java.lang.String, android.os.UserHandle); method public int getShortcutIconResId(android.content.pm.ShortcutInfo); diff --git a/api/system-current.txt b/api/system-current.txt index c8f6ba7724e4..3febd2915acc 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -9835,7 +9835,6 @@ package android.content.pm { public class LauncherApps { method public java.util.List<android.content.pm.LauncherActivityInfo> getActivityList(java.lang.String, android.os.UserHandle); - method public android.content.pm.ApplicationInfo getApplicationInfo(java.lang.String, int, android.os.UserHandle); method public android.os.ParcelFileDescriptor getShortcutIconFd(android.content.pm.ShortcutInfo); method public android.os.ParcelFileDescriptor getShortcutIconFd(java.lang.String, java.lang.String, android.os.UserHandle); method public int getShortcutIconResId(android.content.pm.ShortcutInfo); diff --git a/api/test-current.txt b/api/test-current.txt index 19d43f260091..7805613d291a 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -9507,7 +9507,6 @@ package android.content.pm { public class LauncherApps { ctor public LauncherApps(android.content.Context); method public java.util.List<android.content.pm.LauncherActivityInfo> getActivityList(java.lang.String, android.os.UserHandle); - method public android.content.pm.ApplicationInfo getApplicationInfo(java.lang.String, int, android.os.UserHandle); method public android.os.ParcelFileDescriptor getShortcutIconFd(android.content.pm.ShortcutInfo); method public android.os.ParcelFileDescriptor getShortcutIconFd(java.lang.String, java.lang.String, android.os.UserHandle); method public int getShortcutIconResId(android.content.pm.ShortcutInfo); diff --git a/core/java/android/content/pm/ILauncherApps.aidl b/core/java/android/content/pm/ILauncherApps.aidl index 46321a4d7027..430c7e706b64 100644 --- a/core/java/android/content/pm/ILauncherApps.aidl +++ b/core/java/android/content/pm/ILauncherApps.aidl @@ -18,6 +18,7 @@ package android.content.pm; import android.content.ComponentName; import android.content.Intent; +import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.IOnAppsChangedListener; import android.content.pm.ParceledListSlice; @@ -37,7 +38,7 @@ interface ILauncherApps { void addOnAppsChangedListener(String callingPackage, in IOnAppsChangedListener listener); void removeOnAppsChangedListener(in IOnAppsChangedListener listener); ParceledListSlice getLauncherActivities(String packageName, in UserHandle user); - ResolveInfo resolveActivity(in Intent intent, in UserHandle user); + ActivityInfo resolveActivity(in ComponentName component, in UserHandle user); void startActivityAsUser(in ComponentName component, in Rect sourceBounds, in Bundle opts, in UserHandle user); void showAppDetailsAsUser(in ComponentName component, in Rect sourceBounds, diff --git a/core/java/android/content/pm/LauncherActivityInfo.java b/core/java/android/content/pm/LauncherActivityInfo.java index 40e1a9f8ba79..2beca7bb6022 100644 --- a/core/java/android/content/pm/LauncherActivityInfo.java +++ b/core/java/android/content/pm/LauncherActivityInfo.java @@ -39,7 +39,6 @@ public class LauncherActivityInfo { private ActivityInfo mActivityInfo; private ComponentName mComponentName; - private ResolveInfo mResolveInfo; private UserHandle mUser; /** @@ -49,11 +48,10 @@ public class LauncherActivityInfo { * @param info ResolveInfo from which to create the LauncherActivityInfo. * @param user The UserHandle of the profile to which this activity belongs. */ - LauncherActivityInfo(Context context, ResolveInfo info, UserHandle user) { + LauncherActivityInfo(Context context, ActivityInfo info, UserHandle user) { this(context); - mResolveInfo = info; - mActivityInfo = info.activityInfo; - mComponentName = LauncherApps.getComponentName(info); + mActivityInfo = info; + mComponentName = new ComponentName(info.packageName, info.name); mUser = user; } @@ -91,7 +89,7 @@ public class LauncherActivityInfo { * @return The label for the activity. */ public CharSequence getLabel() { - return mResolveInfo.loadLabel(mPm); + return mActivityInfo.loadLabel(mPm); } /** @@ -103,7 +101,7 @@ public class LauncherActivityInfo { * @return The drawable associated with the activity. */ public Drawable getIcon(int density) { - final int iconRes = mResolveInfo.getIconResourceInternal(); + final int iconRes = mActivityInfo.getIconResource(); Drawable icon = null; // Get the preferred density icon from the app's resources if (density != 0 && iconRes != 0) { @@ -116,7 +114,7 @@ public class LauncherActivityInfo { } // Get the default density icon if (icon == null) { - icon = mResolveInfo.loadIcon(mPm); + icon = mActivityInfo.loadIcon(mPm); } return icon; } diff --git a/core/java/android/content/pm/LauncherApps.java b/core/java/android/content/pm/LauncherApps.java index a0d2339566a5..7c2d4aac6947 100644 --- a/core/java/android/content/pm/LauncherApps.java +++ b/core/java/android/content/pm/LauncherApps.java @@ -291,7 +291,7 @@ public class LauncherApps { } ArrayList<LauncherActivityInfo> lais = new ArrayList<LauncherActivityInfo>(); for (ResolveInfo ri : activities.getList()) { - LauncherActivityInfo lai = new LauncherActivityInfo(mContext, ri, user); + LauncherActivityInfo lai = new LauncherActivityInfo(mContext, ri.activityInfo, user); if (DEBUG) { Log.v(TAG, "Returning activity for profile " + user + " : " + lai.getComponentName()); @@ -301,10 +301,6 @@ public class LauncherApps { return lais; } - static ComponentName getComponentName(ResolveInfo ri) { - return new ComponentName(ri.activityInfo.packageName, ri.activityInfo.name); - } - /** * Returns the activity info for a given intent and user handle, if it resolves. Otherwise it * returns null. @@ -315,9 +311,9 @@ public class LauncherApps { */ public LauncherActivityInfo resolveActivity(Intent intent, UserHandle user) { try { - ResolveInfo ri = mService.resolveActivity(intent, user); - if (ri != null) { - LauncherActivityInfo info = new LauncherActivityInfo(mContext, ri, user); + ActivityInfo ai = mService.resolveActivity(intent.getComponent(), user); + if (ai != null) { + LauncherActivityInfo info = new LauncherActivityInfo(mContext, ai, user); return info; } } catch (RemoteException re) { @@ -389,6 +385,7 @@ public class LauncherApps { * * @return An {@link ApplicationInfo} containing information about the package or * null of the package isn't found. + * @hide */ public ApplicationInfo getApplicationInfo(String packageName, @ApplicationInfoFlags int flags, UserHandle user) { diff --git a/services/core/java/com/android/server/pm/LauncherAppsService.java b/services/core/java/com/android/server/pm/LauncherAppsService.java index 5ee7cc9ce3f3..43a0b9174f8e 100644 --- a/services/core/java/com/android/server/pm/LauncherAppsService.java +++ b/services/core/java/com/android/server/pm/LauncherAppsService.java @@ -294,7 +294,7 @@ public class LauncherAppsService extends SystemService { } @Override - public ResolveInfo resolveActivity(Intent intent, UserHandle user) + public ActivityInfo resolveActivity(ComponentName component, UserHandle user) throws RemoteException { ensureInUserProfiles(user, "Cannot resolve activity for unrelated profile " + user); if (!isUserEnabled(user)) { @@ -303,11 +303,11 @@ public class LauncherAppsService extends SystemService { long ident = Binder.clearCallingIdentity(); try { - ResolveInfo app = mPm.resolveActivityAsUser(intent, + IPackageManager pm = AppGlobals.getPackageManager(); + return pm.getActivityInfo(component, PackageManager.MATCH_DIRECT_BOOT_AWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, user.getIdentifier()); - return app; } finally { Binder.restoreCallingIdentity(ident); } |