Merge "Changing LauncherApps to resolve activity by component name" into nyc-dev

This commit is contained in:
Sunny Goyal
2016-04-12 20:55:31 +00:00
committed by Android (Google) Code Review
7 changed files with 16 additions and 23 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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,

View File

@@ -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;
}

View File

@@ -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) {

View File

@@ -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);
}