Various managed profile fixes
> When matching existing shortcut, match the uri as intent doesn't implement equals
> Fixing user matching when searching for apps in all-apps
Bug: 20749743
Change-Id: I14f3e2134e774727176e865d74108ef79de874d6
diff --git a/src/com/android/launcher3/AlphabeticalAppsList.java b/src/com/android/launcher3/AlphabeticalAppsList.java
index 2ee5a62..c7ee2e9 100644
--- a/src/com/android/launcher3/AlphabeticalAppsList.java
+++ b/src/com/android/launcher3/AlphabeticalAppsList.java
@@ -254,7 +254,7 @@
int length = apps.size();
for (int i = 0; i < length; ++i) {
AppInfo info = apps.get(i);
- if (info.user.equals(info.user)
+ if (info.user.equals(targetInfo.user)
&& info.intent.getComponent().equals(targetComponent)) {
return i;
}
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 97a2830..9570735 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -881,22 +881,22 @@
* TODO: Throw exception is above condition is not met.
*/
@Thunk static boolean shortcutExists(Context context, Intent intent, UserHandleCompat user) {
- final Intent intentWithPkg, intentWithoutPkg;
+ final String intentWithPkg, intentWithoutPkg;
final String packageName;
if (intent.getComponent() != null) {
// If component is not null, an intent with null package will produce
// the same result and should also be a match.
packageName = intent.getComponent().getPackageName();
if (intent.getPackage() != null) {
- intentWithPkg = intent;
- intentWithoutPkg = new Intent(intent).setPackage(null);
+ intentWithPkg = intent.toUri(0);
+ intentWithoutPkg = new Intent(intent).setPackage(null).toUri(0);
} else {
- intentWithPkg = new Intent(intent).setPackage(packageName);
- intentWithoutPkg = intent;
+ intentWithPkg = new Intent(intent).setPackage(packageName).toUri(0);
+ intentWithoutPkg = intent.toUri(0);
}
} else {
- intentWithPkg = intent;
- intentWithoutPkg = intent;
+ intentWithPkg = intent.toUri(0);
+ intentWithoutPkg = intent.toUri(0);
packageName = intent.getPackage();
}
@@ -904,9 +904,11 @@
for (ItemInfo item : sBgItemsIdMap) {
if (item instanceof ShortcutInfo) {
ShortcutInfo info = (ShortcutInfo) item;
- if (intentWithPkg.equals(info.getIntent())
- || intentWithoutPkg.equals(info.getIntent())) {
- return true;
+ if (info.getIntent() != null && info.user.equals(user)) {
+ String s = info.getIntent().toUri(0);
+ if (intentWithPkg.equals(s) || intentWithoutPkg.equals(s)) {
+ return true;
+ }
}
}
}