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

Skip to content
Commit 90894566 authored by Pinyao Ting's avatar Pinyao Ting
Browse files

AppSearch as persistent layer for shortcut

Currently shortcuts are persisted into xml file upon creation/update.
This CL additionally writes those shortcuts into AppSearch.

Shortcuts persisted in AppSearch will only be removed when its publisher
calls setDynamicShortcuts/disableShortcuts or one of the removal api.
Shortcuts won't get removed as a result of exceeding the limit defined
in getMaxShortcutCountPerActivity().

- setDynamicShortcuts:
1. Turn all dynamic shortcuts in memory into floating shortcuts.
2. Remove orphaned shortcuts (floating shotcuts that are neither cached
nor pinned).
3. Add given shortcuts into memory.
4. Remove all shortcuts from AppSearch in background thread.
5. Schedule a job that writes shortcuts from memory into AppSearch in a
background thread.

- addDynamicShortcuts/updateShortcuts:
1. Add or update shortcuts in memory.
2. Schedule a job that writes shortcuts from memory into AppSearch in a
background thread.

- remove APIs:
1. Removes shortcuts from the system ram synchronously.
2. Removes shortcuts from AppSearch in a background thread.

- reportShortcutUsed:
1. Generates an Usage Event that gets propagated to UsageEventManager.
2. Reports document usage in AppSearch in a background thread.

- applyRestore:
1. Parses backup payload and load shortcuts into memory.
2. Persists shortcuts in memory into xml.
3. Schedule a job that writes shortcuts from memory into AppSearch in a
background thread.

- disableShortcuts
1. Turn correponding dynamic shortcuts in memory into floating shortcuts.
2. Remove orphaned shortcuts (floating shortcuts that are neither cached
nor pinned).
3. If any of the shortcuts are removed as a result of step 2, removes
corresponding shortcuts from AppSearch in a background thread.

- enableShortcuts
1. Given the list of shortcutIds, if there exists a matching floating
shortcut, that floating shortcut will be converted into dynamic shortcut
again. Otherwise the shortcutId is ignored.
2. Since this API only mutates in-memory state of a shortcut that is not
persisted into AppSearch, there will be no behavioral change here.

- requestPinShortcuts:
This api mutates in-memory states of a shortcut, these states are not
persisted in AppSearch, thus there will be no behavioral change.

Bug: 151359749
Test: manually enable feature flag and run ShortcutManagerTest12
Test: atest ShortcutManagerTest1 ShortcutManagerTest2
    ShortcutManagerTest3 ShortcutManagerTest4 ShortcutManagerTest5
    ShortcutManagerTest6 ShortcutManagerTest7 ShortcutManagerTest8
    ShortcutManagerTest9 ShortcutManagerTest10 ShortcutManagerTest11
    ShortcutManagerTest12
Test: atest CtsShortcutManagerTestCases

Change-Id: Ibc06fa705cb65c220c4991a1b0247c1a4f318fed
parent 1f6d59c5
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment