diff options
author | Remi NGUYEN VAN <reminv@google.com> | 2020-06-03 04:34:58 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-06-03 04:34:58 +0000 |
commit | 9828a54f3df7266af8154f3ae8799fa93a4d371b (patch) | |
tree | 215db2358a1784d5f68ce496f5d614bdeda3047f /src | |
parent | e2fd218f0a602ebdbe1e1ea90a4f5b1e6e7ae4ca (diff) | |
parent | 7afec38351f7c565ea644002a6e80f5c83fcbe45 (diff) |
Merge "Fix venue info notification not displaying" into rvc-dev am: b4167ae242 am: 7afec38351
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/NetworkStack/+/11685294
Change-Id: Ic9cc7e311193d507c7a19e0dcbb23b33c55e7805
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/networkstack/NetworkStackNotifier.java | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/com/android/networkstack/NetworkStackNotifier.java b/src/com/android/networkstack/NetworkStackNotifier.java index a330c70..872834a 100644 --- a/src/com/android/networkstack/NetworkStackNotifier.java +++ b/src/com/android/networkstack/NetworkStackNotifier.java @@ -16,6 +16,8 @@ package com.android.networkstack; +import static android.app.NotificationManager.IMPORTANCE_NONE; + import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; @@ -142,7 +144,19 @@ public class NetworkStackNotifier { resources.getString(title), importance); channel.setDescription(resources.getString(description)); - mNotificationManager.createNotificationChannel(channel); + getNotificationManagerForChannels().createNotificationChannel(channel); + } + + /** + * Get the NotificationManager to use to query channels, as opposed to posting notifications. + * + * Although notifications are posted as USER_ALL, notification channels are always created + * based on the UID calling NotificationManager, regardless of the context UserHandle. + * When querying notification channels, using a USER_ALL context would return no channel: the + * default context (as UserHandle 0 for NetworkStack) must be used. + */ + private NotificationManager getNotificationManagerForChannels() { + return mContext.getSystemService(NotificationManager.class); } /** @@ -284,7 +298,11 @@ public class NetworkStackNotifier { } private boolean isVenueInfoNotificationEnabled() { - return mNotificationManager.getNotificationChannel(CHANNEL_VENUE_INFO) != null; + final NotificationChannel channel = getNotificationManagerForChannels() + .getNotificationChannel(CHANNEL_VENUE_INFO); + if (channel == null) return false; + + return channel.getImportance() != IMPORTANCE_NONE; } private static String getNotificationTag(@NonNull Network network) { |