Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dfde999c authored by Sunny Goyal's avatar Sunny Goyal
Browse files

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
parent 111c8357
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -254,7 +254,7 @@ public class AlphabeticalAppsList {
        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;
            }
+12 −10
Original line number Diff line number Diff line
@@ -881,22 +881,22 @@ public class LauncherModel extends BroadcastReceiver
     * 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,13 +904,15 @@ public class LauncherModel extends BroadcastReceiver
            for (ItemInfo item : sBgItemsIdMap) {
                if (item instanceof ShortcutInfo) {
                    ShortcutInfo info = (ShortcutInfo) item;
                    if (intentWithPkg.equals(info.getIntent())
                            || intentWithoutPkg.equals(info.getIntent())) {
                    if (info.getIntent() != null && info.user.equals(user)) {
                        String s = info.getIntent().toUri(0);
                        if (intentWithPkg.equals(s) || intentWithoutPkg.equals(s)) {
                            return true;
                        }
                    }
                }
            }
        }
        return false;
    }