From 525a89b21c1e8647eb129b6f576de34090ca96f1 Mon Sep 17 00:00:00 2001 From: Pinyao Ting Date: Mon, 26 Apr 2021 09:50:21 -0700 Subject: [PATCH] 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 --- services/core/java/com/android/server/pm/ShortcutService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/pm/ShortcutService.java b/services/core/java/com/android/server/pm/ShortcutService.java index 007393ab80fbf..678f0466af924 100644 --- a/services/core/java/com/android/server/pm/ShortcutService.java +++ b/services/core/java/com/android/server/pm/ShortcutService.java @@ -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; }