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

Commit 0c4c18ff authored by Willie Koomson's avatar Willie Koomson
Browse files

Save ShortcutUser before rewriting ShortcutPackageItems

This change modifies ShortcutService.injectSaveUser to save the
ShortcutUser before rewriting ShortcutPackageItems. This way, if
saveUserInternalLocked fails, we avoid deleting the ShortcutPackageItems
(because we won't be able to rewrite them).

Bug: 417712196
Test: Manually tested with repro steps from the bug
Flag: EXEMPT bugfix
Change-Id: I567b4d8efa0610da54dd96c84c038f1fde7b8cf2
parent a34fcae5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1107,13 +1107,13 @@ public class ShortcutService extends IShortcutService.Stub {
                }

                synchronized (mServiceLock) {
                    saveUserInternalLocked(userId, os, /* forBackup= */ false);
                    // Since we are not handling package deletion yet, or any single package
                    // changes, just clean the directory and rewrite all the ShortcutPackageItems.
                    final File root = injectUserDataPath(userId);
                    FileUtils.deleteContents(new File(root, DIRECTORY_PACKAGES));
                    FileUtils.deleteContents(new File(root, DIRECTORY_LAUNCHERS));
                    os = file.startWrite();
                    saveUserInternalLocked(userId, os, /* forBackup= */ false);
                    getUserShortcutsLocked(userId).scheduleSaveAllLaunchersAndPackages();
                }