summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Sunny Goyal <sunnygoyal@google.com> 2016-03-31 12:38:17 -0700
committer Sunny Goyal <sunnygoyal@google.com> 2016-04-11 16:02:27 -0700
commit45d3e977487da262a58bbfc5650c99a2d94aba9f (patch)
tree12c002280e717d29017e44848d9c12d1e788bb82
parent6e1e880f001ab3663fba3a7b6d292387efaf7b8f (diff)
Changing LauncherApps to resolve activity by component name
This makes the behavior of resolveActivity similar to isActivityEnabled. Not that starting this activity may still fail due to other reasons. Bug: 27549770 Change-Id: I924d7aa2305c64fd319ca1e38058f9f956c0c256
-rw-r--r--api/current.txt1
-rw-r--r--api/system-current.txt1
-rw-r--r--api/test-current.txt1
-rw-r--r--core/java/android/content/pm/ILauncherApps.aidl3
-rw-r--r--core/java/android/content/pm/LauncherActivityInfo.java14
-rw-r--r--core/java/android/content/pm/LauncherApps.java13
-rw-r--r--services/core/java/com/android/server/pm/LauncherAppsService.java6
7 files changed, 16 insertions, 23 deletions
diff --git a/api/current.txt b/api/current.txt
index 732c50080623..b6f60f9f5639 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 56b2f581bb82..1871b258ae38 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 e837cd06aa35..f2a321de88e4 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -9506,7 +9506,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/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 abe1aaf96c36..342dbe2303e0 100644
--- a/core/java/android/content/pm/LauncherApps.java
+++ b/core/java/android/content/pm/LauncherApps.java
@@ -282,7 +282,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());
@@ -292,10 +292,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.
@@ -306,9 +302,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) {
@@ -380,6 +376,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 79d9c869d2b4..f4b60acba947 100644
--- a/services/core/java/com/android/server/pm/LauncherAppsService.java
+++ b/services/core/java/com/android/server/pm/LauncherAppsService.java
@@ -293,7 +293,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)) {
@@ -302,11 +302,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);
}