Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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 | package com.android.server.notification; |
| 17 | |
Julia Reynolds | 8576991 | 2016-10-25 09:08:57 -0400 | [diff] [blame] | 18 | import static android.app.NotificationManager.IMPORTANCE_MIN; |
| 19 | import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED; |
| 20 | import static android.app.NotificationManager.IMPORTANCE_DEFAULT; |
| 21 | import static android.app.NotificationManager.IMPORTANCE_HIGH; |
| 22 | import static android.app.NotificationManager.IMPORTANCE_LOW; |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 23 | |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 24 | import android.app.Notification; |
Julia Reynolds | b5e44b7 | 2016-08-16 15:00:25 -0400 | [diff] [blame] | 25 | import android.app.NotificationChannel; |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 26 | import android.content.Context; |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 27 | import android.content.pm.ApplicationInfo; |
Tony Mantler | ab55f0f | 2017-06-16 10:50:00 -0700 | [diff] [blame] | 28 | import android.content.pm.PackageManager; |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 29 | import android.content.pm.PackageManager.NameNotFoundException; |
| 30 | import android.content.res.Resources; |
| 31 | import android.graphics.Bitmap; |
Dan Sandler | d63f932 | 2015-05-06 15:18:49 -0400 | [diff] [blame] | 32 | import android.graphics.drawable.Icon; |
John Spurlock | bfa5dc4 | 2014-07-28 23:30:45 -0400 | [diff] [blame] | 33 | import android.media.AudioAttributes; |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 34 | import android.media.AudioSystem; |
Chris Wren | 9eb5e10 | 2017-01-26 13:15:06 -0500 | [diff] [blame] | 35 | import android.metrics.LogMaker; |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 36 | import android.net.Uri; |
| 37 | import android.os.Build; |
Chris Wren | da4bd20 | 2014-09-04 15:53:52 -0400 | [diff] [blame] | 38 | import android.os.UserHandle; |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 39 | import android.provider.Settings; |
Julia Reynolds | 5d25ee7 | 2015-11-20 15:38:20 -0500 | [diff] [blame] | 40 | import android.service.notification.NotificationListenerService; |
Julia Reynolds | c9842c1 | 2017-02-07 12:46:41 -0500 | [diff] [blame] | 41 | import android.service.notification.NotificationRecordProto; |
Julia Reynolds | 22f02b3 | 2016-12-01 15:05:13 -0500 | [diff] [blame] | 42 | import android.service.notification.SnoozeCriterion; |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 43 | import android.service.notification.StatusBarNotification; |
Julia Reynolds | 4b82f6d | 2017-01-04 10:47:41 -0500 | [diff] [blame] | 44 | import android.text.TextUtils; |
Julia Reynolds | f0f629f | 2016-02-25 09:34:04 -0500 | [diff] [blame] | 45 | import android.util.Log; |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 46 | import android.util.Slog; |
Julia Reynolds | 2a12874 | 2016-11-28 14:29:25 -0500 | [diff] [blame] | 47 | import android.util.TimeUtils; |
Julia Reynolds | c9842c1 | 2017-02-07 12:46:41 -0500 | [diff] [blame] | 48 | import android.util.proto.ProtoOutputStream; |
Dan Sandler | 0a2308e | 2017-05-30 19:50:42 -0400 | [diff] [blame] | 49 | import android.widget.RemoteViews; |
John Spurlock | bfa5dc4 | 2014-07-28 23:30:45 -0400 | [diff] [blame] | 50 | |
Chris Wren | 1031c97 | 2014-07-23 13:11:45 +0000 | [diff] [blame] | 51 | import com.android.internal.annotations.VisibleForTesting; |
Chris Wren | 9eb5e10 | 2017-01-26 13:15:06 -0500 | [diff] [blame] | 52 | import com.android.internal.logging.MetricsLogger; |
| 53 | import com.android.internal.logging.nano.MetricsProto.MetricsEvent; |
Chris Wren | 6650e57 | 2015-05-15 17:19:25 -0400 | [diff] [blame] | 54 | import com.android.server.EventLogTags; |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 55 | |
| 56 | import java.io.PrintWriter; |
| 57 | import java.lang.reflect.Array; |
Julia Reynolds | 22f02b3 | 2016-12-01 15:05:13 -0500 | [diff] [blame] | 58 | import java.util.ArrayList; |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 59 | import java.util.Arrays; |
John Spurlock | 312d1d0 | 2014-07-08 10:24:57 -0400 | [diff] [blame] | 60 | import java.util.Objects; |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 61 | |
| 62 | /** |
| 63 | * Holds data about notifications that should not be shared with the |
| 64 | * {@link android.service.notification.NotificationListenerService}s. |
| 65 | * |
| 66 | * <p>These objects should not be mutated unless the code is synchronized |
Julia Reynolds | 88860ce | 2017-06-01 16:55:49 -0400 | [diff] [blame] | 67 | * on {@link NotificationManagerService#mNotificationLock}, and any |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 68 | * modification should be followed by a sorting of that list.</p> |
| 69 | * |
| 70 | * <p>Is sortable by {@link NotificationComparator}.</p> |
| 71 | * |
| 72 | * {@hide} |
| 73 | */ |
| 74 | public final class NotificationRecord { |
Julia Reynolds | f0f629f | 2016-02-25 09:34:04 -0500 | [diff] [blame] | 75 | static final String TAG = "NotificationRecord"; |
| 76 | static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG); |
Chris Wren | b392179 | 2017-06-01 13:34:46 -0400 | [diff] [blame] | 77 | private static final int MAX_LOGTAG_LENGTH = 35; |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 78 | final StatusBarNotification sbn; |
Christoph Studer | 365e4c3 | 2014-09-18 20:35:36 +0200 | [diff] [blame] | 79 | final int mOriginalFlags; |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 80 | private final Context mContext; |
Christoph Studer | 365e4c3 | 2014-09-18 20:35:36 +0200 | [diff] [blame] | 81 | |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 82 | NotificationUsageStats.SingleNotificationStats stats; |
| 83 | boolean isCanceled; |
Amith Yamasani | f47e51e | 2015-04-17 10:02:15 -0700 | [diff] [blame] | 84 | /** Whether the notification was seen by the user via one of the notification listeners. */ |
| 85 | boolean mIsSeen; |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 86 | |
| 87 | // These members are used by NotificationSignalExtractors |
| 88 | // to communicate with the ranking module. |
| 89 | private float mContactAffinity; |
| 90 | private boolean mRecentlyIntrusive; |
Julia Reynolds | 309d1c8 | 2017-05-03 16:00:20 -0400 | [diff] [blame] | 91 | private long mLastIntrusive; |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 92 | |
| 93 | // is this notification currently being intercepted by Zen Mode? |
| 94 | private boolean mIntercept; |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 95 | |
Christoph Studer | 52b7a5a | 2014-06-06 16:09:15 +0200 | [diff] [blame] | 96 | // The timestamp used for ranking. |
| 97 | private long mRankingTimeMs; |
| 98 | |
Chris Wren | 640e387 | 2015-04-21 13:23:18 -0400 | [diff] [blame] | 99 | // The first post time, stable across updates. |
| 100 | private long mCreationTimeMs; |
| 101 | |
Chris Wren | 6650e57 | 2015-05-15 17:19:25 -0400 | [diff] [blame] | 102 | // The most recent visibility event. |
| 103 | private long mVisibleSinceMs; |
| 104 | |
| 105 | // The most recent update time, or the creation time if no updates. |
| 106 | private long mUpdateTimeMs; |
| 107 | |
Chris Wren | a344656 | 2014-06-03 18:11:47 -0400 | [diff] [blame] | 108 | // Is this record an update of an old record? |
| 109 | public boolean isUpdate; |
Chris Wren | 54bbef4 | 2014-07-09 18:37:56 -0400 | [diff] [blame] | 110 | private int mPackagePriority; |
Chris Wren | a344656 | 2014-06-03 18:11:47 -0400 | [diff] [blame] | 111 | |
Chris Wren | 1031c97 | 2014-07-23 13:11:45 +0000 | [diff] [blame] | 112 | private int mAuthoritativeRank; |
Christoph Studer | cd4adf8 | 2014-08-19 17:50:49 +0200 | [diff] [blame] | 113 | private String mGlobalSortKey; |
Chris Wren | 3ad4e3a | 2014-09-02 17:23:51 -0400 | [diff] [blame] | 114 | private int mPackageVisibility; |
Julia Reynolds | ef37f28 | 2016-02-12 09:11:27 -0500 | [diff] [blame] | 115 | private int mUserImportance = IMPORTANCE_UNSPECIFIED; |
Chris Wren | 4763342 | 2016-01-22 09:56:59 -0500 | [diff] [blame] | 116 | private int mImportance = IMPORTANCE_UNSPECIFIED; |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 117 | private CharSequence mImportanceExplanation = null; |
Chris Wren | 1031c97 | 2014-07-23 13:11:45 +0000 | [diff] [blame] | 118 | |
Julia Reynolds | f612869ae | 2015-11-05 16:48:55 -0500 | [diff] [blame] | 119 | private int mSuppressedVisualEffects = 0; |
Julia Reynolds | ef37f28 | 2016-02-12 09:11:27 -0500 | [diff] [blame] | 120 | private String mUserExplanation; |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 121 | private String mPeopleExplanation; |
Geoffrey Pitsch | a22f644 | 2017-05-05 16:47:38 +0000 | [diff] [blame] | 122 | private boolean mPreChannelsNotification = true; |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 123 | private Uri mSound; |
| 124 | private long[] mVibration; |
| 125 | private AudioAttributes mAttributes; |
Julia Reynolds | 924eed1 | 2017-01-19 09:52:07 -0500 | [diff] [blame] | 126 | private NotificationChannel mChannel; |
Julia Reynolds | 22f02b3 | 2016-12-01 15:05:13 -0500 | [diff] [blame] | 127 | private ArrayList<String> mPeopleOverride; |
| 128 | private ArrayList<SnoozeCriterion> mSnoozeCriteria; |
Julia Reynolds | 924eed1 | 2017-01-19 09:52:07 -0500 | [diff] [blame] | 129 | private boolean mShowBadge; |
Chris Wren | 9eb5e10 | 2017-01-26 13:15:06 -0500 | [diff] [blame] | 130 | private LogMaker mLogMaker; |
Julia Reynolds | a33f5c4 | 2017-01-31 16:53:35 -0500 | [diff] [blame] | 131 | private Light mLight; |
Chris Wren | b392179 | 2017-06-01 13:34:46 -0400 | [diff] [blame] | 132 | private String mGroupLogTag; |
| 133 | private String mChannelIdLogTag; |
Julia Reynolds | f612869ae | 2015-11-05 16:48:55 -0500 | [diff] [blame] | 134 | |
Chris Wren | 1031c97 | 2014-07-23 13:11:45 +0000 | [diff] [blame] | 135 | @VisibleForTesting |
Julia Reynolds | 924eed1 | 2017-01-19 09:52:07 -0500 | [diff] [blame] | 136 | public NotificationRecord(Context context, StatusBarNotification sbn, |
Geoffrey Pitsch | a22f644 | 2017-05-05 16:47:38 +0000 | [diff] [blame] | 137 | NotificationChannel channel) |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 138 | { |
| 139 | this.sbn = sbn; |
Christoph Studer | 365e4c3 | 2014-09-18 20:35:36 +0200 | [diff] [blame] | 140 | mOriginalFlags = sbn.getNotification().flags; |
Christoph Studer | 52b7a5a | 2014-06-06 16:09:15 +0200 | [diff] [blame] | 141 | mRankingTimeMs = calculateRankingTimeMs(0L); |
Chris Wren | 640e387 | 2015-04-21 13:23:18 -0400 | [diff] [blame] | 142 | mCreationTimeMs = sbn.getPostTime(); |
Chris Wren | 6650e57 | 2015-05-15 17:19:25 -0400 | [diff] [blame] | 143 | mUpdateTimeMs = mCreationTimeMs; |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 144 | mContext = context; |
Chris Wren | cdee8cd | 2016-01-25 17:10:30 -0500 | [diff] [blame] | 145 | stats = new NotificationUsageStats.SingleNotificationStats(); |
Julia Reynolds | 924eed1 | 2017-01-19 09:52:07 -0500 | [diff] [blame] | 146 | mChannel = channel; |
Geoffrey Pitsch | a22f644 | 2017-05-05 16:47:38 +0000 | [diff] [blame] | 147 | mPreChannelsNotification = isPreChannelsNotification(); |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 148 | mSound = calculateSound(); |
| 149 | mVibration = calculateVibration(); |
| 150 | mAttributes = calculateAttributes(); |
| 151 | mImportance = calculateImportance(); |
Julia Reynolds | a33f5c4 | 2017-01-31 16:53:35 -0500 | [diff] [blame] | 152 | mLight = calculateLights(); |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 153 | } |
| 154 | |
Geoffrey Pitsch | a22f644 | 2017-05-05 16:47:38 +0000 | [diff] [blame] | 155 | private boolean isPreChannelsNotification() { |
| 156 | try { |
| 157 | if (NotificationChannel.DEFAULT_CHANNEL_ID.equals(getChannel().getId())) { |
| 158 | final ApplicationInfo applicationInfo = |
| 159 | mContext.getPackageManager().getApplicationInfoAsUser(sbn.getPackageName(), |
| 160 | 0, UserHandle.getUserId(sbn.getUid())); |
Dan Sandler | e103b78 | 2017-05-17 16:07:56 -0700 | [diff] [blame] | 161 | if (applicationInfo.targetSdkVersion < Build.VERSION_CODES.O) { |
Geoffrey Pitsch | a22f644 | 2017-05-05 16:47:38 +0000 | [diff] [blame] | 162 | return true; |
| 163 | } |
| 164 | } |
| 165 | } catch (NameNotFoundException e) { |
| 166 | Slog.e(TAG, "Can't find package", e); |
| 167 | } |
| 168 | return false; |
| 169 | } |
| 170 | |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 171 | private Uri calculateSound() { |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 172 | final Notification n = sbn.getNotification(); |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 173 | |
Tony Mantler | ab55f0f | 2017-06-16 10:50:00 -0700 | [diff] [blame] | 174 | // No notification sounds on tv |
| 175 | if (mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK)) { |
| 176 | return null; |
| 177 | } |
| 178 | |
Julia Reynolds | 924eed1 | 2017-01-19 09:52:07 -0500 | [diff] [blame] | 179 | Uri sound = mChannel.getSound(); |
Geoffrey Pitsch | a22f644 | 2017-05-05 16:47:38 +0000 | [diff] [blame] | 180 | if (mPreChannelsNotification && (getChannel().getUserLockedFields() |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 181 | & NotificationChannel.USER_LOCKED_SOUND) == 0) { |
| 182 | |
| 183 | final boolean useDefaultSound = (n.defaults & Notification.DEFAULT_SOUND) != 0; |
| 184 | if (useDefaultSound) { |
| 185 | sound = Settings.System.DEFAULT_NOTIFICATION_URI; |
Julia Reynolds | b9e712e | 2017-04-17 10:31:03 -0400 | [diff] [blame] | 186 | } else { |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 187 | sound = n.sound; |
| 188 | } |
| 189 | } |
| 190 | return sound; |
| 191 | } |
| 192 | |
Julia Reynolds | a33f5c4 | 2017-01-31 16:53:35 -0500 | [diff] [blame] | 193 | private Light calculateLights() { |
| 194 | int defaultLightColor = mContext.getResources().getColor( |
| 195 | com.android.internal.R.color.config_defaultNotificationColor); |
| 196 | int defaultLightOn = mContext.getResources().getInteger( |
| 197 | com.android.internal.R.integer.config_defaultNotificationLedOn); |
| 198 | int defaultLightOff = mContext.getResources().getInteger( |
| 199 | com.android.internal.R.integer.config_defaultNotificationLedOff); |
| 200 | |
Julia Reynolds | 529e332 | 2017-02-06 08:33:01 -0500 | [diff] [blame] | 201 | int channelLightColor = getChannel().getLightColor() != 0 ? getChannel().getLightColor() |
| 202 | : defaultLightColor; |
| 203 | Light light = getChannel().shouldShowLights() ? new Light(channelLightColor, |
Julia Reynolds | a33f5c4 | 2017-01-31 16:53:35 -0500 | [diff] [blame] | 204 | defaultLightOn, defaultLightOff) : null; |
Geoffrey Pitsch | a22f644 | 2017-05-05 16:47:38 +0000 | [diff] [blame] | 205 | if (mPreChannelsNotification |
Julia Reynolds | a33f5c4 | 2017-01-31 16:53:35 -0500 | [diff] [blame] | 206 | && (getChannel().getUserLockedFields() |
| 207 | & NotificationChannel.USER_LOCKED_LIGHTS) == 0) { |
| 208 | final Notification notification = sbn.getNotification(); |
| 209 | if ((notification.flags & Notification.FLAG_SHOW_LIGHTS) != 0) { |
| 210 | light = new Light(notification.ledARGB, notification.ledOnMS, |
| 211 | notification.ledOffMS); |
| 212 | if ((notification.defaults & Notification.DEFAULT_LIGHTS) != 0) { |
| 213 | light = new Light(defaultLightColor, defaultLightOn, |
| 214 | defaultLightOff); |
| 215 | } |
| 216 | } else { |
| 217 | light = null; |
| 218 | } |
| 219 | } |
| 220 | return light; |
| 221 | } |
| 222 | |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 223 | private long[] calculateVibration() { |
| 224 | long[] vibration; |
| 225 | final long[] defaultVibration = NotificationManagerService.getLongArray( |
| 226 | mContext.getResources(), |
| 227 | com.android.internal.R.array.config_defaultNotificationVibePattern, |
| 228 | NotificationManagerService.VIBRATE_PATTERN_MAXLEN, |
| 229 | NotificationManagerService.DEFAULT_VIBRATE_PATTERN); |
| 230 | if (getChannel().shouldVibrate()) { |
Julia Reynolds | f57de46 | 2016-11-23 11:31:46 -0500 | [diff] [blame] | 231 | vibration = getChannel().getVibrationPattern() == null |
| 232 | ? defaultVibration : getChannel().getVibrationPattern(); |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 233 | } else { |
| 234 | vibration = null; |
| 235 | } |
Geoffrey Pitsch | a22f644 | 2017-05-05 16:47:38 +0000 | [diff] [blame] | 236 | if (mPreChannelsNotification |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 237 | && (getChannel().getUserLockedFields() |
| 238 | & NotificationChannel.USER_LOCKED_VIBRATION) == 0) { |
| 239 | final Notification notification = sbn.getNotification(); |
| 240 | final boolean useDefaultVibrate = |
| 241 | (notification.defaults & Notification.DEFAULT_VIBRATE) != 0; |
| 242 | if (useDefaultVibrate) { |
| 243 | vibration = defaultVibration; |
| 244 | } else { |
| 245 | vibration = notification.vibrate; |
| 246 | } |
| 247 | } |
| 248 | return vibration; |
| 249 | } |
| 250 | |
| 251 | private AudioAttributes calculateAttributes() { |
| 252 | final Notification n = sbn.getNotification(); |
Julia Reynolds | 619a69f | 2017-01-27 15:11:38 -0500 | [diff] [blame] | 253 | AudioAttributes attributes = getChannel().getAudioAttributes(); |
| 254 | if (attributes == null) { |
| 255 | attributes = Notification.AUDIO_ATTRIBUTES_DEFAULT; |
| 256 | } |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 257 | |
Geoffrey Pitsch | a22f644 | 2017-05-05 16:47:38 +0000 | [diff] [blame] | 258 | if (mPreChannelsNotification |
Julia Reynolds | 619a69f | 2017-01-27 15:11:38 -0500 | [diff] [blame] | 259 | && (getChannel().getUserLockedFields() |
| 260 | & NotificationChannel.USER_LOCKED_SOUND) == 0) { |
| 261 | if (n.audioAttributes != null) { |
| 262 | // prefer audio attributes to stream type |
| 263 | attributes = n.audioAttributes; |
| 264 | } else if (n.audioStreamType >= 0 |
| 265 | && n.audioStreamType < AudioSystem.getNumStreamTypes()) { |
| 266 | // the stream type is valid, use it |
| 267 | attributes = new AudioAttributes.Builder() |
| 268 | .setInternalLegacyStreamType(n.audioStreamType) |
| 269 | .build(); |
| 270 | } else if (n.audioStreamType != AudioSystem.STREAM_DEFAULT) { |
| 271 | Log.w(TAG, String.format("Invalid stream type: %d", n.audioStreamType)); |
| 272 | } |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 273 | } |
| 274 | return attributes; |
| 275 | } |
| 276 | |
| 277 | private int calculateImportance() { |
| 278 | final Notification n = sbn.getNotification(); |
| 279 | int importance = getChannel().getImportance(); |
| 280 | int requestedImportance = IMPORTANCE_DEFAULT; |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 281 | |
| 282 | // Migrate notification flags to scores |
| 283 | if (0 != (n.flags & Notification.FLAG_HIGH_PRIORITY)) { |
| 284 | n.priority = Notification.PRIORITY_MAX; |
| 285 | } |
| 286 | |
Julia Reynolds | a33f5c4 | 2017-01-31 16:53:35 -0500 | [diff] [blame] | 287 | n.priority = NotificationManagerService.clamp(n.priority, Notification.PRIORITY_MIN, |
| 288 | Notification.PRIORITY_MAX); |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 289 | switch (n.priority) { |
| 290 | case Notification.PRIORITY_MIN: |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 291 | requestedImportance = IMPORTANCE_MIN; |
Julia Reynolds | f0f629f | 2016-02-25 09:34:04 -0500 | [diff] [blame] | 292 | break; |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 293 | case Notification.PRIORITY_LOW: |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 294 | requestedImportance = IMPORTANCE_LOW; |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 295 | break; |
| 296 | case Notification.PRIORITY_DEFAULT: |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 297 | requestedImportance = IMPORTANCE_DEFAULT; |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 298 | break; |
| 299 | case Notification.PRIORITY_HIGH: |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 300 | case Notification.PRIORITY_MAX: |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 301 | requestedImportance = IMPORTANCE_HIGH; |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 302 | break; |
| 303 | } |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 304 | stats.requestedImportance = requestedImportance; |
| 305 | stats.isNoisy = mSound != null || mVibration != null; |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 306 | |
Geoffrey Pitsch | a22f644 | 2017-05-05 16:47:38 +0000 | [diff] [blame] | 307 | if (mPreChannelsNotification |
Julia Reynolds | a917a11 | 2017-03-21 11:09:14 -0400 | [diff] [blame] | 308 | && (importance == IMPORTANCE_UNSPECIFIED |
| 309 | || (getChannel().getUserLockedFields() |
| 310 | & NotificationChannel.USER_LOCKED_IMPORTANCE) == 0)) { |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 311 | if (!stats.isNoisy && requestedImportance > IMPORTANCE_LOW) { |
| 312 | requestedImportance = IMPORTANCE_LOW; |
Julia Reynolds | 83fa107 | 2016-02-17 09:10:19 -0500 | [diff] [blame] | 313 | } |
Julia Reynolds | 83fa107 | 2016-02-17 09:10:19 -0500 | [diff] [blame] | 314 | |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 315 | if (stats.isNoisy) { |
| 316 | if (requestedImportance < IMPORTANCE_DEFAULT) { |
| 317 | requestedImportance = IMPORTANCE_DEFAULT; |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | if (n.fullScreenIntent != null) { |
| 322 | requestedImportance = IMPORTANCE_HIGH; |
| 323 | } |
| 324 | importance = requestedImportance; |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 325 | } |
| 326 | |
Chris Wren | cdee8cd | 2016-01-25 17:10:30 -0500 | [diff] [blame] | 327 | stats.naturalImportance = importance; |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 328 | return importance; |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | // copy any notes that the ranking system may have made before the update |
| 332 | public void copyRankingInformation(NotificationRecord previous) { |
| 333 | mContactAffinity = previous.mContactAffinity; |
| 334 | mRecentlyIntrusive = previous.mRecentlyIntrusive; |
Chris Wren | 54bbef4 | 2014-07-09 18:37:56 -0400 | [diff] [blame] | 335 | mPackagePriority = previous.mPackagePriority; |
Chris Wren | 3ad4e3a | 2014-09-02 17:23:51 -0400 | [diff] [blame] | 336 | mPackageVisibility = previous.mPackageVisibility; |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 337 | mIntercept = previous.mIntercept; |
Christoph Studer | 52b7a5a | 2014-06-06 16:09:15 +0200 | [diff] [blame] | 338 | mRankingTimeMs = calculateRankingTimeMs(previous.getRankingTimeMs()); |
Chris Wren | 640e387 | 2015-04-21 13:23:18 -0400 | [diff] [blame] | 339 | mCreationTimeMs = previous.mCreationTimeMs; |
Chris Wren | 6650e57 | 2015-05-15 17:19:25 -0400 | [diff] [blame] | 340 | mVisibleSinceMs = previous.mVisibleSinceMs; |
Selim Cinek | 5b03ce9 | 2016-05-18 15:16:58 -0700 | [diff] [blame] | 341 | if (previous.sbn.getOverrideGroupKey() != null && !sbn.isAppGroup()) { |
Chris Wren | 8a1638f | 2016-05-02 16:19:14 -0400 | [diff] [blame] | 342 | sbn.setOverrideGroupKey(previous.sbn.getOverrideGroupKey()); |
| 343 | } |
Chris Wren | 1f602dc | 2016-04-11 10:33:46 -0400 | [diff] [blame] | 344 | // Don't copy importance information or mGlobalSortKey, recompute them. |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | public Notification getNotification() { return sbn.getNotification(); } |
| 348 | public int getFlags() { return sbn.getNotification().flags; } |
Chris Wren | da4bd20 | 2014-09-04 15:53:52 -0400 | [diff] [blame] | 349 | public UserHandle getUser() { return sbn.getUser(); } |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 350 | public String getKey() { return sbn.getKey(); } |
Chris Wren | da4bd20 | 2014-09-04 15:53:52 -0400 | [diff] [blame] | 351 | /** @deprecated Use {@link #getUser()} instead. */ |
| 352 | public int getUserId() { return sbn.getUserId(); } |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 353 | |
Julia Reynolds | c9842c1 | 2017-02-07 12:46:41 -0500 | [diff] [blame] | 354 | void dump(ProtoOutputStream proto, boolean redact) { |
| 355 | proto.write(NotificationRecordProto.KEY, sbn.getKey()); |
| 356 | if (getChannel() != null) { |
| 357 | proto.write(NotificationRecordProto.CHANNEL_ID, getChannel().getId()); |
| 358 | } |
| 359 | proto.write(NotificationRecordProto.CAN_SHOW_LIGHT, getLight() != null); |
| 360 | proto.write(NotificationRecordProto.CAN_VIBRATE, getVibration() != null); |
| 361 | proto.write(NotificationRecordProto.FLAGS, sbn.getNotification().flags); |
| 362 | proto.write(NotificationRecordProto.GROUP_KEY, getGroupKey()); |
| 363 | proto.write(NotificationRecordProto.IMPORTANCE, getImportance()); |
| 364 | if (getSound() != null) { |
| 365 | proto.write(NotificationRecordProto.SOUND, getSound().toString()); |
| 366 | } |
| 367 | if (getAudioAttributes() != null) { |
| 368 | proto.write(NotificationRecordProto.SOUND_USAGE, getAudioAttributes().getUsage()); |
| 369 | } |
| 370 | } |
| 371 | |
Dan Sandler | 0a2308e | 2017-05-30 19:50:42 -0400 | [diff] [blame] | 372 | String formatRemoteViews(RemoteViews rv) { |
| 373 | if (rv == null) return "null"; |
| 374 | return String.format("%s/0x%08x (%d bytes): %s", |
| 375 | rv.getPackage(), rv.getLayoutId(), rv.estimateMemoryUsage(), rv.toString()); |
| 376 | } |
| 377 | |
Dan Sandler | a177031 | 2015-07-10 13:59:29 -0400 | [diff] [blame] | 378 | void dump(PrintWriter pw, String prefix, Context baseContext, boolean redact) { |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 379 | final Notification notification = sbn.getNotification(); |
Dan Sandler | d63f932 | 2015-05-06 15:18:49 -0400 | [diff] [blame] | 380 | final Icon icon = notification.getSmallIcon(); |
| 381 | String iconStr = String.valueOf(icon); |
| 382 | if (icon != null && icon.getType() == Icon.TYPE_RESOURCE) { |
| 383 | iconStr += " / " + idDebugString(baseContext, icon.getResPackage(), icon.getResId()); |
| 384 | } |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 385 | pw.println(prefix + this); |
Dan Sandler | 0a2308e | 2017-05-30 19:50:42 -0400 | [diff] [blame] | 386 | prefix = prefix + " "; |
Julia Reynolds | a917a11 | 2017-03-21 11:09:14 -0400 | [diff] [blame] | 387 | pw.println(prefix + "uid=" + sbn.getUid() + " userId=" + sbn.getUserId()); |
| 388 | pw.println(prefix + "icon=" + iconStr); |
| 389 | pw.println(prefix + "pri=" + notification.priority); |
| 390 | pw.println(prefix + "key=" + sbn.getKey()); |
| 391 | pw.println(prefix + "seen=" + mIsSeen); |
| 392 | pw.println(prefix + "groupKey=" + getGroupKey()); |
| 393 | pw.println(prefix + "fullscreenIntent=" + notification.fullScreenIntent); |
| 394 | pw.println(prefix + "contentIntent=" + notification.contentIntent); |
| 395 | pw.println(prefix + "deleteIntent=" + notification.deleteIntent); |
Dan Sandler | 0b4ceb3 | 2017-03-29 14:13:55 -0400 | [diff] [blame] | 396 | |
| 397 | pw.print(prefix + "tickerText="); |
| 398 | if (!TextUtils.isEmpty(notification.tickerText)) { |
| 399 | final String ticker = notification.tickerText.toString(); |
| 400 | if (redact) { |
| 401 | // if the string is long enough, we allow ourselves a few bytes for debugging |
| 402 | pw.print(ticker.length() > 16 ? ticker.substring(0,8) : ""); |
| 403 | pw.println("..."); |
| 404 | } else { |
| 405 | pw.println(ticker); |
| 406 | } |
| 407 | } else { |
| 408 | pw.println("null"); |
| 409 | } |
Dan Sandler | 0a2308e | 2017-05-30 19:50:42 -0400 | [diff] [blame] | 410 | pw.println(prefix + "contentView=" + formatRemoteViews(notification.contentView)); |
| 411 | pw.println(prefix + "bigContentView=" + formatRemoteViews(notification.bigContentView)); |
| 412 | pw.println(prefix + "headsUpContentView=" |
| 413 | + formatRemoteViews(notification.headsUpContentView)); |
| 414 | pw.print(prefix + String.format("color=0x%08x", notification.color)); |
Julia Reynolds | bad4297 | 2017-04-25 13:52:49 -0400 | [diff] [blame] | 415 | pw.println(prefix + "timeout=" |
| 416 | + TimeUtils.formatForLogging(notification.getTimeoutAfter())); |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 417 | if (notification.actions != null && notification.actions.length > 0) { |
Julia Reynolds | a917a11 | 2017-03-21 11:09:14 -0400 | [diff] [blame] | 418 | pw.println(prefix + "actions={"); |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 419 | final int N = notification.actions.length; |
Julia Reynolds | 4b82f6d | 2017-01-04 10:47:41 -0500 | [diff] [blame] | 420 | for (int i = 0; i < N; i++) { |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 421 | final Notification.Action action = notification.actions[i]; |
Chris Wren | 1ac52a9 | 2016-02-24 14:54:52 -0500 | [diff] [blame] | 422 | if (action != null) { |
| 423 | pw.println(String.format("%s [%d] \"%s\" -> %s", |
| 424 | prefix, |
| 425 | i, |
| 426 | action.title, |
| 427 | action.actionIntent == null ? "null" : action.actionIntent.toString() |
| 428 | )); |
| 429 | } |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 430 | } |
| 431 | pw.println(prefix + " }"); |
| 432 | } |
| 433 | if (notification.extras != null && notification.extras.size() > 0) { |
Julia Reynolds | a917a11 | 2017-03-21 11:09:14 -0400 | [diff] [blame] | 434 | pw.println(prefix + "extras={"); |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 435 | for (String key : notification.extras.keySet()) { |
| 436 | pw.print(prefix + " " + key + "="); |
| 437 | Object val = notification.extras.get(key); |
| 438 | if (val == null) { |
| 439 | pw.println("null"); |
| 440 | } else { |
| 441 | pw.print(val.getClass().getSimpleName()); |
Dan Sandler | a177031 | 2015-07-10 13:59:29 -0400 | [diff] [blame] | 442 | if (redact && (val instanceof CharSequence || val instanceof String)) { |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 443 | // redact contents from bugreports |
| 444 | } else if (val instanceof Bitmap) { |
| 445 | pw.print(String.format(" (%dx%d)", |
| 446 | ((Bitmap) val).getWidth(), |
| 447 | ((Bitmap) val).getHeight())); |
| 448 | } else if (val.getClass().isArray()) { |
| 449 | final int N = Array.getLength(val); |
Dan Sandler | a177031 | 2015-07-10 13:59:29 -0400 | [diff] [blame] | 450 | pw.print(" (" + N + ")"); |
| 451 | if (!redact) { |
Julia Reynolds | 4b82f6d | 2017-01-04 10:47:41 -0500 | [diff] [blame] | 452 | for (int j = 0; j < N; j++) { |
Dan Sandler | a177031 | 2015-07-10 13:59:29 -0400 | [diff] [blame] | 453 | pw.println(); |
| 454 | pw.print(String.format("%s [%d] %s", |
| 455 | prefix, j, String.valueOf(Array.get(val, j)))); |
| 456 | } |
| 457 | } |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 458 | } else { |
| 459 | pw.print(" (" + String.valueOf(val) + ")"); |
| 460 | } |
| 461 | pw.println(); |
| 462 | } |
| 463 | } |
Julia Reynolds | a917a11 | 2017-03-21 11:09:14 -0400 | [diff] [blame] | 464 | pw.println(prefix + "}"); |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 465 | } |
Julia Reynolds | a917a11 | 2017-03-21 11:09:14 -0400 | [diff] [blame] | 466 | pw.println(prefix + "stats=" + stats.toString()); |
| 467 | pw.println(prefix + "mContactAffinity=" + mContactAffinity); |
| 468 | pw.println(prefix + "mRecentlyIntrusive=" + mRecentlyIntrusive); |
| 469 | pw.println(prefix + "mPackagePriority=" + mPackagePriority); |
| 470 | pw.println(prefix + "mPackageVisibility=" + mPackageVisibility); |
| 471 | pw.println(prefix + "mUserImportance=" |
Julia Reynolds | ef37f28 | 2016-02-12 09:11:27 -0500 | [diff] [blame] | 472 | + NotificationListenerService.Ranking.importanceToString(mUserImportance)); |
Julia Reynolds | a917a11 | 2017-03-21 11:09:14 -0400 | [diff] [blame] | 473 | pw.println(prefix + "mImportance=" |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 474 | + NotificationListenerService.Ranking.importanceToString(mImportance)); |
Julia Reynolds | a917a11 | 2017-03-21 11:09:14 -0400 | [diff] [blame] | 475 | pw.println(prefix + "mImportanceExplanation=" + mImportanceExplanation); |
| 476 | pw.println(prefix + "mIntercept=" + mIntercept); |
| 477 | pw.println(prefix + "mGlobalSortKey=" + mGlobalSortKey); |
| 478 | pw.println(prefix + "mRankingTimeMs=" + mRankingTimeMs); |
| 479 | pw.println(prefix + "mCreationTimeMs=" + mCreationTimeMs); |
| 480 | pw.println(prefix + "mVisibleSinceMs=" + mVisibleSinceMs); |
| 481 | pw.println(prefix + "mUpdateTimeMs=" + mUpdateTimeMs); |
| 482 | pw.println(prefix + "mSuppressedVisualEffects= " + mSuppressedVisualEffects); |
Geoffrey Pitsch | a22f644 | 2017-05-05 16:47:38 +0000 | [diff] [blame] | 483 | if (mPreChannelsNotification) { |
Julia Reynolds | a917a11 | 2017-03-21 11:09:14 -0400 | [diff] [blame] | 484 | pw.println(prefix + String.format("defaults=0x%08x flags=0x%08x", |
Julia Reynolds | a33f5c4 | 2017-01-31 16:53:35 -0500 | [diff] [blame] | 485 | notification.defaults, notification.flags)); |
Julia Reynolds | a917a11 | 2017-03-21 11:09:14 -0400 | [diff] [blame] | 486 | pw.println(prefix + "n.sound=" + notification.sound); |
| 487 | pw.println(prefix + "n.audioStreamType=" + notification.audioStreamType); |
| 488 | pw.println(prefix + "n.audioAttributes=" + notification.audioAttributes); |
Julia Reynolds | a33f5c4 | 2017-01-31 16:53:35 -0500 | [diff] [blame] | 489 | pw.println(prefix + String.format(" led=0x%08x onMs=%d offMs=%d", |
| 490 | notification.ledARGB, notification.ledOnMS, notification.ledOffMS)); |
Julia Reynolds | a917a11 | 2017-03-21 11:09:14 -0400 | [diff] [blame] | 491 | pw.println(prefix + "vibrate=" + Arrays.toString(notification.vibrate)); |
Julia Reynolds | a33f5c4 | 2017-01-31 16:53:35 -0500 | [diff] [blame] | 492 | } |
Julia Reynolds | a917a11 | 2017-03-21 11:09:14 -0400 | [diff] [blame] | 493 | pw.println(prefix + "mSound= " + mSound); |
| 494 | pw.println(prefix + "mVibration= " + mVibration); |
| 495 | pw.println(prefix + "mAttributes= " + mAttributes); |
| 496 | pw.println(prefix + "mLight= " + mLight); |
| 497 | pw.println(prefix + "mShowBadge=" + mShowBadge); |
| 498 | pw.println(prefix + "effectiveNotificationChannel=" + getChannel()); |
Julia Reynolds | 4b82f6d | 2017-01-04 10:47:41 -0500 | [diff] [blame] | 499 | if (getPeopleOverride() != null) { |
Julia Reynolds | a917a11 | 2017-03-21 11:09:14 -0400 | [diff] [blame] | 500 | pw.println(prefix + "overridePeople= " + TextUtils.join(",", getPeopleOverride())); |
Julia Reynolds | 4b82f6d | 2017-01-04 10:47:41 -0500 | [diff] [blame] | 501 | } |
| 502 | if (getSnoozeCriteria() != null) { |
Julia Reynolds | a917a11 | 2017-03-21 11:09:14 -0400 | [diff] [blame] | 503 | pw.println(prefix + "snoozeCriteria=" + TextUtils.join(",", getSnoozeCriteria())); |
Julia Reynolds | 4b82f6d | 2017-01-04 10:47:41 -0500 | [diff] [blame] | 504 | } |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 505 | } |
| 506 | |
| 507 | |
| 508 | static String idDebugString(Context baseContext, String packageName, int id) { |
| 509 | Context c; |
| 510 | |
| 511 | if (packageName != null) { |
| 512 | try { |
| 513 | c = baseContext.createPackageContext(packageName, 0); |
| 514 | } catch (NameNotFoundException e) { |
| 515 | c = baseContext; |
| 516 | } |
| 517 | } else { |
| 518 | c = baseContext; |
| 519 | } |
| 520 | |
| 521 | Resources r = c.getResources(); |
| 522 | try { |
| 523 | return r.getResourceName(id); |
| 524 | } catch (Resources.NotFoundException e) { |
| 525 | return "<name unknown>"; |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | @Override |
| 530 | public final String toString() { |
| 531 | return String.format( |
Julia Reynolds | 8576991 | 2016-10-25 09:08:57 -0400 | [diff] [blame] | 532 | "NotificationRecord(0x%08x: pkg=%s user=%s id=%d tag=%s importance=%d key=%s" + |
| 533 | " channel=%s: %s)", |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 534 | System.identityHashCode(this), |
| 535 | this.sbn.getPackageName(), this.sbn.getUser(), this.sbn.getId(), |
Julia Reynolds | 8576991 | 2016-10-25 09:08:57 -0400 | [diff] [blame] | 536 | this.sbn.getTag(), this.mImportance, this.sbn.getKey(), this.getChannel().getId(), |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 537 | this.sbn.getNotification()); |
| 538 | } |
| 539 | |
| 540 | public void setContactAffinity(float contactAffinity) { |
| 541 | mContactAffinity = contactAffinity; |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 542 | if (mImportance < IMPORTANCE_DEFAULT && |
Chris Wren | c977f81 | 2016-06-13 21:24:53 +0000 | [diff] [blame] | 543 | mContactAffinity > ValidateNotificationPeople.VALID_CONTACT) { |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 544 | setImportance(IMPORTANCE_DEFAULT, getPeopleExplanation()); |
| 545 | } |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 546 | } |
| 547 | |
| 548 | public float getContactAffinity() { |
| 549 | return mContactAffinity; |
| 550 | } |
| 551 | |
John Spurlock | 1d881a1 | 2015-03-18 19:21:54 -0400 | [diff] [blame] | 552 | public void setRecentlyIntrusive(boolean recentlyIntrusive) { |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 553 | mRecentlyIntrusive = recentlyIntrusive; |
Julia Reynolds | 309d1c8 | 2017-05-03 16:00:20 -0400 | [diff] [blame] | 554 | if (recentlyIntrusive) { |
| 555 | mLastIntrusive = System.currentTimeMillis(); |
| 556 | } |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 557 | } |
| 558 | |
| 559 | public boolean isRecentlyIntrusive() { |
| 560 | return mRecentlyIntrusive; |
| 561 | } |
| 562 | |
Julia Reynolds | 309d1c8 | 2017-05-03 16:00:20 -0400 | [diff] [blame] | 563 | public long getLastIntrusive() { |
| 564 | return mLastIntrusive; |
| 565 | } |
| 566 | |
Chris Wren | 54bbef4 | 2014-07-09 18:37:56 -0400 | [diff] [blame] | 567 | public void setPackagePriority(int packagePriority) { |
John Spurlock | 6ac5f8d | 2014-07-18 11:27:54 -0400 | [diff] [blame] | 568 | mPackagePriority = packagePriority; |
Chris Wren | 54bbef4 | 2014-07-09 18:37:56 -0400 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | public int getPackagePriority() { |
| 572 | return mPackagePriority; |
| 573 | } |
| 574 | |
Chris Wren | 3ad4e3a | 2014-09-02 17:23:51 -0400 | [diff] [blame] | 575 | public void setPackageVisibilityOverride(int packageVisibility) { |
| 576 | mPackageVisibility = packageVisibility; |
| 577 | } |
| 578 | |
| 579 | public int getPackageVisibilityOverride() { |
| 580 | return mPackageVisibility; |
| 581 | } |
| 582 | |
Julia Reynolds | ef37f28 | 2016-02-12 09:11:27 -0500 | [diff] [blame] | 583 | public void setUserImportance(int importance) { |
| 584 | mUserImportance = importance; |
| 585 | applyUserImportance(); |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 586 | } |
| 587 | |
Julia Reynolds | ef37f28 | 2016-02-12 09:11:27 -0500 | [diff] [blame] | 588 | private String getUserExplanation() { |
| 589 | if (mUserExplanation == null) { |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 590 | mUserExplanation = mContext.getResources().getString( |
| 591 | com.android.internal.R.string.importance_from_user); |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 592 | } |
Julia Reynolds | ef37f28 | 2016-02-12 09:11:27 -0500 | [diff] [blame] | 593 | return mUserExplanation; |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 594 | } |
| 595 | |
| 596 | private String getPeopleExplanation() { |
| 597 | if (mPeopleExplanation == null) { |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 598 | mPeopleExplanation = mContext.getResources().getString( |
| 599 | com.android.internal.R.string.importance_from_person); |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 600 | } |
| 601 | return mPeopleExplanation; |
| 602 | } |
| 603 | |
Julia Reynolds | ef37f28 | 2016-02-12 09:11:27 -0500 | [diff] [blame] | 604 | private void applyUserImportance() { |
Julia Reynolds | 8576991 | 2016-10-25 09:08:57 -0400 | [diff] [blame] | 605 | if (mUserImportance != IMPORTANCE_UNSPECIFIED) { |
Julia Reynolds | ef37f28 | 2016-02-12 09:11:27 -0500 | [diff] [blame] | 606 | mImportance = mUserImportance; |
| 607 | mImportanceExplanation = getUserExplanation(); |
Julia Reynolds | 5d25ee7 | 2015-11-20 15:38:20 -0500 | [diff] [blame] | 608 | } |
| 609 | } |
| 610 | |
Julia Reynolds | ef37f28 | 2016-02-12 09:11:27 -0500 | [diff] [blame] | 611 | public int getUserImportance() { |
| 612 | return mUserImportance; |
Julia Reynolds | 5d25ee7 | 2015-11-20 15:38:20 -0500 | [diff] [blame] | 613 | } |
| 614 | |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 615 | public void setImportance(int importance, CharSequence explanation) { |
Julia Reynolds | 8576991 | 2016-10-25 09:08:57 -0400 | [diff] [blame] | 616 | if (importance != IMPORTANCE_UNSPECIFIED) { |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 617 | mImportance = importance; |
| 618 | mImportanceExplanation = explanation; |
| 619 | } |
Julia Reynolds | ef37f28 | 2016-02-12 09:11:27 -0500 | [diff] [blame] | 620 | applyUserImportance(); |
Chris Wren | bdf3376 | 2015-12-04 15:50:51 -0500 | [diff] [blame] | 621 | } |
| 622 | |
| 623 | public int getImportance() { |
| 624 | return mImportance; |
| 625 | } |
| 626 | |
| 627 | public CharSequence getImportanceExplanation() { |
| 628 | return mImportanceExplanation; |
| 629 | } |
| 630 | |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 631 | public boolean setIntercepted(boolean intercept) { |
| 632 | mIntercept = intercept; |
| 633 | return mIntercept; |
| 634 | } |
| 635 | |
| 636 | public boolean isIntercepted() { |
| 637 | return mIntercept; |
| 638 | } |
| 639 | |
Julia Reynolds | f612869ae | 2015-11-05 16:48:55 -0500 | [diff] [blame] | 640 | public void setSuppressedVisualEffects(int effects) { |
| 641 | mSuppressedVisualEffects = effects; |
| 642 | } |
| 643 | |
| 644 | public int getSuppressedVisualEffects() { |
| 645 | return mSuppressedVisualEffects; |
| 646 | } |
| 647 | |
John Spurlock | 312d1d0 | 2014-07-08 10:24:57 -0400 | [diff] [blame] | 648 | public boolean isCategory(String category) { |
John Spurlock | bfa5dc4 | 2014-07-28 23:30:45 -0400 | [diff] [blame] | 649 | return Objects.equals(getNotification().category, category); |
| 650 | } |
| 651 | |
| 652 | public boolean isAudioStream(int stream) { |
| 653 | return getNotification().audioStreamType == stream; |
| 654 | } |
| 655 | |
| 656 | public boolean isAudioAttributesUsage(int usage) { |
| 657 | final AudioAttributes attributes = getNotification().audioAttributes; |
| 658 | return attributes != null && attributes.getUsage() == usage; |
John Spurlock | 312d1d0 | 2014-07-08 10:24:57 -0400 | [diff] [blame] | 659 | } |
| 660 | |
Christoph Studer | 52b7a5a | 2014-06-06 16:09:15 +0200 | [diff] [blame] | 661 | /** |
| 662 | * Returns the timestamp to use for time-based sorting in the ranker. |
| 663 | */ |
| 664 | public long getRankingTimeMs() { |
| 665 | return mRankingTimeMs; |
| 666 | } |
| 667 | |
| 668 | /** |
Chris Wren | e6ddb8a | 2015-05-27 15:21:00 -0400 | [diff] [blame] | 669 | * @param now this current time in milliseconds. |
| 670 | * @returns the number of milliseconds since the most recent update, or the post time if none. |
Chris Wren | 6650e57 | 2015-05-15 17:19:25 -0400 | [diff] [blame] | 671 | */ |
Chris Wren | e6ddb8a | 2015-05-27 15:21:00 -0400 | [diff] [blame] | 672 | public int getFreshnessMs(long now) { |
| 673 | return (int) (now - mUpdateTimeMs); |
Chris Wren | 6650e57 | 2015-05-15 17:19:25 -0400 | [diff] [blame] | 674 | } |
| 675 | |
| 676 | /** |
Chris Wren | e6ddb8a | 2015-05-27 15:21:00 -0400 | [diff] [blame] | 677 | * @param now this current time in milliseconds. |
| 678 | * @returns the number of milliseconds since the the first post, ignoring updates. |
Chris Wren | 640e387 | 2015-04-21 13:23:18 -0400 | [diff] [blame] | 679 | */ |
Chris Wren | e6ddb8a | 2015-05-27 15:21:00 -0400 | [diff] [blame] | 680 | public int getLifespanMs(long now) { |
| 681 | return (int) (now - mCreationTimeMs); |
Chris Wren | 640e387 | 2015-04-21 13:23:18 -0400 | [diff] [blame] | 682 | } |
| 683 | |
| 684 | /** |
Chris Wren | e6ddb8a | 2015-05-27 15:21:00 -0400 | [diff] [blame] | 685 | * @param now this current time in milliseconds. |
| 686 | * @returns the number of milliseconds since the most recent visibility event, or 0 if never. |
Chris Wren | 6650e57 | 2015-05-15 17:19:25 -0400 | [diff] [blame] | 687 | */ |
Chris Wren | e6ddb8a | 2015-05-27 15:21:00 -0400 | [diff] [blame] | 688 | public int getExposureMs(long now) { |
| 689 | return mVisibleSinceMs == 0 ? 0 : (int) (now - mVisibleSinceMs); |
Chris Wren | 6650e57 | 2015-05-15 17:19:25 -0400 | [diff] [blame] | 690 | } |
| 691 | |
| 692 | /** |
| 693 | * Set the visibility of the notification. |
| 694 | */ |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 695 | public void setVisibility(boolean visible, int rank) { |
Chris Wren | 6650e57 | 2015-05-15 17:19:25 -0400 | [diff] [blame] | 696 | final long now = System.currentTimeMillis(); |
Chris Wren | e6ddb8a | 2015-05-27 15:21:00 -0400 | [diff] [blame] | 697 | mVisibleSinceMs = visible ? now : mVisibleSinceMs; |
Chris Wren | 6650e57 | 2015-05-15 17:19:25 -0400 | [diff] [blame] | 698 | stats.onVisibilityChanged(visible); |
Chris Wren | 9eb5e10 | 2017-01-26 13:15:06 -0500 | [diff] [blame] | 699 | MetricsLogger.action(getLogMaker(now) |
| 700 | .setCategory(MetricsEvent.NOTIFICATION_ITEM) |
| 701 | .setType(visible ? MetricsEvent.TYPE_OPEN : MetricsEvent.TYPE_CLOSE) |
| 702 | .addTaggedData(MetricsEvent.NOTIFICATION_SHADE_INDEX, rank)); |
| 703 | if (visible) { |
| 704 | MetricsLogger.histogram(mContext, "note_freshness", getFreshnessMs(now)); |
| 705 | } |
Chris Wren | 6650e57 | 2015-05-15 17:19:25 -0400 | [diff] [blame] | 706 | EventLogTags.writeNotificationVisibility(getKey(), visible ? 1 : 0, |
Chris Wren | 9eb5e10 | 2017-01-26 13:15:06 -0500 | [diff] [blame] | 707 | getLifespanMs(now), |
| 708 | getFreshnessMs(now), |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 709 | 0, // exposure time |
| 710 | rank); |
Chris Wren | 6650e57 | 2015-05-15 17:19:25 -0400 | [diff] [blame] | 711 | } |
| 712 | |
| 713 | /** |
Christoph Studer | 52b7a5a | 2014-06-06 16:09:15 +0200 | [diff] [blame] | 714 | * @param previousRankingTimeMs for updated notifications, {@link #getRankingTimeMs()} |
| 715 | * of the previous notification record, 0 otherwise |
| 716 | */ |
| 717 | private long calculateRankingTimeMs(long previousRankingTimeMs) { |
| 718 | Notification n = getNotification(); |
| 719 | // Take developer provided 'when', unless it's in the future. |
| 720 | if (n.when != 0 && n.when <= sbn.getPostTime()) { |
| 721 | return n.when; |
| 722 | } |
| 723 | // If we've ranked a previous instance with a timestamp, inherit it. This case is |
| 724 | // important in order to have ranking stability for updating notifications. |
| 725 | if (previousRankingTimeMs > 0) { |
| 726 | return previousRankingTimeMs; |
| 727 | } |
| 728 | return sbn.getPostTime(); |
| 729 | } |
Chris Wren | 1031c97 | 2014-07-23 13:11:45 +0000 | [diff] [blame] | 730 | |
Christoph Studer | cd4adf8 | 2014-08-19 17:50:49 +0200 | [diff] [blame] | 731 | public void setGlobalSortKey(String globalSortKey) { |
| 732 | mGlobalSortKey = globalSortKey; |
Chris Wren | 1031c97 | 2014-07-23 13:11:45 +0000 | [diff] [blame] | 733 | } |
| 734 | |
Christoph Studer | cd4adf8 | 2014-08-19 17:50:49 +0200 | [diff] [blame] | 735 | public String getGlobalSortKey() { |
| 736 | return mGlobalSortKey; |
Chris Wren | 1031c97 | 2014-07-23 13:11:45 +0000 | [diff] [blame] | 737 | } |
| 738 | |
Amith Yamasani | f47e51e | 2015-04-17 10:02:15 -0700 | [diff] [blame] | 739 | /** Check if any of the listeners have marked this notification as seen by the user. */ |
| 740 | public boolean isSeen() { |
| 741 | return mIsSeen; |
| 742 | } |
| 743 | |
| 744 | /** Mark the notification as seen by the user. */ |
| 745 | public void setSeen() { |
| 746 | mIsSeen = true; |
| 747 | } |
| 748 | |
Chris Wren | 1031c97 | 2014-07-23 13:11:45 +0000 | [diff] [blame] | 749 | public void setAuthoritativeRank(int authoritativeRank) { |
| 750 | mAuthoritativeRank = authoritativeRank; |
| 751 | } |
| 752 | |
| 753 | public int getAuthoritativeRank() { |
| 754 | return mAuthoritativeRank; |
| 755 | } |
| 756 | |
| 757 | public String getGroupKey() { |
| 758 | return sbn.getGroupKey(); |
| 759 | } |
Chris Wren | 4763342 | 2016-01-22 09:56:59 -0500 | [diff] [blame] | 760 | |
Chris Wren | b392179 | 2017-06-01 13:34:46 -0400 | [diff] [blame] | 761 | public void setOverrideGroupKey(String overrideGroupKey) { |
| 762 | sbn.setOverrideGroupKey(overrideGroupKey); |
| 763 | mGroupLogTag = null; |
| 764 | } |
| 765 | |
| 766 | private String getGroupLogTag() { |
| 767 | if (mGroupLogTag == null) { |
| 768 | mGroupLogTag = shortenTag(sbn.getGroup()); |
| 769 | } |
| 770 | return mGroupLogTag; |
| 771 | } |
| 772 | |
| 773 | private String getChannelIdLogTag() { |
| 774 | if (mChannelIdLogTag == null) { |
| 775 | mChannelIdLogTag = shortenTag(mChannel.getId()); |
| 776 | } |
| 777 | return mChannelIdLogTag; |
| 778 | } |
| 779 | |
| 780 | private String shortenTag(String longTag) { |
| 781 | if (longTag == null) { |
| 782 | return null; |
| 783 | } |
| 784 | if (longTag.length() < MAX_LOGTAG_LENGTH) { |
| 785 | return longTag; |
| 786 | } else { |
| 787 | return longTag.substring(0, MAX_LOGTAG_LENGTH - 8) + "-" + |
| 788 | Integer.toHexString(longTag.hashCode()); |
| 789 | } |
| 790 | } |
| 791 | |
Chris Wren | 4763342 | 2016-01-22 09:56:59 -0500 | [diff] [blame] | 792 | public boolean isImportanceFromUser() { |
Julia Reynolds | ef37f28 | 2016-02-12 09:11:27 -0500 | [diff] [blame] | 793 | return mImportance == mUserImportance; |
Chris Wren | 4763342 | 2016-01-22 09:56:59 -0500 | [diff] [blame] | 794 | } |
Julia Reynolds | b5e44b7 | 2016-08-16 15:00:25 -0400 | [diff] [blame] | 795 | |
| 796 | public NotificationChannel getChannel() { |
Julia Reynolds | 924eed1 | 2017-01-19 09:52:07 -0500 | [diff] [blame] | 797 | return mChannel; |
Julia Reynolds | 22f02b3 | 2016-12-01 15:05:13 -0500 | [diff] [blame] | 798 | } |
| 799 | |
Julia Reynolds | 924eed1 | 2017-01-19 09:52:07 -0500 | [diff] [blame] | 800 | protected void updateNotificationChannel(NotificationChannel channel) { |
| 801 | if (channel != null) { |
| 802 | mChannel = channel; |
Julia Reynolds | 22f02b3 | 2016-12-01 15:05:13 -0500 | [diff] [blame] | 803 | calculateImportance(); |
| 804 | } |
Julia Reynolds | b5e44b7 | 2016-08-16 15:00:25 -0400 | [diff] [blame] | 805 | } |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 806 | |
Julia Reynolds | 924eed1 | 2017-01-19 09:52:07 -0500 | [diff] [blame] | 807 | public void setShowBadge(boolean showBadge) { |
| 808 | mShowBadge = showBadge; |
| 809 | } |
| 810 | |
| 811 | public boolean canShowBadge() { |
| 812 | return mShowBadge; |
| 813 | } |
| 814 | |
Julia Reynolds | a33f5c4 | 2017-01-31 16:53:35 -0500 | [diff] [blame] | 815 | public Light getLight() { |
| 816 | return mLight; |
| 817 | } |
| 818 | |
Julia Reynolds | 0c299d4 | 2016-11-15 14:37:04 -0500 | [diff] [blame] | 819 | public Uri getSound() { |
| 820 | return mSound; |
| 821 | } |
| 822 | |
| 823 | public long[] getVibration() { |
| 824 | return mVibration; |
| 825 | } |
| 826 | |
| 827 | public AudioAttributes getAudioAttributes() { |
| 828 | return mAttributes; |
| 829 | } |
Julia Reynolds | 22f02b3 | 2016-12-01 15:05:13 -0500 | [diff] [blame] | 830 | |
| 831 | public ArrayList<String> getPeopleOverride() { |
| 832 | return mPeopleOverride; |
| 833 | } |
| 834 | |
| 835 | protected void setPeopleOverride(ArrayList<String> people) { |
| 836 | mPeopleOverride = people; |
| 837 | } |
| 838 | |
| 839 | public ArrayList<SnoozeCriterion> getSnoozeCriteria() { |
| 840 | return mSnoozeCriteria; |
| 841 | } |
| 842 | |
| 843 | protected void setSnoozeCriteria(ArrayList<SnoozeCriterion> snoozeCriteria) { |
| 844 | mSnoozeCriteria = snoozeCriteria; |
| 845 | } |
Chris Wren | 9eb5e10 | 2017-01-26 13:15:06 -0500 | [diff] [blame] | 846 | |
| 847 | public LogMaker getLogMaker(long now) { |
| 848 | if (mLogMaker == null) { |
Chris Wren | b392179 | 2017-06-01 13:34:46 -0400 | [diff] [blame] | 849 | // initialize fields that only change on update (so a new record) |
Chris Wren | 9eb5e10 | 2017-01-26 13:15:06 -0500 | [diff] [blame] | 850 | mLogMaker = new LogMaker(MetricsEvent.VIEW_UNKNOWN) |
| 851 | .setPackageName(sbn.getPackageName()) |
| 852 | .addTaggedData(MetricsEvent.NOTIFICATION_ID, sbn.getId()) |
Chris Wren | b392179 | 2017-06-01 13:34:46 -0400 | [diff] [blame] | 853 | .addTaggedData(MetricsEvent.NOTIFICATION_TAG, sbn.getTag()) |
| 854 | .addTaggedData(MetricsEvent.FIELD_NOTIFICATION_CHANNEL_ID, getChannelIdLogTag()); |
Chris Wren | 9eb5e10 | 2017-01-26 13:15:06 -0500 | [diff] [blame] | 855 | } |
Chris Wren | b392179 | 2017-06-01 13:34:46 -0400 | [diff] [blame] | 856 | // reset fields that can change between updates, or are used by multiple logs |
Chris Wren | 9eb5e10 | 2017-01-26 13:15:06 -0500 | [diff] [blame] | 857 | return mLogMaker |
Chris Wren | a7c1b80 | 2017-03-07 10:17:20 -0500 | [diff] [blame] | 858 | .clearCategory() |
| 859 | .clearType() |
| 860 | .clearSubtype() |
Chris Wren | 9eb5e10 | 2017-01-26 13:15:06 -0500 | [diff] [blame] | 861 | .clearTaggedData(MetricsEvent.NOTIFICATION_SHADE_INDEX) |
Chris Wren | b392179 | 2017-06-01 13:34:46 -0400 | [diff] [blame] | 862 | .addTaggedData(MetricsEvent.FIELD_NOTIFICATION_CHANNEL_IMPORTANCE, mImportance) |
| 863 | .addTaggedData(MetricsEvent.FIELD_NOTIFICATION_GROUP_ID, getGroupLogTag()) |
| 864 | .addTaggedData(MetricsEvent.FIELD_NOTIFICATION_GROUP_SUMMARY, |
| 865 | sbn.getNotification().isGroupSummary() ? 1 : 0) |
Chris Wren | 9eb5e10 | 2017-01-26 13:15:06 -0500 | [diff] [blame] | 866 | .addTaggedData(MetricsEvent.NOTIFICATION_SINCE_CREATE_MILLIS, getLifespanMs(now)) |
| 867 | .addTaggedData(MetricsEvent.NOTIFICATION_SINCE_UPDATE_MILLIS, getFreshnessMs(now)) |
| 868 | .addTaggedData(MetricsEvent.NOTIFICATION_SINCE_VISIBLE_MILLIS, getExposureMs(now)); |
| 869 | } |
| 870 | |
| 871 | public LogMaker getLogMaker() { |
| 872 | return getLogMaker(System.currentTimeMillis()); |
| 873 | } |
Julia Reynolds | a33f5c4 | 2017-01-31 16:53:35 -0500 | [diff] [blame] | 874 | |
| 875 | @VisibleForTesting |
| 876 | static final class Light { |
| 877 | public final int color; |
| 878 | public final int onMs; |
| 879 | public final int offMs; |
| 880 | |
| 881 | public Light(int color, int onMs, int offMs) { |
| 882 | this.color = color; |
| 883 | this.onMs = onMs; |
| 884 | this.offMs = offMs; |
| 885 | } |
| 886 | |
| 887 | @Override |
| 888 | public boolean equals(Object o) { |
| 889 | if (this == o) return true; |
| 890 | if (o == null || getClass() != o.getClass()) return false; |
| 891 | |
| 892 | Light light = (Light) o; |
| 893 | |
| 894 | if (color != light.color) return false; |
| 895 | if (onMs != light.onMs) return false; |
| 896 | return offMs == light.offMs; |
| 897 | |
| 898 | } |
| 899 | |
| 900 | @Override |
| 901 | public int hashCode() { |
| 902 | int result = color; |
| 903 | result = 31 * result + onMs; |
| 904 | result = 31 * result + offMs; |
| 905 | return result; |
| 906 | } |
| 907 | |
| 908 | @Override |
| 909 | public String toString() { |
| 910 | return "Light{" + |
| 911 | "color=" + color + |
| 912 | ", onMs=" + onMs + |
| 913 | ", offMs=" + offMs + |
| 914 | '}'; |
| 915 | } |
| 916 | } |
Chris Wren | 333a61c | 2014-05-28 16:40:57 -0400 | [diff] [blame] | 917 | } |