Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 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 | |
| 17 | package com.android.systemui.statusbar.notification.row; |
| 18 | |
Julia Reynolds | 8d25709 | 2020-04-15 15:57:21 -0400 | [diff] [blame] | 19 | import static android.app.NotificationManager.BUBBLE_PREFERENCE_ALL; |
Mady Mellor | a92268c | 2020-03-09 17:25:08 -0700 | [diff] [blame] | 20 | import static android.app.NotificationManager.BUBBLE_PREFERENCE_NONE; |
| 21 | import static android.app.NotificationManager.BUBBLE_PREFERENCE_SELECTED; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 22 | import static android.app.NotificationManager.IMPORTANCE_DEFAULT; |
| 23 | import static android.app.NotificationManager.IMPORTANCE_LOW; |
| 24 | import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 25 | import static android.provider.Settings.Global.NOTIFICATION_BUBBLES; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 26 | |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 27 | import static com.android.systemui.Interpolators.FAST_OUT_SLOW_IN; |
| 28 | |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 29 | import static java.lang.annotation.RetentionPolicy.SOURCE; |
| 30 | |
| 31 | import android.annotation.IntDef; |
| 32 | import android.annotation.NonNull; |
Evan Laird | 03c4445 | 2020-04-16 12:26:07 -0400 | [diff] [blame] | 33 | import android.annotation.Nullable; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 34 | import android.app.INotificationManager; |
| 35 | import android.app.Notification; |
| 36 | import android.app.NotificationChannel; |
| 37 | import android.app.NotificationChannelGroup; |
Julia Reynolds | 8d25709 | 2020-04-15 15:57:21 -0400 | [diff] [blame] | 38 | import android.app.NotificationManager; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 39 | import android.content.Context; |
| 40 | import android.content.Intent; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 41 | import android.content.pm.ApplicationInfo; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 42 | import android.content.pm.PackageManager; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 43 | import android.content.pm.ShortcutInfo; |
| 44 | import android.content.pm.ShortcutManager; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 45 | import android.os.Handler; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 46 | import android.os.RemoteException; |
Julia Reynolds | c535650 | 2020-06-08 16:14:58 -0400 | [diff] [blame] | 47 | import android.os.UserHandle; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 48 | import android.provider.Settings; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 49 | import android.service.notification.StatusBarNotification; |
| 50 | import android.text.TextUtils; |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 51 | import android.transition.ChangeBounds; |
| 52 | import android.transition.Fade; |
| 53 | import android.transition.TransitionManager; |
| 54 | import android.transition.TransitionSet; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 55 | import android.util.AttributeSet; |
| 56 | import android.util.Log; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 57 | import android.view.LayoutInflater; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 58 | import android.view.View; |
| 59 | import android.view.accessibility.AccessibilityEvent; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 60 | import android.widget.ImageView; |
| 61 | import android.widget.LinearLayout; |
| 62 | import android.widget.TextView; |
| 63 | |
| 64 | import com.android.internal.annotations.VisibleForTesting; |
Julia Reynolds | 01c9da4 | 2020-02-14 14:17:58 -0500 | [diff] [blame] | 65 | import com.android.settingslib.notification.ConversationIconFactory; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 66 | import com.android.systemui.Prefs; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 67 | import com.android.systemui.R; |
Steve Elliott | 6771f54 | 2020-05-26 13:31:10 -0400 | [diff] [blame] | 68 | import com.android.systemui.dagger.qualifiers.Background; |
| 69 | import com.android.systemui.dagger.qualifiers.Main; |
Mady Mellor | 9adfe6a | 2020-03-30 17:23:26 -0700 | [diff] [blame] | 70 | import com.android.systemui.statusbar.notification.NotificationChannelHelper; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 71 | import com.android.systemui.statusbar.notification.VisualStabilityManager; |
| 72 | import com.android.systemui.statusbar.notification.collection.NotificationEntry; |
Steve Elliott | 6771f54 | 2020-05-26 13:31:10 -0400 | [diff] [blame] | 73 | import com.android.systemui.statusbar.notification.stack.StackStateAnimator; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 74 | |
| 75 | import java.lang.annotation.Retention; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 76 | |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 77 | import javax.inject.Provider; |
| 78 | |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 79 | /** |
| 80 | * The guts of a conversation notification revealed when performing a long press. |
| 81 | */ |
| 82 | public class NotificationConversationInfo extends LinearLayout implements |
| 83 | NotificationGuts.GutsContent { |
| 84 | private static final String TAG = "ConversationGuts"; |
| 85 | |
| 86 | |
| 87 | private INotificationManager mINotificationManager; |
Steve Elliott | 6771f54 | 2020-05-26 13:31:10 -0400 | [diff] [blame] | 88 | private ShortcutManager mShortcutManager; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 89 | private PackageManager mPm; |
Julia Reynolds | 01c9da4 | 2020-02-14 14:17:58 -0500 | [diff] [blame] | 90 | private ConversationIconFactory mIconFactory; |
Julia Reynolds | d5cc0ea | 2020-04-24 11:30:29 -0400 | [diff] [blame] | 91 | private VisualStabilityManager mVisualStabilityManager; |
Steve Elliott | 6771f54 | 2020-05-26 13:31:10 -0400 | [diff] [blame] | 92 | private Handler mMainHandler; |
| 93 | private Handler mBgHandler; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 94 | |
| 95 | private String mPackageName; |
| 96 | private String mAppName; |
| 97 | private int mAppUid; |
| 98 | private String mDelegatePkg; |
| 99 | private NotificationChannel mNotificationChannel; |
| 100 | private ShortcutInfo mShortcutInfo; |
Steve Elliott | 6771f54 | 2020-05-26 13:31:10 -0400 | [diff] [blame] | 101 | private NotificationEntry mEntry; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 102 | private StatusBarNotification mSbn; |
Evan Laird | 03c4445 | 2020-04-16 12:26:07 -0400 | [diff] [blame] | 103 | @Nullable private Notification.BubbleMetadata mBubbleMetadata; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 104 | private Context mUserContext; |
| 105 | private Provider<PriorityOnboardingDialogController.Builder> mBuilderProvider; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 106 | private boolean mIsDeviceProvisioned; |
Julia Reynolds | 8d25709 | 2020-04-15 15:57:21 -0400 | [diff] [blame] | 107 | private int mAppBubble; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 108 | |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 109 | private TextView mPriorityDescriptionView; |
| 110 | private TextView mDefaultDescriptionView; |
| 111 | private TextView mSilentDescriptionView; |
Julia Reynolds | d5cc0ea | 2020-04-24 11:30:29 -0400 | [diff] [blame] | 112 | |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 113 | private @Action int mSelectedAction = -1; |
Julia Reynolds | d5cc0ea | 2020-04-24 11:30:29 -0400 | [diff] [blame] | 114 | private boolean mPressedApply; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 115 | |
| 116 | private OnSnoozeClickListener mOnSnoozeClickListener; |
| 117 | private OnSettingsClickListener mOnSettingsClickListener; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 118 | private NotificationGuts mGutsContainer; |
Julia Reynolds | e03aa8f | 2020-06-02 11:21:38 -0400 | [diff] [blame] | 119 | private OnConversationSettingsClickListener mOnConversationSettingsClickListener; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 120 | |
| 121 | @VisibleForTesting |
| 122 | boolean mSkipPost = false; |
Selim Cinek | a5a4ee4 | 2020-05-21 15:38:32 -0700 | [diff] [blame] | 123 | private int mActualHeight; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 124 | |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 125 | @Retention(SOURCE) |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 126 | @IntDef({ACTION_DEFAULT, ACTION_HOME, ACTION_FAVORITE, ACTION_SNOOZE, ACTION_MUTE, |
| 127 | ACTION_SETTINGS}) |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 128 | private @interface Action {} |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 129 | static final int ACTION_DEFAULT = 0; |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 130 | static final int ACTION_HOME = 1; |
| 131 | static final int ACTION_FAVORITE = 2; |
| 132 | static final int ACTION_SNOOZE = 3; |
| 133 | static final int ACTION_MUTE = 4; |
| 134 | static final int ACTION_SETTINGS = 5; |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 135 | |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 136 | // TODO: b/152050825 |
| 137 | /* |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 138 | private OnClickListener mOnHomeClick = v -> { |
| 139 | mSelectedAction = ACTION_HOME; |
| 140 | mShortcutManager.requestPinShortcut(mShortcutInfo, null); |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 141 | mShadeController.animateCollapsePanels(); |
Dave Mankoff | c97a0e6 | 2020-06-01 12:13:05 -0400 | [diff] [blame] | 142 | mGutsContainer.closeControls(v, true); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 143 | }; |
| 144 | |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 145 | private OnClickListener mOnSnoozeClick = v -> { |
| 146 | mSelectedAction = ACTION_SNOOZE; |
| 147 | mOnSnoozeClickListener.onClick(v, 1); |
Dave Mankoff | c97a0e6 | 2020-06-01 12:13:05 -0400 | [diff] [blame] | 148 | mGutsContainer.closeControls(v, true); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 149 | }; |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 150 | */ |
| 151 | |
| 152 | private OnClickListener mOnFavoriteClick = v -> { |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 153 | setSelectedAction(ACTION_FAVORITE); |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 154 | updateToggleActions(mSelectedAction, true); |
| 155 | }; |
| 156 | |
| 157 | private OnClickListener mOnDefaultClick = v -> { |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 158 | setSelectedAction(ACTION_DEFAULT); |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 159 | updateToggleActions(mSelectedAction, true); |
| 160 | }; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 161 | |
| 162 | private OnClickListener mOnMuteClick = v -> { |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 163 | setSelectedAction(ACTION_MUTE); |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 164 | updateToggleActions(mSelectedAction, true); |
| 165 | }; |
| 166 | |
| 167 | private OnClickListener mOnDone = v -> { |
Julia Reynolds | d5cc0ea | 2020-04-24 11:30:29 -0400 | [diff] [blame] | 168 | mPressedApply = true; |
Julia Reynolds | e03aa8f | 2020-06-02 11:21:38 -0400 | [diff] [blame] | 169 | // If the user selected Priority, maybe show the priority onboarding |
| 170 | if (mSelectedAction == ACTION_FAVORITE && shouldShowPriorityOnboarding()) { |
| 171 | showPriorityOnboarding(); |
| 172 | } |
Dave Mankoff | c97a0e6 | 2020-06-01 12:13:05 -0400 | [diff] [blame] | 173 | mGutsContainer.closeControls(v, true); |
Julia Reynolds | dcd70d6 | 2020-01-15 10:33:43 -0500 | [diff] [blame] | 174 | }; |
| 175 | |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 176 | public NotificationConversationInfo(Context context, AttributeSet attrs) { |
| 177 | super(context, attrs); |
| 178 | } |
| 179 | |
| 180 | public interface OnSettingsClickListener { |
| 181 | void onClick(View v, NotificationChannel channel, int appUid); |
| 182 | } |
| 183 | |
Julia Reynolds | e03aa8f | 2020-06-02 11:21:38 -0400 | [diff] [blame] | 184 | public interface OnConversationSettingsClickListener { |
| 185 | void onClick(); |
| 186 | } |
| 187 | |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 188 | public interface OnAppSettingsClickListener { |
| 189 | void onClick(View v, Intent intent); |
| 190 | } |
| 191 | |
| 192 | public interface OnSnoozeClickListener { |
| 193 | void onClick(View v, int hoursToSnooze); |
| 194 | } |
| 195 | |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 196 | @VisibleForTesting |
| 197 | void setSelectedAction(int selectedAction) { |
| 198 | if (mSelectedAction == selectedAction) { |
| 199 | return; |
| 200 | } |
| 201 | |
| 202 | mSelectedAction = selectedAction; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 203 | } |
| 204 | |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 205 | public void bindNotification( |
| 206 | ShortcutManager shortcutManager, |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 207 | PackageManager pm, |
| 208 | INotificationManager iNotificationManager, |
| 209 | VisualStabilityManager visualStabilityManager, |
| 210 | String pkg, |
| 211 | NotificationChannel notificationChannel, |
| 212 | NotificationEntry entry, |
Evan Laird | 03c4445 | 2020-04-16 12:26:07 -0400 | [diff] [blame] | 213 | Notification.BubbleMetadata bubbleMetadata, |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 214 | OnSettingsClickListener onSettingsClick, |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 215 | OnSnoozeClickListener onSnoozeClickListener, |
Julia Reynolds | 01c9da4 | 2020-02-14 14:17:58 -0500 | [diff] [blame] | 216 | ConversationIconFactory conversationIconFactory, |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 217 | Context userContext, |
| 218 | Provider<PriorityOnboardingDialogController.Builder> builderProvider, |
Steve Elliott | 6771f54 | 2020-05-26 13:31:10 -0400 | [diff] [blame] | 219 | boolean isDeviceProvisioned, |
| 220 | @Main Handler mainHandler, |
Julia Reynolds | e03aa8f | 2020-06-02 11:21:38 -0400 | [diff] [blame] | 221 | @Background Handler bgHandler, |
| 222 | OnConversationSettingsClickListener onConversationSettingsClickListener) { |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 223 | mSelectedAction = -1; |
| 224 | mINotificationManager = iNotificationManager; |
| 225 | mVisualStabilityManager = visualStabilityManager; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 226 | mPackageName = pkg; |
Steve Elliott | 6771f54 | 2020-05-26 13:31:10 -0400 | [diff] [blame] | 227 | mEntry = entry; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 228 | mSbn = entry.getSbn(); |
| 229 | mPm = pm; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 230 | mAppName = mPackageName; |
| 231 | mOnSettingsClickListener = onSettingsClick; |
| 232 | mNotificationChannel = notificationChannel; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 233 | mAppUid = mSbn.getUid(); |
| 234 | mDelegatePkg = mSbn.getOpPkg(); |
| 235 | mIsDeviceProvisioned = isDeviceProvisioned; |
| 236 | mOnSnoozeClickListener = onSnoozeClickListener; |
Julia Reynolds | e03aa8f | 2020-06-02 11:21:38 -0400 | [diff] [blame] | 237 | mOnConversationSettingsClickListener = onConversationSettingsClickListener; |
Julia Reynolds | 01c9da4 | 2020-02-14 14:17:58 -0500 | [diff] [blame] | 238 | mIconFactory = conversationIconFactory; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 239 | mUserContext = userContext; |
Evan Laird | 03c4445 | 2020-04-16 12:26:07 -0400 | [diff] [blame] | 240 | mBubbleMetadata = bubbleMetadata; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 241 | mBuilderProvider = builderProvider; |
Steve Elliott | 6771f54 | 2020-05-26 13:31:10 -0400 | [diff] [blame] | 242 | mMainHandler = mainHandler; |
| 243 | mBgHandler = bgHandler; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 244 | mShortcutManager = shortcutManager; |
Julia Reynolds | 8582df5 | 2020-04-24 18:30:59 -0400 | [diff] [blame] | 245 | mShortcutInfo = entry.getRanking().getShortcutInfo(); |
| 246 | if (mShortcutInfo == null) { |
Julia Reynolds | 7c26752 | 2020-01-16 11:26:41 -0500 | [diff] [blame] | 247 | throw new IllegalArgumentException("Does not have required information"); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 248 | } |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 249 | |
Mady Mellor | 9adfe6a | 2020-03-30 17:23:26 -0700 | [diff] [blame] | 250 | mNotificationChannel = NotificationChannelHelper.createConversationChannelIfNeeded( |
| 251 | getContext(), mINotificationManager, entry, mNotificationChannel); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 252 | |
Julia Reynolds | 8d25709 | 2020-04-15 15:57:21 -0400 | [diff] [blame] | 253 | try { |
| 254 | mAppBubble = mINotificationManager.getBubblePreferenceForPackage(mPackageName, mAppUid); |
| 255 | } catch (RemoteException e) { |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 256 | Log.e(TAG, "can't reach OS", e); |
Julia Reynolds | 8d25709 | 2020-04-15 15:57:21 -0400 | [diff] [blame] | 257 | mAppBubble = BUBBLE_PREFERENCE_SELECTED; |
| 258 | } |
| 259 | |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 260 | bindHeader(); |
| 261 | bindActions(); |
| 262 | |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 263 | View done = findViewById(R.id.done); |
| 264 | done.setOnClickListener(mOnDone); |
Dave Mankoff | c97a0e6 | 2020-06-01 12:13:05 -0400 | [diff] [blame] | 265 | done.setAccessibilityDelegate(mGutsContainer.getAccessibilityDelegate()); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 266 | } |
| 267 | |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 268 | private void bindActions() { |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 269 | |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 270 | // TODO: b/152050825 |
| 271 | /* |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 272 | Button home = findViewById(R.id.home); |
| 273 | home.setOnClickListener(mOnHomeClick); |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 274 | home.setVisibility(mShortcutInfo != null |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 275 | && mShortcutManager.isRequestPinShortcutSupported() |
| 276 | ? VISIBLE : GONE); |
| 277 | |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 278 | Button snooze = findViewById(R.id.snooze); |
| 279 | snooze.setOnClickListener(mOnSnoozeClick); |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 280 | */ |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 281 | |
Julia Reynolds | 8d25709 | 2020-04-15 15:57:21 -0400 | [diff] [blame] | 282 | if (mAppBubble == BUBBLE_PREFERENCE_ALL) { |
| 283 | ((TextView) findViewById(R.id.default_summary)).setText(getResources().getString( |
| 284 | R.string.notification_channel_summary_default_with_bubbles, mAppName)); |
| 285 | } |
| 286 | |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 287 | findViewById(R.id.priority).setOnClickListener(mOnFavoriteClick); |
| 288 | findViewById(R.id.default_behavior).setOnClickListener(mOnDefaultClick); |
| 289 | findViewById(R.id.silence).setOnClickListener(mOnMuteClick); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 290 | |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 291 | final View settingsButton = findViewById(R.id.info); |
| 292 | settingsButton.setOnClickListener(getSettingsOnClickListener()); |
| 293 | settingsButton.setVisibility(settingsButton.hasOnClickListeners() ? VISIBLE : GONE); |
| 294 | |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 295 | updateToggleActions(getSelectedAction(), false); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | private void bindHeader() { |
| 299 | bindConversationDetails(); |
| 300 | |
| 301 | // Delegate |
| 302 | bindDelegate(); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | private OnClickListener getSettingsOnClickListener() { |
| 306 | if (mAppUid >= 0 && mOnSettingsClickListener != null && mIsDeviceProvisioned) { |
| 307 | final int appUidF = mAppUid; |
| 308 | return ((View view) -> { |
| 309 | mOnSettingsClickListener.onClick(view, mNotificationChannel, appUidF); |
| 310 | }); |
| 311 | } |
| 312 | return null; |
| 313 | } |
| 314 | |
| 315 | private void bindConversationDetails() { |
| 316 | final TextView channelName = findViewById(R.id.parent_channel_name); |
| 317 | channelName.setText(mNotificationChannel.getName()); |
| 318 | |
| 319 | bindGroup(); |
Julia Reynolds | f2acd60 | 2020-01-21 16:01:25 -0500 | [diff] [blame] | 320 | // TODO: bring back when channel name does not include name |
| 321 | // bindName(); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 322 | bindPackage(); |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 323 | bindIcon(mNotificationChannel.isImportantConversation()); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 324 | } |
| 325 | |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 326 | private void bindIcon(boolean important) { |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 327 | ImageView image = findViewById(R.id.conversation_icon); |
Julia Reynolds | 8582df5 | 2020-04-24 18:30:59 -0400 | [diff] [blame] | 328 | image.setImageDrawable(mIconFactory.getConversationDrawable( |
| 329 | mShortcutInfo, mPackageName, mAppUid, important)); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 330 | } |
| 331 | |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 332 | private void bindPackage() { |
| 333 | ApplicationInfo info; |
| 334 | try { |
| 335 | info = mPm.getApplicationInfo( |
| 336 | mPackageName, |
| 337 | PackageManager.MATCH_UNINSTALLED_PACKAGES |
| 338 | | PackageManager.MATCH_DISABLED_COMPONENTS |
| 339 | | PackageManager.MATCH_DIRECT_BOOT_UNAWARE |
| 340 | | PackageManager.MATCH_DIRECT_BOOT_AWARE); |
| 341 | if (info != null) { |
| 342 | mAppName = String.valueOf(mPm.getApplicationLabel(info)); |
| 343 | } |
| 344 | } catch (PackageManager.NameNotFoundException e) { |
| 345 | } |
| 346 | ((TextView) findViewById(R.id.pkg_name)).setText(mAppName); |
| 347 | } |
| 348 | |
| 349 | private void bindDelegate() { |
| 350 | TextView delegateView = findViewById(R.id.delegate_name); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 351 | |
| 352 | if (!TextUtils.equals(mPackageName, mDelegatePkg)) { |
| 353 | // this notification was posted by a delegate! |
| 354 | delegateView.setVisibility(View.VISIBLE); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 355 | } else { |
| 356 | delegateView.setVisibility(View.GONE); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 357 | } |
| 358 | } |
| 359 | |
| 360 | private void bindGroup() { |
| 361 | // Set group information if this channel has an associated group. |
| 362 | CharSequence groupName = null; |
| 363 | if (mNotificationChannel != null && mNotificationChannel.getGroup() != null) { |
| 364 | try { |
| 365 | final NotificationChannelGroup notificationChannelGroup = |
| 366 | mINotificationManager.getNotificationChannelGroupForPackage( |
| 367 | mNotificationChannel.getGroup(), mPackageName, mAppUid); |
| 368 | if (notificationChannelGroup != null) { |
| 369 | groupName = notificationChannelGroup.getName(); |
| 370 | } |
| 371 | } catch (RemoteException e) { |
| 372 | } |
| 373 | } |
| 374 | TextView groupNameView = findViewById(R.id.group_name); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 375 | if (groupName != null) { |
| 376 | groupNameView.setText(groupName); |
| 377 | groupNameView.setVisibility(VISIBLE); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 378 | } else { |
| 379 | groupNameView.setVisibility(GONE); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 380 | } |
| 381 | } |
| 382 | |
| 383 | @Override |
| 384 | public boolean post(Runnable action) { |
| 385 | if (mSkipPost) { |
| 386 | action.run(); |
| 387 | return true; |
| 388 | } else { |
| 389 | return super.post(action); |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | @Override |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 394 | protected void onFinishInflate() { |
| 395 | super.onFinishInflate(); |
| 396 | |
| 397 | mPriorityDescriptionView = findViewById(R.id.priority_summary); |
| 398 | mDefaultDescriptionView = findViewById(R.id.default_summary); |
| 399 | mSilentDescriptionView = findViewById(R.id.silence_summary); |
| 400 | } |
| 401 | |
| 402 | @Override |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 403 | public void onFinishedClosing() { |
| 404 | // TODO: do we need to do anything here? |
| 405 | } |
| 406 | |
| 407 | @Override |
Julia Reynolds | be37107 | 2020-05-28 11:32:01 -0400 | [diff] [blame] | 408 | public boolean needsFalsingProtection() { |
| 409 | return true; |
| 410 | } |
| 411 | |
| 412 | @Override |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 413 | public void onInitializeAccessibilityEvent(AccessibilityEvent event) { |
| 414 | super.onInitializeAccessibilityEvent(event); |
| 415 | if (mGutsContainer != null && |
| 416 | event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { |
| 417 | if (mGutsContainer.isExposed()) { |
| 418 | event.getText().add(mContext.getString( |
| 419 | R.string.notification_channel_controls_opened_accessibility, mAppName)); |
| 420 | } else { |
| 421 | event.getText().add(mContext.getString( |
| 422 | R.string.notification_channel_controls_closed_accessibility, mAppName)); |
| 423 | } |
| 424 | } |
| 425 | } |
| 426 | |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 427 | private void updateToggleActions(int selectedAction, boolean userTriggered) { |
| 428 | if (userTriggered) { |
| 429 | TransitionSet transition = new TransitionSet(); |
| 430 | transition.setOrdering(TransitionSet.ORDERING_TOGETHER); |
| 431 | transition.addTransition(new Fade(Fade.OUT)) |
| 432 | .addTransition(new ChangeBounds()) |
| 433 | .addTransition( |
| 434 | new Fade(Fade.IN) |
| 435 | .setStartDelay(150) |
| 436 | .setDuration(200) |
| 437 | .setInterpolator(FAST_OUT_SLOW_IN)); |
| 438 | transition.setDuration(350); |
| 439 | transition.setInterpolator(FAST_OUT_SLOW_IN); |
| 440 | TransitionManager.beginDelayedTransition(this, transition); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 441 | } |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 442 | |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 443 | View priority = findViewById(R.id.priority); |
| 444 | View defaultBehavior = findViewById(R.id.default_behavior); |
| 445 | View silence = findViewById(R.id.silence); |
| 446 | |
| 447 | switch (selectedAction) { |
| 448 | case ACTION_FAVORITE: |
| 449 | mPriorityDescriptionView.setVisibility(VISIBLE); |
| 450 | mDefaultDescriptionView.setVisibility(GONE); |
| 451 | mSilentDescriptionView.setVisibility(GONE); |
| 452 | post(() -> { |
| 453 | priority.setSelected(true); |
| 454 | defaultBehavior.setSelected(false); |
| 455 | silence.setSelected(false); |
| 456 | }); |
| 457 | break; |
| 458 | |
| 459 | case ACTION_MUTE: |
| 460 | mSilentDescriptionView.setVisibility(VISIBLE); |
| 461 | mDefaultDescriptionView.setVisibility(GONE); |
| 462 | mPriorityDescriptionView.setVisibility(GONE); |
| 463 | post(() -> { |
| 464 | priority.setSelected(false); |
| 465 | defaultBehavior.setSelected(false); |
| 466 | silence.setSelected(true); |
| 467 | }); |
| 468 | break; |
| 469 | |
| 470 | case ACTION_DEFAULT: |
| 471 | mDefaultDescriptionView.setVisibility(VISIBLE); |
| 472 | mSilentDescriptionView.setVisibility(GONE); |
| 473 | mPriorityDescriptionView.setVisibility(GONE); |
| 474 | post(() -> { |
| 475 | priority.setSelected(false); |
| 476 | defaultBehavior.setSelected(true); |
| 477 | silence.setSelected(false); |
| 478 | }); |
| 479 | break; |
| 480 | |
| 481 | default: |
| 482 | throw new IllegalArgumentException("Unrecognized behavior: " + mSelectedAction); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 483 | } |
Dan Sandler | b11f2de | 2020-02-19 13:18:24 -0500 | [diff] [blame] | 484 | |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 485 | boolean isAChange = getSelectedAction() != selectedAction; |
| 486 | TextView done = findViewById(R.id.done); |
| 487 | done.setText(isAChange |
| 488 | ? R.string.inline_ok_button |
| 489 | : R.string.inline_done_button); |
| 490 | |
Dan Sandler | b11f2de | 2020-02-19 13:18:24 -0500 | [diff] [blame] | 491 | // update icon in case importance has changed |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 492 | bindIcon(selectedAction == ACTION_FAVORITE); |
| 493 | } |
| 494 | |
| 495 | int getSelectedAction() { |
| 496 | if (mNotificationChannel.getImportance() <= IMPORTANCE_LOW |
| 497 | && mNotificationChannel.getImportance() > IMPORTANCE_UNSPECIFIED) { |
| 498 | return ACTION_MUTE; |
| 499 | } else { |
| 500 | if (mNotificationChannel.isImportantConversation()) { |
| 501 | return ACTION_FAVORITE; |
| 502 | } |
| 503 | } |
| 504 | return ACTION_DEFAULT; |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 505 | } |
| 506 | |
| 507 | private void updateChannel() { |
Steve Elliott | 6771f54 | 2020-05-26 13:31:10 -0400 | [diff] [blame] | 508 | mBgHandler.post( |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 509 | new UpdateChannelRunnable(mINotificationManager, mPackageName, |
| 510 | mAppUid, mSelectedAction, mNotificationChannel)); |
Steve Elliott | 8b4929d | 2020-06-02 13:38:04 -0400 | [diff] [blame] | 511 | mEntry.markForUserTriggeredMovement(true); |
| 512 | mMainHandler.postDelayed( |
| 513 | mVisualStabilityManager::temporarilyAllowReordering, |
| 514 | StackStateAnimator.ANIMATION_DURATION_STANDARD); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 515 | } |
| 516 | |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 517 | private boolean shouldShowPriorityOnboarding() { |
| 518 | return !Prefs.getBoolean(mUserContext, Prefs.Key.HAS_SEEN_PRIORITY_ONBOARDING, false); |
| 519 | } |
| 520 | |
| 521 | private void showPriorityOnboarding() { |
| 522 | View onboardingView = LayoutInflater.from(mContext) |
| 523 | .inflate(R.layout.priority_onboarding_half_shell, null); |
| 524 | |
| 525 | boolean ignoreDnd = false; |
| 526 | try { |
Julia Reynolds | e03aa8f | 2020-06-02 11:21:38 -0400 | [diff] [blame] | 527 | ignoreDnd = mINotificationManager |
| 528 | .getConsolidatedNotificationPolicy().priorityConversationSenders == |
| 529 | NotificationManager.Policy.CONVERSATION_SENDERS_IMPORTANT; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 530 | } catch (RemoteException e) { |
| 531 | Log.e(TAG, "Could not check conversation senders", e); |
| 532 | } |
| 533 | |
Evan Laird | 03c4445 | 2020-04-16 12:26:07 -0400 | [diff] [blame] | 534 | boolean showAsBubble = mBubbleMetadata != null |
| 535 | && mBubbleMetadata.getAutoExpandBubble() |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 536 | && Settings.Global.getInt(mContext.getContentResolver(), |
| 537 | NOTIFICATION_BUBBLES, 0) == 1; |
| 538 | |
| 539 | PriorityOnboardingDialogController controller = mBuilderProvider.get() |
| 540 | .setContext(mUserContext) |
| 541 | .setView(onboardingView) |
| 542 | .setIgnoresDnd(ignoreDnd) |
| 543 | .setShowsAsBubble(showAsBubble) |
Julia Reynolds | c535650 | 2020-06-08 16:14:58 -0400 | [diff] [blame] | 544 | .setIcon(mIconFactory.getBaseIconDrawable(mShortcutInfo)) |
| 545 | .setBadge(mIconFactory.getAppBadge( |
| 546 | mPackageName, UserHandle.getUserId(mSbn.getUid()))) |
Julia Reynolds | e03aa8f | 2020-06-02 11:21:38 -0400 | [diff] [blame] | 547 | .setOnSettingsClick(mOnConversationSettingsClickListener) |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 548 | .build(); |
| 549 | |
| 550 | controller.init(); |
| 551 | controller.show(); |
| 552 | } |
| 553 | |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 554 | @Override |
| 555 | public void setGutsParent(NotificationGuts guts) { |
| 556 | mGutsContainer = guts; |
| 557 | } |
| 558 | |
| 559 | @Override |
| 560 | public boolean willBeRemoved() { |
| 561 | return false; |
| 562 | } |
| 563 | |
| 564 | @Override |
| 565 | public boolean shouldBeSaved() { |
Julia Reynolds | d5cc0ea | 2020-04-24 11:30:29 -0400 | [diff] [blame] | 566 | return mPressedApply; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | @Override |
| 570 | public View getContentView() { |
| 571 | return this; |
| 572 | } |
| 573 | |
| 574 | @Override |
| 575 | public boolean handleCloseControls(boolean save, boolean force) { |
| 576 | if (save && mSelectedAction > -1) { |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 577 | updateChannel(); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 578 | } |
| 579 | return false; |
| 580 | } |
| 581 | |
| 582 | @Override |
| 583 | public int getActualHeight() { |
Selim Cinek | a5a4ee4 | 2020-05-21 15:38:32 -0700 | [diff] [blame] | 584 | // Because we're animating the bounds, getHeight will return the small height at the |
| 585 | // beginning of the animation. Instead we'd want it to already return the end value |
| 586 | return mActualHeight; |
| 587 | } |
| 588 | |
| 589 | @Override |
| 590 | protected void onLayout(boolean changed, int l, int t, int r, int b) { |
| 591 | super.onLayout(changed, l, t, r, b); |
| 592 | mActualHeight = getHeight(); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 593 | } |
| 594 | |
| 595 | @VisibleForTesting |
| 596 | public boolean isAnimating() { |
| 597 | return false; |
| 598 | } |
| 599 | |
Julia Reynolds | e6fed50 | 2020-02-07 14:41:02 -0500 | [diff] [blame] | 600 | class UpdateChannelRunnable implements Runnable { |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 601 | |
| 602 | private final INotificationManager mINotificationManager; |
| 603 | private final String mAppPkg; |
| 604 | private final int mAppUid; |
| 605 | private NotificationChannel mChannelToUpdate; |
| 606 | private final @Action int mAction; |
| 607 | |
| 608 | public UpdateChannelRunnable(INotificationManager notificationManager, |
| 609 | String packageName, int appUid, @Action int action, |
| 610 | @NonNull NotificationChannel channelToUpdate) { |
| 611 | mINotificationManager = notificationManager; |
| 612 | mAppPkg = packageName; |
| 613 | mAppUid = appUid; |
| 614 | mChannelToUpdate = channelToUpdate; |
| 615 | mAction = action; |
| 616 | } |
| 617 | |
| 618 | @Override |
| 619 | public void run() { |
| 620 | try { |
| 621 | switch (mAction) { |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 622 | case ACTION_FAVORITE: |
Julia Reynolds | e03aa8f | 2020-06-02 11:21:38 -0400 | [diff] [blame] | 623 | mChannelToUpdate.setImportantConversation(true); |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 624 | if (mChannelToUpdate.isImportantConversation()) { |
Julia Reynolds | 908201e | 2020-02-17 21:53:49 -0500 | [diff] [blame] | 625 | mChannelToUpdate.setAllowBubbles(true); |
Julia Reynolds | 8d25709 | 2020-04-15 15:57:21 -0400 | [diff] [blame] | 626 | if (mAppBubble == BUBBLE_PREFERENCE_NONE) { |
Mady Mellor | a92268c | 2020-03-09 17:25:08 -0700 | [diff] [blame] | 627 | mINotificationManager.setBubblesAllowed(mAppPkg, mAppUid, |
| 628 | BUBBLE_PREFERENCE_SELECTED); |
| 629 | } |
Julia Reynolds | 908201e | 2020-02-17 21:53:49 -0500 | [diff] [blame] | 630 | } |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 631 | mChannelToUpdate.setImportance(Math.max( |
| 632 | mChannelToUpdate.getOriginalImportance(), IMPORTANCE_DEFAULT)); |
| 633 | break; |
| 634 | case ACTION_DEFAULT: |
| 635 | mChannelToUpdate.setImportance(Math.max( |
| 636 | mChannelToUpdate.getOriginalImportance(), IMPORTANCE_DEFAULT)); |
| 637 | if (mChannelToUpdate.isImportantConversation()) { |
| 638 | mChannelToUpdate.setImportantConversation(false); |
| 639 | mChannelToUpdate.setAllowBubbles(false); |
| 640 | } |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 641 | break; |
| 642 | case ACTION_MUTE: |
| 643 | if (mChannelToUpdate.getImportance() == IMPORTANCE_UNSPECIFIED |
| 644 | || mChannelToUpdate.getImportance() >= IMPORTANCE_DEFAULT) { |
| 645 | mChannelToUpdate.setImportance(IMPORTANCE_LOW); |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 646 | } |
| 647 | if (mChannelToUpdate.isImportantConversation()) { |
| 648 | mChannelToUpdate.setImportantConversation(false); |
| 649 | mChannelToUpdate.setAllowBubbles(false); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 650 | } |
| 651 | break; |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 652 | } |
| 653 | |
Julia Reynolds | a856e49 | 2020-03-18 17:30:06 -0400 | [diff] [blame] | 654 | mINotificationManager.updateNotificationChannelForPackage( |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 655 | mAppPkg, mAppUid, mChannelToUpdate); |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 656 | } catch (RemoteException e) { |
| 657 | Log.e(TAG, "Unable to update notification channel", e); |
| 658 | } |
| 659 | } |
| 660 | } |
Julia Reynolds | 12ba4cf | 2020-01-10 16:01:38 -0500 | [diff] [blame] | 661 | } |