Fixes a potential error in setDynamicShortcut

In the current implementation, ret.complete will still be called after
ret.completeExceptionally is called. Although the second call doesn't do
anything right now since the implementation of AndroidFuture ignores
consecutive attempts at calling complete on an already completed future,
it is better to avoid these kind of behaviors in the first place.

Bug: 186237458
Test: manual
Change-Id: I65e44c28ded947d499ba74aafd9a2686f02a9f18
This commit is contained in:
Pinyao Ting
2021-04-26 09:50:21 -07:00
parent 00475ff23d
commit 525a89b21c

View File

@@ -1992,10 +1992,11 @@ public class ShortcutService extends IShortcutService.Stub {
packageShortcutsChanged(packageName, userId, changedShortcuts, removedShortcuts);
verifyStates();
ret.complete(true);
} catch (Exception e) {
ret.completeExceptionally(e);
}
ret.complete(true);
});
return ret;
}