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

Commit bd088c42 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Only update mutable shortcuts."

parents 5e568343 79848abf
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();
    }
}