diff options
author | Danning Chen <danningc@google.com> | 2020-02-14 11:21:32 -0800 |
---|---|---|
committer | Danning Chen <danningc@google.com> | 2020-02-14 12:20:46 -0800 |
commit | 1cc7197864912c164320a5d80a4c22536ace4044 (patch) | |
tree | d48993cd9d33ac5f44bcf09b4d03b00d90ac5c66 /services/people | |
parent | 7af601e8ed63c0435e3bbfc440bc463f7db8ca6b (diff) |
Cache the shortcut if the user has changed the conversation's notification settings
Change-Id: Ic4125e5fa510e82d13a578f7c7aa03c397b80354
Bug: 146522621
Test: atest com.android.server.people.data.DataManagerTest
Test: atest com.android.server.people.data.ConversationInfoTest
Diffstat (limited to 'services/people')
-rw-r--r-- | services/people/java/com/android/server/people/data/ConversationInfo.java | 8 | ||||
-rw-r--r-- | services/people/java/com/android/server/people/data/DataManager.java | 10 |
2 files changed, 17 insertions, 1 deletions
diff --git a/services/people/java/com/android/server/people/data/ConversationInfo.java b/services/people/java/com/android/server/people/data/ConversationInfo.java index ce353667b62d..859cdf24bc7e 100644 --- a/services/people/java/com/android/server/people/data/ConversationInfo.java +++ b/services/people/java/com/android/server/people/data/ConversationInfo.java @@ -137,6 +137,11 @@ public class ConversationInfo { return hasShortcutFlags(ShortcutInfo.FLAG_LONG_LIVED); } + /** Whether the shortcut for this conversation is cached in Shortcut Service. */ + public boolean isShortcutCached() { + return hasShortcutFlags(ShortcutInfo.FLAG_CACHED); + } + /** Whether this conversation is marked as important by the user. */ public boolean isImportant() { return hasConversationFlags(FLAG_IMPORTANT); @@ -213,6 +218,9 @@ public class ConversationInfo { if (isShortcutLongLived()) { sb.append("Liv"); } + if (isShortcutCached()) { + sb.append("Cac"); + } sb.append("]"); sb.append(", conversationFlags=0x").append(Integer.toHexString(mConversationFlags)); sb.append(" ["); diff --git a/services/people/java/com/android/server/people/data/DataManager.java b/services/people/java/com/android/server/people/data/DataManager.java index 39a26662da4b..dd9cbd00f6a2 100644 --- a/services/people/java/com/android/server/people/data/DataManager.java +++ b/services/people/java/com/android/server/people/data/DataManager.java @@ -696,7 +696,15 @@ public class DataManager { break; } conversationStore.addOrUpdate(builder.build()); - // TODO: Cache the shortcut when a conversation's notification setting is changed. + + if (modificationType == NOTIFICATION_CHANNEL_OR_GROUP_UPDATED + && conversationInfo.isShortcutLongLived() + && !conversationInfo.isShortcutCached()) { + mShortcutServiceInternal.cacheShortcuts(user.getIdentifier(), + mContext.getPackageName(), pkg, + Collections.singletonList(conversationInfo.getShortcutId()), + user.getIdentifier()); + } } } |