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

Commit 2a6cf09b authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Fix issue where sometimes duplicate icons are added on homescreen when

installing a package

Shortcuts placed by the user have no package in their intent.
Ensure that this is accounted for when searching for duplicates.

issue: 12888844

Change-Id: I2fb8b7c2b8f7cb74926904bf49a96aeb59a5a9f8
parent 03f20ba3
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -842,9 +842,26 @@ public class LauncherModel extends BroadcastReceiver
     */
    static boolean shortcutExists(Context context, String title, Intent intent) {
        final ContentResolver cr = context.getContentResolver();
        final Intent intentWithPkg, intentWithoutPkg;

        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.
            if (intent.getPackage() != null) {
                intentWithPkg = intent;
                intentWithoutPkg = new Intent(intent).setPackage(null);
            } else {
                intentWithPkg = new Intent(intent).setPackage(
                        intent.getComponent().getPackageName());
                intentWithoutPkg = intent;
            }
        } else {
            intentWithPkg = intent;
            intentWithoutPkg = intent;
        }
        Cursor c = cr.query(LauncherSettings.Favorites.CONTENT_URI,
            new String[] { "title", "intent" }, "title=? and intent=?",
            new String[] { title, intent.toUri(0) }, null);
            new String[] { "title", "intent" }, "title=? and (intent=? or intent=?)",
            new String[] { title, intentWithPkg.toUri(0), intentWithoutPkg.toUri(0) }, null);
        boolean result = false;
        try {
            result = c.moveToFirst();