Joe Onorato | 503007d | 2010-04-16 09:20:55 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Joe Onorato | 79de0c5 | 2010-05-26 17:03:26 -0400 | [diff] [blame] | 17 | package com.android.systemui.statusbar; |
Joe Onorato | 503007d | 2010-04-16 09:20:55 -0700 | [diff] [blame] | 18 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 19 | import android.app.Notification; |
Chris Wren | 3ad4e3a | 2014-09-02 17:23:51 -0400 | [diff] [blame] | 20 | import android.service.notification.NotificationListenerService; |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 21 | import android.service.notification.NotificationListenerService.Ranking; |
Christoph Studer | d0694b6 | 2014-06-04 16:36:01 +0200 | [diff] [blame] | 22 | import android.service.notification.NotificationListenerService.RankingMap; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 23 | import android.service.notification.StatusBarNotification; |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 24 | import android.util.ArrayMap; |
Joe Onorato | e345fff | 2010-05-23 15:18:27 -0400 | [diff] [blame] | 25 | import android.view.View; |
Joe Onorato | 503007d | 2010-04-16 09:20:55 -0700 | [diff] [blame] | 26 | |
Selim Cinek | 25fd4e2b | 2015-02-20 17:46:07 +0100 | [diff] [blame] | 27 | import com.android.systemui.statusbar.phone.NotificationGroupManager; |
| 28 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 29 | import java.io.PrintWriter; |
Joe Onorato | e345fff | 2010-05-23 15:18:27 -0400 | [diff] [blame] | 30 | import java.util.ArrayList; |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 31 | import java.util.Collections; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 32 | import java.util.Comparator; |
Joe Onorato | e345fff | 2010-05-23 15:18:27 -0400 | [diff] [blame] | 33 | |
| 34 | /** |
| 35 | * The list of currently displaying notifications. |
| 36 | */ |
Joe Onorato | 503007d | 2010-04-16 09:20:55 -0700 | [diff] [blame] | 37 | public class NotificationData { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 38 | |
| 39 | private final Environment mEnvironment; |
| 40 | |
Joe Onorato | e345fff | 2010-05-23 15:18:27 -0400 | [diff] [blame] | 41 | public static final class Entry { |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 42 | public String key; |
Joe Onorato | e345fff | 2010-05-23 15:18:27 -0400 | [diff] [blame] | 43 | public StatusBarNotification notification; |
Joe Onorato | 66b4c5b | 2010-05-23 15:39:40 -0400 | [diff] [blame] | 44 | public StatusBarIconView icon; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 45 | public ExpandableNotificationRow row; // the outer expanded view |
Joe Onorato | 9c1d823 | 2010-05-24 20:02:53 -0400 | [diff] [blame] | 46 | public View expanded; // the inflated RemoteViews |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 47 | public View expandedPublic; // for insecure lockscreens |
Dan Sandler | 842dd77 | 2014-05-15 09:36:47 -0400 | [diff] [blame] | 48 | public View expandedBig; |
Chris Wren | f0048ce | 2013-08-07 16:43:43 -0400 | [diff] [blame] | 49 | private boolean interruption; |
Jorim Jaggi | 36b1523 | 2014-06-10 17:24:20 +0200 | [diff] [blame] | 50 | public boolean autoRedacted; // whether the redacted notification was generated by us |
| 51 | public boolean legacy; // whether the notification has a legacy, dark background |
Jorim Jaggi | a1eeade | 2014-09-08 22:34:39 +0200 | [diff] [blame] | 52 | public int targetSdk; |
Jorim Jaggi | 36b1523 | 2014-06-10 17:24:20 +0200 | [diff] [blame] | 53 | |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 54 | public Entry(StatusBarNotification n, StatusBarIconView ic) { |
| 55 | this.key = n.getKey(); |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 56 | this.notification = n; |
| 57 | this.icon = ic; |
| 58 | } |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 59 | public void setBigContentView(View bigContentView) { |
| 60 | this.expandedBig = bigContentView; |
Chris Wren | 51c7510 | 2013-07-16 20:49:17 -0400 | [diff] [blame] | 61 | row.setExpandable(bigContentView != null); |
Chris Wren | 8fd1265 | 2012-05-09 21:25:57 -0400 | [diff] [blame] | 62 | } |
Chris Wren | 574a55e | 2013-07-15 18:48:37 -0400 | [diff] [blame] | 63 | public View getBigContentView() { |
| 64 | return expandedBig; |
Chris Wren | 8fd1265 | 2012-05-09 21:25:57 -0400 | [diff] [blame] | 65 | } |
Dan Sandler | a5e0f41 | 2014-01-23 15:11:54 -0500 | [diff] [blame] | 66 | public View getPublicContentView() { return expandedPublic; } |
Chris Wren | f0048ce | 2013-08-07 16:43:43 -0400 | [diff] [blame] | 67 | |
| 68 | public void setInterruption() { |
| 69 | interruption = true; |
| 70 | } |
Chris Wren | d04f6ce | 2014-06-11 17:37:28 -0400 | [diff] [blame] | 71 | |
| 72 | public boolean hasInterrupted() { |
| 73 | return interruption; |
| 74 | } |
Christoph Studer | 22f2ee5 | 2014-07-29 22:57:21 +0200 | [diff] [blame] | 75 | |
| 76 | /** |
| 77 | * Resets the notification entry to be re-used. |
| 78 | */ |
| 79 | public void reset() { |
| 80 | // NOTE: Icon needs to be preserved for now. |
| 81 | // We should fix this at some point. |
| 82 | expanded = null; |
| 83 | expandedPublic = null; |
| 84 | expandedBig = null; |
| 85 | autoRedacted = false; |
| 86 | legacy = false; |
| 87 | if (row != null) { |
| 88 | row.reset(); |
| 89 | } |
| 90 | } |
Joe Onorato | e345fff | 2010-05-23 15:18:27 -0400 | [diff] [blame] | 91 | } |
Christoph Studer | 71f18fd | 2014-05-20 17:02:04 +0200 | [diff] [blame] | 92 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 93 | private final ArrayMap<String, Entry> mEntries = new ArrayMap<>(); |
| 94 | private final ArrayList<Entry> mSortedAndFiltered = new ArrayList<>(); |
Selim Cinek | 25fd4e2b | 2015-02-20 17:46:07 +0100 | [diff] [blame] | 95 | |
| 96 | private NotificationGroupManager mGroupManager; |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 97 | |
Christoph Studer | 1d599da | 2014-06-12 15:25:59 +0200 | [diff] [blame] | 98 | private RankingMap mRankingMap; |
| 99 | private final Ranking mTmpRanking = new Ranking(); |
Selim Cinek | 25fd4e2b | 2015-02-20 17:46:07 +0100 | [diff] [blame] | 100 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 101 | private final Comparator<Entry> mRankingComparator = new Comparator<Entry>() { |
Christoph Studer | 1d599da | 2014-06-12 15:25:59 +0200 | [diff] [blame] | 102 | private final Ranking mRankingA = new Ranking(); |
| 103 | private final Ranking mRankingB = new Ranking(); |
| 104 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 105 | @Override |
Daniel Sandler | 379020a | 2010-07-29 16:20:06 -0400 | [diff] [blame] | 106 | public int compare(Entry a, Entry b) { |
Christoph Studer | 2e731b5 | 2014-08-22 16:01:51 +0200 | [diff] [blame] | 107 | // Upsort current media notification. |
Christoph Studer | 1492116 | 2014-09-03 12:51:26 +0200 | [diff] [blame] | 108 | String mediaNotification = mEnvironment.getCurrentMediaNotificationKey(); |
Christoph Studer | 2e731b5 | 2014-08-22 16:01:51 +0200 | [diff] [blame] | 109 | boolean aMedia = a.key.equals(mediaNotification); |
| 110 | boolean bMedia = b.key.equals(mediaNotification); |
| 111 | if (aMedia != bMedia) { |
| 112 | return aMedia ? -1 : 1; |
| 113 | } |
| 114 | |
Christoph Studer | 1492116 | 2014-09-03 12:51:26 +0200 | [diff] [blame] | 115 | final StatusBarNotification na = a.notification; |
| 116 | final StatusBarNotification nb = b.notification; |
| 117 | |
| 118 | // Upsort PRIORITY_MAX system notifications |
| 119 | boolean aSystemMax = na.getNotification().priority >= Notification.PRIORITY_MAX && |
| 120 | isSystemNotification(na); |
| 121 | boolean bSystemMax = nb.getNotification().priority >= Notification.PRIORITY_MAX && |
| 122 | isSystemNotification(nb); |
| 123 | if (aSystemMax != bSystemMax) { |
| 124 | return aSystemMax ? -1 : 1; |
| 125 | } |
| 126 | |
Christoph Studer | 2e731b5 | 2014-08-22 16:01:51 +0200 | [diff] [blame] | 127 | // RankingMap as received from NoMan. |
Christoph Studer | 1d599da | 2014-06-12 15:25:59 +0200 | [diff] [blame] | 128 | if (mRankingMap != null) { |
| 129 | mRankingMap.getRanking(a.key, mRankingA); |
| 130 | mRankingMap.getRanking(b.key, mRankingB); |
| 131 | return mRankingA.getRank() - mRankingB.getRank(); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 132 | } |
| 133 | |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 134 | int d = nb.getScore() - na.getScore(); |
John Spurlock | 362fafe | 2014-02-24 16:56:42 -0500 | [diff] [blame] | 135 | if (a.interruption != b.interruption) { |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 136 | return a.interruption ? -1 : 1; |
John Spurlock | 362fafe | 2014-02-24 16:56:42 -0500 | [diff] [blame] | 137 | } else if (d != 0) { |
Chris Wren | f0048ce | 2013-08-07 16:43:43 -0400 | [diff] [blame] | 138 | return d; |
| 139 | } else { |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 140 | return (int) (nb.getNotification().when - na.getNotification().when); |
Chris Wren | f0048ce | 2013-08-07 16:43:43 -0400 | [diff] [blame] | 141 | } |
Daniel Sandler | 379020a | 2010-07-29 16:20:06 -0400 | [diff] [blame] | 142 | } |
| 143 | }; |
Joe Onorato | 503007d | 2010-04-16 09:20:55 -0700 | [diff] [blame] | 144 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 145 | public NotificationData(Environment environment) { |
| 146 | mEnvironment = environment; |
Selim Cinek | 25fd4e2b | 2015-02-20 17:46:07 +0100 | [diff] [blame] | 147 | mGroupManager = environment.getGroupManager(); |
Joe Onorato | e345fff | 2010-05-23 15:18:27 -0400 | [diff] [blame] | 148 | } |
Joe Onorato | 503007d | 2010-04-16 09:20:55 -0700 | [diff] [blame] | 149 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 150 | /** |
| 151 | * Returns the sorted list of active notifications (depending on {@link Environment} |
| 152 | * |
| 153 | * <p> |
| 154 | * This call doesn't update the list of active notifications. Call {@link #filterAndSort()} |
| 155 | * when the environment changes. |
| 156 | * <p> |
| 157 | * Don't hold on to or modify the returned list. |
| 158 | */ |
| 159 | public ArrayList<Entry> getActiveNotifications() { |
| 160 | return mSortedAndFiltered; |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 161 | } |
| 162 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 163 | public Entry get(String key) { |
| 164 | return mEntries.get(key); |
Joe Onorato | 0e26dff | 2010-05-24 16:17:02 -0400 | [diff] [blame] | 165 | } |
| 166 | |
Christoph Studer | d0694b6 | 2014-06-04 16:36:01 +0200 | [diff] [blame] | 167 | public void add(Entry entry, RankingMap ranking) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 168 | mEntries.put(entry.notification.getKey(), entry); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 169 | updateRankingAndSort(ranking); |
Selim Cinek | 25fd4e2b | 2015-02-20 17:46:07 +0100 | [diff] [blame] | 170 | mGroupManager.onEntryAdded(entry); |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 171 | } |
| 172 | |
Christoph Studer | d0694b6 | 2014-06-04 16:36:01 +0200 | [diff] [blame] | 173 | public Entry remove(String key, RankingMap ranking) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 174 | Entry removed = mEntries.remove(key); |
| 175 | if (removed == null) return null; |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 176 | updateRankingAndSort(ranking); |
Selim Cinek | 25fd4e2b | 2015-02-20 17:46:07 +0100 | [diff] [blame] | 177 | mGroupManager.onEntryRemoved(removed); |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 178 | return removed; |
Joe Onorato | 503007d | 2010-04-16 09:20:55 -0700 | [diff] [blame] | 179 | } |
Joe Onorato | 20da8f8 | 2010-05-24 16:39:29 -0400 | [diff] [blame] | 180 | |
Christoph Studer | d0694b6 | 2014-06-04 16:36:01 +0200 | [diff] [blame] | 181 | public void updateRanking(RankingMap ranking) { |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 182 | updateRankingAndSort(ranking); |
| 183 | } |
| 184 | |
| 185 | public boolean isAmbient(String key) { |
John Spurlock | f079fc5 | 2014-08-09 11:10:03 -0400 | [diff] [blame] | 186 | if (mRankingMap != null) { |
| 187 | mRankingMap.getRanking(key, mTmpRanking); |
| 188 | return mTmpRanking.isAmbient(); |
| 189 | } |
| 190 | return false; |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 191 | } |
| 192 | |
Chris Wren | 3ad4e3a | 2014-09-02 17:23:51 -0400 | [diff] [blame] | 193 | public int getVisibilityOverride(String key) { |
| 194 | if (mRankingMap != null) { |
| 195 | mRankingMap.getRanking(key, mTmpRanking); |
| 196 | return mTmpRanking.getVisibilityOverride(); |
| 197 | } |
| 198 | return NotificationListenerService.Ranking.VISIBILITY_NO_OVERRIDE; |
| 199 | } |
| 200 | |
Christoph Studer | d0694b6 | 2014-06-04 16:36:01 +0200 | [diff] [blame] | 201 | private void updateRankingAndSort(RankingMap ranking) { |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 202 | if (ranking != null) { |
Christoph Studer | 1d599da | 2014-06-12 15:25:59 +0200 | [diff] [blame] | 203 | mRankingMap = ranking; |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 204 | } |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 205 | filterAndSort(); |
Christoph Studer | 37fe693 | 2014-05-26 13:10:30 +0200 | [diff] [blame] | 206 | } |
| 207 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 208 | // TODO: This should not be public. Instead the Environment should notify this class when |
| 209 | // anything changed, and this class should call back the UI so it updates itself. |
| 210 | public void filterAndSort() { |
| 211 | mSortedAndFiltered.clear(); |
| 212 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 213 | final int N = mEntries.size(); |
| 214 | for (int i = 0; i < N; i++) { |
| 215 | Entry entry = mEntries.valueAt(i); |
| 216 | StatusBarNotification sbn = entry.notification; |
| 217 | |
| 218 | if (shouldFilterOut(sbn)) { |
| 219 | continue; |
Joe Onorato | 9c1d823 | 2010-05-24 20:02:53 -0400 | [diff] [blame] | 220 | } |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 221 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 222 | mSortedAndFiltered.add(entry); |
| 223 | } |
| 224 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 225 | Collections.sort(mSortedAndFiltered, mRankingComparator); |
| 226 | } |
| 227 | |
Christoph Studer | 2f9dbba | 2014-09-03 17:35:54 +0200 | [diff] [blame] | 228 | boolean shouldFilterOut(StatusBarNotification sbn) { |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 229 | if (!(mEnvironment.isDeviceProvisioned() || |
| 230 | showNotificationEvenIfUnprovisioned(sbn))) { |
| 231 | return true; |
| 232 | } |
| 233 | |
| 234 | if (!mEnvironment.isNotificationForCurrentProfiles(sbn)) { |
| 235 | return true; |
| 236 | } |
| 237 | |
| 238 | if (sbn.getNotification().visibility == Notification.VISIBILITY_SECRET && |
| 239 | mEnvironment.shouldHideSensitiveContents(sbn.getUserId())) { |
| 240 | return true; |
Joe Onorato | 9c1d823 | 2010-05-24 20:02:53 -0400 | [diff] [blame] | 241 | } |
Selim Cinek | 25fd4e2b | 2015-02-20 17:46:07 +0100 | [diff] [blame] | 242 | |
Selim Cinek | b5605e5 | 2015-02-20 18:21:41 +0100 | [diff] [blame] | 243 | if (!BaseStatusBar.ENABLE_CHILD_NOTIFICATIONS |
| 244 | && mGroupManager.isChildInGroupWithSummary(sbn)) { |
Selim Cinek | 25fd4e2b | 2015-02-20 17:46:07 +0100 | [diff] [blame] | 245 | return true; |
| 246 | } |
Joe Onorato | 9c1d823 | 2010-05-24 20:02:53 -0400 | [diff] [blame] | 247 | return false; |
Joe Onorato | 20da8f8 | 2010-05-24 16:39:29 -0400 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | /** |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 251 | * Return whether there are any clearable notifications (that aren't errors). |
Joe Onorato | 20da8f8 | 2010-05-24 16:39:29 -0400 | [diff] [blame] | 252 | */ |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 253 | public boolean hasActiveClearableNotifications() { |
| 254 | for (Entry e : mSortedAndFiltered) { |
Daniel Sandler | 379020a | 2010-07-29 16:20:06 -0400 | [diff] [blame] | 255 | if (e.expanded != null) { // the view successfully inflated |
Joe Onorato | 5dd1169 | 2010-09-27 15:34:04 -0700 | [diff] [blame] | 256 | if (e.notification.isClearable()) { |
Joe Onorato | 9c1d823 | 2010-05-24 20:02:53 -0400 | [diff] [blame] | 257 | return true; |
| 258 | } |
Joe Onorato | 20da8f8 | 2010-05-24 16:39:29 -0400 | [diff] [blame] | 259 | } |
| 260 | } |
| 261 | return false; |
| 262 | } |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 263 | |
| 264 | // Q: What kinds of notifications should show during setup? |
| 265 | // A: Almost none! Only things coming from the system (package is "android") that also |
| 266 | // have special "kind" tags marking them as relevant for setup (see below). |
| 267 | public static boolean showNotificationEvenIfUnprovisioned(StatusBarNotification sbn) { |
| 268 | return "android".equals(sbn.getPackageName()) |
| 269 | && sbn.getNotification().extras.getBoolean(Notification.EXTRA_ALLOW_DURING_SETUP); |
| 270 | } |
| 271 | |
| 272 | public void dump(PrintWriter pw, String indent) { |
| 273 | int N = mSortedAndFiltered.size(); |
| 274 | pw.print(indent); |
| 275 | pw.println("active notifications: " + N); |
Christoph Studer | 11840cd | 2014-08-21 16:41:45 +0200 | [diff] [blame] | 276 | int active; |
| 277 | for (active = 0; active < N; active++) { |
| 278 | NotificationData.Entry e = mSortedAndFiltered.get(active); |
| 279 | dumpEntry(pw, indent, active, e); |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | int M = mEntries.size(); |
| 283 | pw.print(indent); |
Christoph Studer | 11840cd | 2014-08-21 16:41:45 +0200 | [diff] [blame] | 284 | pw.println("inactive notifications: " + (M - active)); |
| 285 | int inactiveCount = 0; |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 286 | for (int i = 0; i < M; i++) { |
| 287 | Entry entry = mEntries.valueAt(i); |
| 288 | if (!mSortedAndFiltered.contains(entry)) { |
Christoph Studer | 11840cd | 2014-08-21 16:41:45 +0200 | [diff] [blame] | 289 | dumpEntry(pw, indent, inactiveCount, entry); |
| 290 | inactiveCount++; |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 291 | } |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | private void dumpEntry(PrintWriter pw, String indent, int i, Entry e) { |
| 296 | pw.print(indent); |
| 297 | pw.println(" [" + i + "] key=" + e.key + " icon=" + e.icon); |
| 298 | StatusBarNotification n = e.notification; |
| 299 | pw.print(indent); |
Christoph Studer | 11840cd | 2014-08-21 16:41:45 +0200 | [diff] [blame] | 300 | pw.println(" pkg=" + n.getPackageName() + " id=" + n.getId() + " score=" + |
| 301 | n.getScore()); |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 302 | pw.print(indent); |
| 303 | pw.println(" notification=" + n.getNotification()); |
| 304 | pw.print(indent); |
| 305 | pw.println(" tickerText=\"" + n.getNotification().tickerText + "\""); |
| 306 | } |
| 307 | |
Christoph Studer | 1492116 | 2014-09-03 12:51:26 +0200 | [diff] [blame] | 308 | private static boolean isSystemNotification(StatusBarNotification sbn) { |
| 309 | String sbnPackage = sbn.getPackageName(); |
| 310 | return "android".equals(sbnPackage) || "com.android.systemui".equals(sbnPackage); |
| 311 | } |
| 312 | |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 313 | /** |
| 314 | * Provides access to keyguard state and user settings dependent data. |
| 315 | */ |
| 316 | public interface Environment { |
Chris Wren | 3ad4e3a | 2014-09-02 17:23:51 -0400 | [diff] [blame] | 317 | public boolean shouldHideSensitiveContents(int userid); |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 318 | public boolean isDeviceProvisioned(); |
| 319 | public boolean isNotificationForCurrentProfiles(StatusBarNotification sbn); |
Christoph Studer | 2e731b5 | 2014-08-22 16:01:51 +0200 | [diff] [blame] | 320 | public String getCurrentMediaNotificationKey(); |
Selim Cinek | 25fd4e2b | 2015-02-20 17:46:07 +0100 | [diff] [blame] | 321 | public NotificationGroupManager getGroupManager(); |
Christoph Studer | c8db24b | 2014-07-25 17:50:30 +0200 | [diff] [blame] | 322 | } |
Joe Onorato | 503007d | 2010-04-16 09:20:55 -0700 | [diff] [blame] | 323 | } |