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

Commit 79848abf authored by Doris Ling's avatar Doris Ling
Browse files

Only update mutable shortcuts.

When trying to update the flags for the existing shortcuts, check and
skip the immutable shortcuts, since they should not be modified.

Change-Id: Iee70ed92f45c1b0b0f0c5b902069c017acfa4990
Fixes: 119119713
Test: make RunSettingsRoboTests
parent 4fa2b885
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -128,6 +128,9 @@ public class SettingsInitialize extends BroadcastReceiver {
        final List<ShortcutInfo> pinnedShortcuts = shortcutManager.getPinnedShortcuts();
        final List<ShortcutInfo> updates = new ArrayList<>();
        for (ShortcutInfo info : pinnedShortcuts) {
            if (info.isImmutable()) {
                continue;
            }
            final Intent shortcutIntent = info.getIntent();
            shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
            final ShortcutInfo updatedInfo = new ShortcutInfo.Builder(context, info.getId())
+19 −0
Original line number Diff line number Diff line
@@ -78,4 +78,23 @@ public class SettingsInitializeTest {
        assertThat(flags & Intent.FLAG_ACTIVITY_CLEAR_TOP).isEqualTo(
                Intent.FLAG_ACTIVITY_CLEAR_TOP);
    }

    @Test
    public void refreshExistingShortcuts_shouldNotUpdateImmutableShortcut() {
        final String id = "test_shortcut_id";
        final ShortcutInfo info = new ShortcutInfo.Builder(mContext, id)
            .setShortLabel("test123")
            .setIntent(new Intent(Intent.ACTION_DEFAULT))
            .build();
        info.addFlags(ShortcutInfo.FLAG_IMMUTABLE);
        final List<ShortcutInfo> shortcuts = new ArrayList<>();
        shortcuts.add(info);
        ShadowShortcutManager.get().setPinnedShortcuts(shortcuts);

        mSettingsInitialize.refreshExistingShortcuts(mContext);

        final List<ShortcutInfo> updatedShortcuts =
            ShadowShortcutManager.get().getLastUpdatedShortcuts();
        assertThat(updatedShortcuts).isEmpty();
    }
}