blob: 9a41e136e6558e17b99e3158c19014714e674f34 [file] [log] [blame]
Mady Mellorc3d6f7d2018-11-07 09:36:56 -08001/*
2 * Copyright (C) 2018 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
17package com.android.systemui.bubbles;
18
Mady Mellorc2ff0112019-03-28 14:18:06 -070019import static android.service.notification.NotificationListenerService.REASON_APP_CANCEL;
20import static android.service.notification.NotificationListenerService.REASON_APP_CANCEL_ALL;
21import static android.service.notification.NotificationListenerService.REASON_CANCEL;
22import static android.service.notification.NotificationListenerService.REASON_CANCEL_ALL;
Mady Mellor390bff42019-04-05 15:09:01 -070023import static android.view.Display.DEFAULT_DISPLAY;
24import static android.view.Display.INVALID_DISPLAY;
Mady Mellord1c78b262018-11-06 18:04:40 -080025import static android.view.View.INVISIBLE;
Mady Mellorc3d6f7d2018-11-07 09:36:56 -080026import static android.view.View.VISIBLE;
Joshua Tsujib1a796b2019-01-16 15:43:12 -080027import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
Mady Mellorc3d6f7d2018-11-07 09:36:56 -080028
Mady Mellor3f2efdb2018-11-21 11:30:45 -080029import static com.android.systemui.statusbar.StatusBarState.SHADE;
Mady Mellor1a4e86f2019-05-03 16:07:23 -070030import static com.android.systemui.statusbar.notification.NotificationEntryManager.UNDEFINED_DISMISS_REASON;
Mady Mellorc3d6f7d2018-11-07 09:36:56 -080031
Mark Renoufba5ab512019-05-02 15:21:01 -040032import static java.lang.annotation.ElementType.FIELD;
33import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
34import static java.lang.annotation.ElementType.PARAMETER;
Mark Renouf08bc42a2019-03-07 13:01:59 -050035import static java.lang.annotation.RetentionPolicy.SOURCE;
36
Mady Mellorb4991e62019-01-10 15:14:51 -080037import android.annotation.Nullable;
Mady Mellore80930e2019-03-21 16:00:45 -070038import android.app.ActivityManager;
Mark Renoufc808f062019-02-07 15:20:37 -050039import android.app.ActivityManager.RunningTaskInfo;
Mark Renoufcecc77b2019-01-30 16:32:24 -050040import android.app.ActivityTaskManager;
41import android.app.IActivityTaskManager;
Mady Mellor5549dd22018-11-06 18:07:34 -080042import android.app.Notification;
Mady Mellor66efd5e2019-05-15 13:38:11 -070043import android.app.NotificationManager;
Mady Mellorc3d6f7d2018-11-07 09:36:56 -080044import android.content.Context;
Joshua Tsujia19515f2019-02-13 18:02:29 -050045import android.content.pm.ParceledListSlice;
Joshua Tsujif418f9e2019-04-04 17:09:53 -040046import android.content.res.Configuration;
Mady Mellord1c78b262018-11-06 18:04:40 -080047import android.graphics.Rect;
Mark Renoufcecc77b2019-01-30 16:32:24 -050048import android.os.RemoteException;
Mady Mellorb4991e62019-01-10 15:14:51 -080049import android.os.ServiceManager;
Mady Mellorceced172018-11-27 11:18:39 -080050import android.provider.Settings;
Mady Mellor5549dd22018-11-06 18:07:34 -080051import android.service.notification.StatusBarNotification;
Mark Renouf9ba6cea2019-04-17 11:53:50 -040052import android.util.Log;
Mark Renouf82a40e62019-05-23 16:16:24 -040053import android.util.Pair;
Mark Renoufcecc77b2019-01-30 16:32:24 -050054import android.view.Display;
Joshua Tsujia19515f2019-02-13 18:02:29 -050055import android.view.IPinnedStackController;
56import android.view.IPinnedStackListener;
Mady Mellorc3d6f7d2018-11-07 09:36:56 -080057import android.view.ViewGroup;
Mady Mellorc3d6f7d2018-11-07 09:36:56 -080058import android.widget.FrameLayout;
59
Mark Renouf08bc42a2019-03-07 13:01:59 -050060import androidx.annotation.IntDef;
Mark Renouf658c6bc2019-01-30 10:26:54 -050061import androidx.annotation.MainThread;
62
Mady Mellorebdbbb92018-11-15 14:36:48 -080063import com.android.internal.annotations.VisibleForTesting;
Mady Mellora54e9fa2019-04-18 13:26:18 -070064import com.android.internal.statusbar.IStatusBarService;
Ned Burns01e38212019-01-03 16:32:52 -050065import com.android.systemui.Dependency;
Mady Mellorc3d6f7d2018-11-07 09:36:56 -080066import com.android.systemui.R;
Beverly8fdb5332019-02-04 14:29:49 -050067import com.android.systemui.plugins.statusbar.StatusBarStateController;
Mark Renoufcecc77b2019-01-30 16:32:24 -050068import com.android.systemui.shared.system.ActivityManagerWrapper;
69import com.android.systemui.shared.system.TaskStackChangeListener;
Joshua Tsujia19515f2019-02-13 18:02:29 -050070import com.android.systemui.shared.system.WindowManagerWrapper;
Mady Mellorc2ff0112019-03-28 14:18:06 -070071import com.android.systemui.statusbar.NotificationRemoveInterceptor;
Ned Burns01e38212019-01-03 16:32:52 -050072import com.android.systemui.statusbar.notification.NotificationEntryListener;
73import com.android.systemui.statusbar.notification.NotificationEntryManager;
Mady Mellor3f2efdb2018-11-21 11:30:45 -080074import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
Ned Burnsf81c4c42019-01-07 14:10:43 -050075import com.android.systemui.statusbar.notification.collection.NotificationEntry;
Ned Burns1a5e22f2019-02-14 15:11:52 -050076import com.android.systemui.statusbar.notification.row.NotificationContentInflater.InflationFlag;
Mady Mellorc3d6f7d2018-11-07 09:36:56 -080077import com.android.systemui.statusbar.phone.StatusBarWindowController;
Lyn Hanf1c9b8b2019-03-14 16:49:48 -070078import com.android.systemui.statusbar.policy.ConfigurationController;
Mady Mellorc3d6f7d2018-11-07 09:36:56 -080079
Mark Renouf08bc42a2019-03-07 13:01:59 -050080import java.lang.annotation.Retention;
Mark Renoufba5ab512019-05-02 15:21:01 -040081import java.lang.annotation.Target;
Mady Mellore80930e2019-03-21 16:00:45 -070082import java.util.List;
Mark Renouf08bc42a2019-03-07 13:01:59 -050083
Jason Monk27d01a622018-12-10 15:57:09 -050084import javax.inject.Inject;
85import javax.inject.Singleton;
86
Mady Mellorc3d6f7d2018-11-07 09:36:56 -080087/**
88 * Bubbles are a special type of content that can "float" on top of other apps or System UI.
89 * Bubbles can be expanded to show more content.
90 *
91 * The controller manages addition, removal, and visible state of bubbles on screen.
92 */
Jason Monk27d01a622018-12-10 15:57:09 -050093@Singleton
Mark Renouf71a3af62019-04-08 15:02:54 -040094public class BubbleController implements ConfigurationController.ConfigurationListener {
Mady Mellorc3d6f7d2018-11-07 09:36:56 -080095
96 private static final String TAG = "BubbleController";
Mark Renoufba5ab512019-05-02 15:21:01 -040097 private static final boolean DEBUG = false;
Mady Mellorc3d6f7d2018-11-07 09:36:56 -080098
Mark Renouf08bc42a2019-03-07 13:01:59 -050099 @Retention(SOURCE)
100 @IntDef({DISMISS_USER_GESTURE, DISMISS_AGED, DISMISS_TASK_FINISHED, DISMISS_BLOCKED,
Mady Melloraa8fef22019-04-11 13:36:40 -0700101 DISMISS_NOTIF_CANCEL, DISMISS_ACCESSIBILITY_ACTION, DISMISS_NO_LONGER_BUBBLE})
Mark Renoufba5ab512019-05-02 15:21:01 -0400102 @Target({FIELD, LOCAL_VARIABLE, PARAMETER})
Mark Renouf08bc42a2019-03-07 13:01:59 -0500103 @interface DismissReason {}
Lyn Hanf1c9b8b2019-03-14 16:49:48 -0700104
Mark Renouf08bc42a2019-03-07 13:01:59 -0500105 static final int DISMISS_USER_GESTURE = 1;
106 static final int DISMISS_AGED = 2;
107 static final int DISMISS_TASK_FINISHED = 3;
108 static final int DISMISS_BLOCKED = 4;
109 static final int DISMISS_NOTIF_CANCEL = 5;
110 static final int DISMISS_ACCESSIBILITY_ACTION = 6;
Mady Melloraa8fef22019-04-11 13:36:40 -0700111 static final int DISMISS_NO_LONGER_BUBBLE = 7;
Mark Renouf08bc42a2019-03-07 13:01:59 -0500112
Joshua Tsuji4accf5982019-04-22 17:36:11 -0400113 public static final int MAX_BUBBLES = 5; // TODO: actually enforce this
Joshua Tsuji25a4b7b2019-03-22 14:11:06 -0400114
Mady Mellor5549dd22018-11-06 18:07:34 -0800115 // Enables some subset of notifs to automatically become bubbles
Ned Burns01e38212019-01-03 16:32:52 -0500116 private static final boolean DEBUG_ENABLE_AUTO_BUBBLE = false;
Mady Mellor5549dd22018-11-06 18:07:34 -0800117
Mady Mellor44ee2fe2019-01-30 17:51:16 -0800118 /** Flag to enable or disable the entire feature */
Mady Mellorf6e3ac02019-01-29 10:37:52 -0800119 private static final String ENABLE_BUBBLES = "experiment_enable_bubbles";
Mady Mellor44ee2fe2019-01-30 17:51:16 -0800120 /** Auto bubble flags set whether different notif types should be presented as a bubble */
Mady Mellorceced172018-11-27 11:18:39 -0800121 private static final String ENABLE_AUTO_BUBBLE_MESSAGES = "experiment_autobubble_messaging";
122 private static final String ENABLE_AUTO_BUBBLE_ONGOING = "experiment_autobubble_ongoing";
123 private static final String ENABLE_AUTO_BUBBLE_ALL = "experiment_autobubble_all";
Mady Mellor44ee2fe2019-01-30 17:51:16 -0800124
125 /** Use an activityView for an auto-bubbled notifs if it has an appropriate content intent */
Mark Renouf89b1a4a2018-12-04 14:59:45 -0500126 private static final String ENABLE_BUBBLE_CONTENT_INTENT = "experiment_bubble_content_intent";
Mady Mellorceced172018-11-27 11:18:39 -0800127
Joshua Tsuji010c2b12019-02-25 18:11:25 -0500128 private static final String BUBBLE_STIFFNESS = "experiment_bubble_stiffness";
129 private static final String BUBBLE_BOUNCINESS = "experiment_bubble_bounciness";
130
Ned Burns01e38212019-01-03 16:32:52 -0500131 private final Context mContext;
132 private final NotificationEntryManager mNotificationEntryManager;
Mark Renoufcecc77b2019-01-30 16:32:24 -0500133 private final IActivityTaskManager mActivityTaskManager;
134 private final BubbleTaskStackListener mTaskStackListener;
Mady Mellord1c78b262018-11-06 18:04:40 -0800135 private BubbleStateChangeListener mStateChangeListener;
Mady Mellorcd9b1302018-11-06 18:08:04 -0800136 private BubbleExpandListener mExpandListener;
Issei Suzukic0387542019-03-08 17:31:14 +0100137 @Nullable private BubbleStackView.SurfaceSynchronizer mSurfaceSynchronizer;
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800138
Mady Mellor3dff9e62019-02-05 18:12:53 -0800139 private BubbleData mBubbleData;
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800140 private BubbleStackView mStackView;
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800141
142 // Bubbles get added to the status bar view
Ned Burns01e38212019-01-03 16:32:52 -0500143 private final StatusBarWindowController mStatusBarWindowController;
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800144 private StatusBarStateListener mStatusBarStateListener;
145
Mady Melloraa8fef22019-04-11 13:36:40 -0700146 private final NotificationInterruptionStateProvider mNotificationInterruptionStateProvider;
Mady Mellora54e9fa2019-04-18 13:26:18 -0700147 private IStatusBarService mBarService;
Mady Mellorb4991e62019-01-10 15:14:51 -0800148
Mady Mellord1c78b262018-11-06 18:04:40 -0800149 // Used for determining view rect for touch interaction
150 private Rect mTempRect = new Rect();
151
Joshua Tsujif418f9e2019-04-04 17:09:53 -0400152 /** Last known orientation, used to detect orientation changes in {@link #onConfigChanged}. */
153 private int mOrientation = Configuration.ORIENTATION_UNDEFINED;
154
Mady Mellor5549dd22018-11-06 18:07:34 -0800155 /**
Mady Mellord1c78b262018-11-06 18:04:40 -0800156 * Listener to be notified when some states of the bubbles change.
157 */
158 public interface BubbleStateChangeListener {
159 /**
160 * Called when the stack has bubbles or no longer has bubbles.
161 */
162 void onHasBubblesChanged(boolean hasBubbles);
163 }
164
Mady Mellorcd9b1302018-11-06 18:08:04 -0800165 /**
166 * Listener to find out about stack expansion / collapse events.
167 */
168 public interface BubbleExpandListener {
169 /**
170 * Called when the expansion state of the bubble stack changes.
Lyn Hanf1c9b8b2019-03-14 16:49:48 -0700171 *
Mady Mellorcd9b1302018-11-06 18:08:04 -0800172 * @param isExpanding whether it's expanding or collapsing
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800173 * @param key the notification key associated with bubble being expanded
Mady Mellorcd9b1302018-11-06 18:08:04 -0800174 */
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800175 void onBubbleExpandChanged(boolean isExpanding, String key);
176 }
177
178 /**
179 * Listens for the current state of the status bar and updates the visibility state
180 * of bubbles as needed.
181 */
182 private class StatusBarStateListener implements StatusBarStateController.StateListener {
183 private int mState;
184 /**
185 * Returns the current status bar state.
186 */
187 public int getCurrentState() {
188 return mState;
189 }
190
191 @Override
192 public void onStateChanged(int newState) {
193 mState = newState;
Mark Renouf71a3af62019-04-08 15:02:54 -0400194 boolean shouldCollapse = (mState != SHADE);
195 if (shouldCollapse) {
196 collapseStack();
197 }
Lyn Han6c40fe72019-05-08 14:06:33 -0700198 updateStack();
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800199 }
Mady Mellorcd9b1302018-11-06 18:08:04 -0800200 }
201
Jason Monk27d01a622018-12-10 15:57:09 -0500202 @Inject
Mady Mellorcfd06c12019-02-13 14:32:12 -0800203 public BubbleController(Context context, StatusBarWindowController statusBarWindowController,
Mady Melloraa8fef22019-04-11 13:36:40 -0700204 BubbleData data, ConfigurationController configurationController,
Josh Tsuji890a7952019-05-18 01:55:47 +0000205 NotificationInterruptionStateProvider interruptionStateProvider) {
Lyn Hanf1c9b8b2019-03-14 16:49:48 -0700206 this(context, statusBarWindowController, data, null /* synchronizer */,
Josh Tsuji890a7952019-05-18 01:55:47 +0000207 configurationController, interruptionStateProvider);
Issei Suzukic0387542019-03-08 17:31:14 +0100208 }
209
210 public BubbleController(Context context, StatusBarWindowController statusBarWindowController,
Lyn Hanf1c9b8b2019-03-14 16:49:48 -0700211 BubbleData data, @Nullable BubbleStackView.SurfaceSynchronizer synchronizer,
Mady Melloraa8fef22019-04-11 13:36:40 -0700212 ConfigurationController configurationController,
Josh Tsuji890a7952019-05-18 01:55:47 +0000213 NotificationInterruptionStateProvider interruptionStateProvider) {
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800214 mContext = context;
Mady Melloraa8fef22019-04-11 13:36:40 -0700215 mNotificationInterruptionStateProvider = interruptionStateProvider;
216
Lyn Hanf1c9b8b2019-03-14 16:49:48 -0700217 configurationController.addCallback(this /* configurationListener */);
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800218
Mark Renouf9ba6cea2019-04-17 11:53:50 -0400219 mBubbleData = data;
220 mBubbleData.setListener(mBubbleDataListener);
221
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800222 mNotificationEntryManager = Dependency.get(NotificationEntryManager.class);
Ned Burns01e38212019-01-03 16:32:52 -0500223 mNotificationEntryManager.addNotificationEntryListener(mEntryListener);
Mady Mellorc2ff0112019-03-28 14:18:06 -0700224 mNotificationEntryManager.setNotificationRemoveInterceptor(mRemoveInterceptor);
Mady Mellorb4991e62019-01-10 15:14:51 -0800225
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800226 mStatusBarWindowController = statusBarWindowController;
227 mStatusBarStateListener = new StatusBarStateListener();
228 Dependency.get(StatusBarStateController.class).addCallback(mStatusBarStateListener);
Mark Renoufcecc77b2019-01-30 16:32:24 -0500229
230 mActivityTaskManager = ActivityTaskManager.getService();
231 mTaskStackListener = new BubbleTaskStackListener();
232 ActivityManagerWrapper.getInstance().registerTaskStackListener(mTaskStackListener);
Mady Mellor3dff9e62019-02-05 18:12:53 -0800233
Joshua Tsujia19515f2019-02-13 18:02:29 -0500234 try {
235 WindowManagerWrapper.getInstance().addPinnedStackListener(new BubblesImeListener());
236 } catch (RemoteException e) {
237 e.printStackTrace();
238 }
Issei Suzukic0387542019-03-08 17:31:14 +0100239 mSurfaceSynchronizer = synchronizer;
Mady Mellora54e9fa2019-04-18 13:26:18 -0700240
241 mBarService = IStatusBarService.Stub.asInterface(
242 ServiceManager.getService(Context.STATUS_BAR_SERVICE));
Mady Mellor5549dd22018-11-06 18:07:34 -0800243 }
244
Mark Renouf8b6a3c62019-04-09 10:17:40 -0400245 /**
246 * BubbleStackView is lazily created by this method the first time a Bubble is added. This
247 * method initializes the stack view and adds it to the StatusBar just above the scrim.
248 */
249 private void ensureStackViewCreated() {
250 if (mStackView == null) {
251 mStackView = new BubbleStackView(mContext, mBubbleData, mSurfaceSynchronizer);
252 ViewGroup sbv = mStatusBarWindowController.getStatusBarView();
253 // TODO(b/130237686): When you expand the shade on top of expanded bubble, there is no
254 // scrim between bubble and the shade
255 int bubblePosition = sbv.indexOfChild(sbv.findViewById(R.id.scrim_behind)) + 1;
256 sbv.addView(mStackView, bubblePosition,
257 new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
258 if (mExpandListener != null) {
259 mStackView.setExpandListener(mExpandListener);
260 }
Mark Renouf8b6a3c62019-04-09 10:17:40 -0400261 }
262 }
263
Lyn Hanf1c9b8b2019-03-14 16:49:48 -0700264 @Override
265 public void onUiModeChanged() {
266 if (mStackView != null) {
Lyn Han02cca812019-04-02 16:27:32 -0700267 mStackView.onThemeChanged();
Lyn Hanf1c9b8b2019-03-14 16:49:48 -0700268 }
269 }
270
271 @Override
272 public void onOverlayChanged() {
273 if (mStackView != null) {
Lyn Han02cca812019-04-02 16:27:32 -0700274 mStackView.onThemeChanged();
Lyn Hanf1c9b8b2019-03-14 16:49:48 -0700275 }
276 }
277
Joshua Tsujif418f9e2019-04-04 17:09:53 -0400278 @Override
279 public void onConfigChanged(Configuration newConfig) {
280 if (mStackView != null && newConfig != null && newConfig.orientation != mOrientation) {
281 mStackView.onOrientationChanged();
282 mOrientation = newConfig.orientation;
283 }
284 }
285
Mady Mellor5549dd22018-11-06 18:07:34 -0800286 /**
Mady Mellord1c78b262018-11-06 18:04:40 -0800287 * Set a listener to be notified when some states of the bubbles change.
288 */
289 public void setBubbleStateChangeListener(BubbleStateChangeListener listener) {
290 mStateChangeListener = listener;
291 }
292
293 /**
Mady Mellorcd9b1302018-11-06 18:08:04 -0800294 * Set a listener to be notified of bubble expand events.
295 */
296 public void setExpandListener(BubbleExpandListener listener) {
Issei Suzukiac9fcb72019-02-04 17:45:57 +0100297 mExpandListener = ((isExpanding, key) -> {
298 if (listener != null) {
299 listener.onBubbleExpandChanged(isExpanding, key);
300 }
301 mStatusBarWindowController.setBubbleExpanded(isExpanding);
302 });
Mady Mellorcd9b1302018-11-06 18:08:04 -0800303 if (mStackView != null) {
304 mStackView.setExpandListener(mExpandListener);
305 }
306 }
307
308 /**
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800309 * Whether or not there are bubbles present, regardless of them being visible on the
310 * screen (e.g. if on AOD).
311 */
312 public boolean hasBubbles() {
Mady Mellor3dff9e62019-02-05 18:12:53 -0800313 if (mStackView == null) {
314 return false;
315 }
Mark Renouf71a3af62019-04-08 15:02:54 -0400316 return mBubbleData.hasBubbles();
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800317 }
318
319 /**
320 * Whether the stack of bubbles is expanded or not.
321 */
322 public boolean isStackExpanded() {
Mark Renouf71a3af62019-04-08 15:02:54 -0400323 return mBubbleData.isExpanded();
324 }
325
326 /**
327 * Tell the stack of bubbles to expand.
328 */
329 public void expandStack() {
330 mBubbleData.setExpanded(true);
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800331 }
332
333 /**
334 * Tell the stack of bubbles to collapse.
335 */
336 public void collapseStack() {
Mark Renouf71a3af62019-04-08 15:02:54 -0400337 mBubbleData.setExpanded(false /* expanded */);
338 }
339
340 void selectBubble(Bubble bubble) {
341 mBubbleData.setSelectedBubble(bubble);
342 }
343
344 @VisibleForTesting
345 void selectBubble(String key) {
346 Bubble bubble = mBubbleData.getBubbleWithKey(key);
347 selectBubble(bubble);
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800348 }
349
350 /**
Mark Renouffec45da2019-03-13 13:24:27 -0400351 * Request the stack expand if needed, then select the specified Bubble as current.
352 *
353 * @param notificationKey the notification key for the bubble to be selected
354 */
355 public void expandStackAndSelectBubble(String notificationKey) {
Mark Renouf71a3af62019-04-08 15:02:54 -0400356 Bubble bubble = mBubbleData.getBubbleWithKey(notificationKey);
357 if (bubble != null) {
358 mBubbleData.setSelectedBubble(bubble);
359 mBubbleData.setExpanded(true);
Mark Renouffec45da2019-03-13 13:24:27 -0400360 }
361 }
362
363 /**
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800364 * Tell the stack of bubbles to be dismissed, this will remove all of the bubbles in the stack.
365 */
Mark Renouf08bc42a2019-03-07 13:01:59 -0500366 void dismissStack(@DismissReason int reason) {
Mark Renouf71a3af62019-04-08 15:02:54 -0400367 mBubbleData.dismissAll(reason);
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800368 }
369
370 /**
Mark Renouf041d7262019-02-06 12:09:41 -0500371 * Directs a back gesture at the bubble stack. When opened, the current expanded bubble
372 * is forwarded a back key down/up pair.
373 */
374 public void performBackPressIfNeeded() {
375 if (mStackView != null) {
376 mStackView.performBackPressIfNeeded();
377 }
378 }
379
380 /**
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800381 * Adds or updates a bubble associated with the provided notification entry.
382 *
Mark Renouf8b6a3c62019-04-09 10:17:40 -0400383 * @param notif the notification associated with this bubble.
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800384 */
Mark Renouff97ed462019-04-05 13:46:24 -0400385 void updateBubble(NotificationEntry notif) {
Mady Mellor66efd5e2019-05-15 13:38:11 -0700386 // If this is an interruptive notif, mark that it's interrupted
387 if (notif.importance >= NotificationManager.IMPORTANCE_HIGH) {
388 notif.setInterruption();
389 }
Mark Renouf71a3af62019-04-08 15:02:54 -0400390 mBubbleData.notificationEntryUpdated(notif);
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800391 }
392
393 /**
394 * Removes the bubble associated with the {@param uri}.
Mark Renouf658c6bc2019-01-30 10:26:54 -0500395 * <p>
396 * Must be called from the main thread.
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800397 */
Mark Renouf658c6bc2019-01-30 10:26:54 -0500398 @MainThread
Mark Renouf08bc42a2019-03-07 13:01:59 -0500399 void removeBubble(String key, int reason) {
Mark Renouf71a3af62019-04-08 15:02:54 -0400400 // TEMP: refactor to change this to pass entry
401 Bubble bubble = mBubbleData.getBubbleWithKey(key);
402 if (bubble != null) {
403 mBubbleData.notificationEntryRemoved(bubble.entry, reason);
Mady Mellore8e07712019-01-23 12:45:33 -0800404 }
405 }
406
Ned Burns01e38212019-01-03 16:32:52 -0500407 @SuppressWarnings("FieldCanBeLocal")
Mady Mellorc2ff0112019-03-28 14:18:06 -0700408 private final NotificationRemoveInterceptor mRemoveInterceptor =
409 new NotificationRemoveInterceptor() {
410 @Override
411 public boolean onNotificationRemoveRequested(String key, int reason) {
412 if (!mBubbleData.hasBubbleWithKey(key)) {
413 return false;
414 }
415 NotificationEntry entry = mBubbleData.getBubbleWithKey(key).entry;
416
417 final boolean isClearAll = reason == REASON_CANCEL_ALL;
418 final boolean isUserDimiss = reason == REASON_CANCEL;
419 final boolean isAppCancel = reason == REASON_APP_CANCEL
420 || reason == REASON_APP_CANCEL_ALL;
421
422 // Need to check for !appCancel here because the notification may have
423 // previously been dismissed & entry.isRowDismissed would still be true
424 boolean userRemovedNotif = (entry.isRowDismissed() && !isAppCancel)
425 || isClearAll || isUserDimiss;
426
427 // The bubble notification sticks around in the data as long as the bubble is
428 // not dismissed and the app hasn't cancelled the notification.
429 boolean bubbleExtended = entry.isBubble() && !entry.isBubbleDismissed()
430 && userRemovedNotif;
431 if (bubbleExtended) {
432 entry.setShowInShadeWhenBubble(false);
433 if (mStackView != null) {
434 mStackView.updateDotVisibility(entry.key);
435 }
436 mNotificationEntryManager.updateNotifications();
437 return true;
438 } else if (!userRemovedNotif && !entry.isBubbleDismissed()) {
439 // This wasn't a user removal so we should remove the bubble as well
440 mBubbleData.notificationEntryRemoved(entry, DISMISS_NOTIF_CANCEL);
441 return false;
442 }
443 return false;
444 }
445 };
446
447 @SuppressWarnings("FieldCanBeLocal")
Ned Burns01e38212019-01-03 16:32:52 -0500448 private final NotificationEntryListener mEntryListener = new NotificationEntryListener() {
449 @Override
Ned Burnsf81c4c42019-01-07 14:10:43 -0500450 public void onPendingEntryAdded(NotificationEntry entry) {
Mady Mellorf6e3ac02019-01-29 10:37:52 -0800451 if (!areBubblesEnabled(mContext)) {
452 return;
453 }
Mady Melloraa8fef22019-04-11 13:36:40 -0700454 if (mNotificationInterruptionStateProvider.shouldBubbleUp(entry)) {
Mady Mellor8a1f0252019-04-01 11:31:34 -0700455 updateShowInShadeForSuppressNotification(entry);
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800456 }
457 }
458
459 @Override
Ned Burns1a5e22f2019-02-14 15:11:52 -0500460 public void onEntryInflated(NotificationEntry entry, @InflationFlag int inflatedFlags) {
Mady Mellorf6e3ac02019-01-29 10:37:52 -0800461 if (!areBubblesEnabled(mContext)) {
462 return;
463 }
Mady Melloraa8fef22019-04-11 13:36:40 -0700464 if (mNotificationInterruptionStateProvider.shouldBubbleUp(entry)) {
Mark Renouff97ed462019-04-05 13:46:24 -0400465 updateBubble(entry);
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800466 }
467 }
468
469 @Override
470 public void onPreEntryUpdated(NotificationEntry entry) {
Mady Mellorf6e3ac02019-01-29 10:37:52 -0800471 if (!areBubblesEnabled(mContext)) {
472 return;
473 }
Mady Melloraa8fef22019-04-11 13:36:40 -0700474 boolean shouldBubble = mNotificationInterruptionStateProvider.shouldBubbleUp(entry);
475 if (!shouldBubble && mBubbleData.hasBubbleWithKey(entry.key)) {
476 // It was previously a bubble but no longer a bubble -- lets remove it
477 removeBubble(entry.key, DISMISS_NO_LONGER_BUBBLE);
Mady Mellorff40e012019-05-03 15:34:41 -0700478 } else if (shouldBubble) {
Mady Mellor8a1f0252019-04-01 11:31:34 -0700479 updateShowInShadeForSuppressNotification(entry);
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800480 entry.setBubbleDismissed(false); // updates come back as bubbles even if dismissed
Mark Renouff97ed462019-04-05 13:46:24 -0400481 updateBubble(entry);
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800482 }
483 }
Ned Burns01e38212019-01-03 16:32:52 -0500484 };
485
Mark Renouf71a3af62019-04-08 15:02:54 -0400486 @SuppressWarnings("FieldCanBeLocal")
Mark Renouf3bc5b362019-04-05 14:37:59 -0400487 private final BubbleData.Listener mBubbleDataListener = new BubbleData.Listener() {
Mark Renouf71a3af62019-04-08 15:02:54 -0400488
Mark Renouf3bc5b362019-04-05 14:37:59 -0400489 @Override
Mark Renouf82a40e62019-05-23 16:16:24 -0400490 public void applyUpdate(BubbleData.Update update) {
491 if (mStackView == null && update.addedBubble != null) {
492 // Lazy init stack view when the first bubble is added.
493 ensureStackViewCreated();
Mark Renouf71a3af62019-04-08 15:02:54 -0400494 }
Mark Renouf82a40e62019-05-23 16:16:24 -0400495
496 // If not yet initialized, ignore all other changes.
497 if (mStackView == null) {
498 return;
499 }
500
501 if (update.addedBubble != null) {
502 mStackView.addBubble(update.addedBubble);
503 }
504
505 // Collapsing? Do this first before remaining steps.
506 if (update.expandedChanged && !update.expanded) {
507 mStackView.setExpanded(false);
508 }
509
510 // Do removals, if any.
511 for (Pair<Bubble, Integer> removed : update.removedBubbles) {
512 final Bubble bubble = removed.first;
513 @DismissReason final int reason = removed.second;
514 mStackView.removeBubble(bubble);
515
516 if (!mBubbleData.hasBubbleWithKey(bubble.getKey())
517 && !bubble.entry.showInShadeWhenBubble()) {
518 // The bubble is gone & the notification is gone, time to actually remove it
519 mNotificationEntryManager.performRemoveNotification(bubble.entry.notification,
520 UNDEFINED_DISMISS_REASON);
521 } else {
522 // The notification is still in the shade but we've removed the bubble so
523 // lets make sure NoMan knows it's not a bubble anymore
524 try {
525 mBarService.onNotificationBubbleChanged(bubble.getKey(),
526 false /* isBubble */);
527 } catch (RemoteException e) {
528 // Bad things have happened
529 }
Mady Mellora54e9fa2019-04-18 13:26:18 -0700530 }
531 }
Mark Renouf3bc5b362019-04-05 14:37:59 -0400532
Mark Renouf82a40e62019-05-23 16:16:24 -0400533 if (update.updatedBubble != null) {
534 mStackView.updateBubble(update.updatedBubble);
Mark Renouf71a3af62019-04-08 15:02:54 -0400535 }
Mark Renouf3bc5b362019-04-05 14:37:59 -0400536
Mark Renouf82a40e62019-05-23 16:16:24 -0400537 if (update.orderChanged) {
538 mStackView.updateBubbleOrder(update.bubbles);
Mark Renoufba5ab512019-05-02 15:21:01 -0400539 }
Mark Renouf3bc5b362019-04-05 14:37:59 -0400540
Mark Renouf82a40e62019-05-23 16:16:24 -0400541 if (update.selectionChanged) {
542 mStackView.setSelectedBubble(update.selectedBubble);
Mark Renouf71a3af62019-04-08 15:02:54 -0400543 }
Mark Renouf3bc5b362019-04-05 14:37:59 -0400544
Mark Renouf82a40e62019-05-23 16:16:24 -0400545 // Expanding? Apply this last.
546 if (update.expandedChanged && update.expanded) {
547 mStackView.setExpanded(true);
Mark Renouf71a3af62019-04-08 15:02:54 -0400548 }
Mark Renouf3bc5b362019-04-05 14:37:59 -0400549
Mark Renouf71a3af62019-04-08 15:02:54 -0400550 mNotificationEntryManager.updateNotifications();
Lyn Han6c40fe72019-05-08 14:06:33 -0700551 updateStack();
Mark Renouf9ba6cea2019-04-17 11:53:50 -0400552
553 if (DEBUG) {
554 Log.d(TAG, "[BubbleData]");
555 Log.d(TAG, formatBubblesString(mBubbleData.getBubbles(),
556 mBubbleData.getSelectedBubble()));
557
558 if (mStackView != null) {
559 Log.d(TAG, "[BubbleStackView]");
560 Log.d(TAG, formatBubblesString(mStackView.getBubblesOnScreen(),
561 mStackView.getExpandedBubble()));
562 }
563 }
Mark Renouf3bc5b362019-04-05 14:37:59 -0400564 }
565 };
566
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800567 /**
Lyn Han6c40fe72019-05-08 14:06:33 -0700568 * Updates the visibility of the bubbles based on current state.
569 * Does not un-bubble, just hides or un-hides. Notifies any
570 * {@link BubbleStateChangeListener}s of visibility changes.
571 * Updates stack description for TalkBack focus.
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800572 */
Lyn Han6c40fe72019-05-08 14:06:33 -0700573 public void updateStack() {
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800574 if (mStackView == null) {
575 return;
Mady Mellord1c78b262018-11-06 18:04:40 -0800576 }
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800577 if (mStatusBarStateListener.getCurrentState() == SHADE && hasBubbles()) {
578 // Bubbles only appear in unlocked shade
579 mStackView.setVisibility(hasBubbles() ? VISIBLE : INVISIBLE);
580 } else if (mStackView != null) {
581 mStackView.setVisibility(INVISIBLE);
Mady Mellor5549dd22018-11-06 18:07:34 -0800582 }
Lyn Han6c40fe72019-05-08 14:06:33 -0700583
584 // Let listeners know if bubble state changed.
585 boolean hadBubbles = mStatusBarWindowController.getBubblesShowing();
586 boolean hasBubblesShowing = hasBubbles() && mStackView.getVisibility() == VISIBLE;
587 mStatusBarWindowController.setBubblesShowing(hasBubblesShowing);
588 if (mStateChangeListener != null && hadBubbles != hasBubblesShowing) {
589 mStateChangeListener.onHasBubblesChanged(hasBubblesShowing);
590 }
591
592 mStackView.updateContentDescription();
Mady Mellord1c78b262018-11-06 18:04:40 -0800593 }
594
595 /**
596 * Rect indicating the touchable region for the bubble stack / expanded stack.
597 */
598 public Rect getTouchableRegion() {
599 if (mStackView == null || mStackView.getVisibility() != VISIBLE) {
600 return null;
601 }
602 mStackView.getBoundsOnScreen(mTempRect);
603 return mTempRect;
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800604 }
605
Mady Mellor390bff42019-04-05 15:09:01 -0700606 /**
607 * The display id of the expanded view, if the stack is expanded and not occluded by the
608 * status bar, otherwise returns {@link Display#INVALID_DISPLAY}.
609 */
610 public int getExpandedDisplayId(Context context) {
Joel Galenson4071ddb2019-04-18 13:30:45 -0700611 if (mStackView == null) {
612 return INVALID_DISPLAY;
613 }
Mady Mellor390bff42019-04-05 15:09:01 -0700614 boolean defaultDisplay = context.getDisplay() != null
615 && context.getDisplay().getDisplayId() == DEFAULT_DISPLAY;
616 Bubble b = mStackView.getExpandedBubble();
617 if (defaultDisplay && b != null && isStackExpanded()
618 && !mStatusBarWindowController.getPanelExpanded()) {
619 return b.expandedView.getVirtualDisplayId();
620 }
621 return INVALID_DISPLAY;
622 }
623
Mady Mellorf6e3ac02019-01-29 10:37:52 -0800624 @VisibleForTesting
625 BubbleStackView getStackView() {
626 return mStackView;
627 }
628
Mady Mellor5549dd22018-11-06 18:07:34 -0800629 /**
Mady Mellorf6e3ac02019-01-29 10:37:52 -0800630 * Whether the notification should automatically bubble or not. Gated by secure settings flags.
Mady Mellor5549dd22018-11-06 18:07:34 -0800631 */
Mady Mellor9bad2242019-01-28 11:21:51 -0800632 @VisibleForTesting
Mady Mellorf6e3ac02019-01-29 10:37:52 -0800633 protected boolean shouldAutoBubbleForFlags(Context context, NotificationEntry entry) {
Mady Mellorceced172018-11-27 11:18:39 -0800634 if (entry.isBubbleDismissed()) {
Mady Mellor5549dd22018-11-06 18:07:34 -0800635 return false;
636 }
Mady Mellorb4991e62019-01-10 15:14:51 -0800637 StatusBarNotification n = entry.notification;
Mady Mellorceced172018-11-27 11:18:39 -0800638
639 boolean autoBubbleMessages = shouldAutoBubbleMessages(context) || DEBUG_ENABLE_AUTO_BUBBLE;
640 boolean autoBubbleOngoing = shouldAutoBubbleOngoing(context) || DEBUG_ENABLE_AUTO_BUBBLE;
641 boolean autoBubbleAll = shouldAutoBubbleAll(context) || DEBUG_ENABLE_AUTO_BUBBLE;
642
Mady Mellor5549dd22018-11-06 18:07:34 -0800643 boolean hasRemoteInput = false;
644 if (n.getNotification().actions != null) {
645 for (Notification.Action action : n.getNotification().actions) {
646 if (action.getRemoteInputs() != null) {
647 hasRemoteInput = true;
648 break;
649 }
650 }
651 }
Mady Mellor711f9562018-12-05 14:53:46 -0800652 boolean isCall = Notification.CATEGORY_CALL.equals(n.getNotification().category)
653 && n.isOngoing();
654 boolean isMusic = n.getNotification().hasMediaSession();
655 boolean isImportantOngoing = isMusic || isCall;
Mady Mellorceced172018-11-27 11:18:39 -0800656
Mady Mellor5549dd22018-11-06 18:07:34 -0800657 Class<? extends Notification.Style> style = n.getNotification().getNotificationStyle();
Mady Mellore3175372018-12-04 17:05:11 -0800658 boolean isMessageType = Notification.CATEGORY_MESSAGE.equals(n.getNotification().category);
659 boolean isMessageStyle = Notification.MessagingStyle.class.equals(style);
Mady Mellorf6e3ac02019-01-29 10:37:52 -0800660 return (((isMessageType && hasRemoteInput) || isMessageStyle) && autoBubbleMessages)
Mady Mellor711f9562018-12-05 14:53:46 -0800661 || (isImportantOngoing && autoBubbleOngoing)
Mady Mellorceced172018-11-27 11:18:39 -0800662 || autoBubbleAll;
663 }
664
Mady Mellore80930e2019-03-21 16:00:45 -0700665 private boolean shouldAutoExpand(NotificationEntry entry) {
666 Notification.BubbleMetadata metadata = entry.getBubbleMetadata();
667 return metadata != null && metadata.getAutoExpandBubble()
Steven Wu8ba8ca92019-04-11 10:47:42 -0400668 && isForegroundApp(mContext, entry.notification.getPackageName());
Mady Mellore80930e2019-03-21 16:00:45 -0700669 }
670
Mady Mellor8a1f0252019-04-01 11:31:34 -0700671 private void updateShowInShadeForSuppressNotification(NotificationEntry entry) {
672 boolean suppressNotification = entry.getBubbleMetadata() != null
Mady Mellorc529d6d2019-04-16 14:22:52 -0700673 && entry.getBubbleMetadata().isNotificationSuppressed()
Steven Wu8ba8ca92019-04-11 10:47:42 -0400674 && isForegroundApp(mContext, entry.notification.getPackageName());
Mady Mellor8a1f0252019-04-01 11:31:34 -0700675 entry.setShowInShadeWhenBubble(!suppressNotification);
676 }
677
Mark Renouf9ba6cea2019-04-17 11:53:50 -0400678 static String formatBubblesString(List<Bubble> bubbles, Bubble selected) {
679 StringBuilder sb = new StringBuilder();
680 for (Bubble bubble : bubbles) {
681 if (bubble == null) {
682 sb.append(" <null> !!!!!\n");
683 } else {
684 boolean isSelected = (bubble == selected);
685 sb.append(String.format("%s Bubble{act=%12d, ongoing=%d, key=%s}\n",
686 ((isSelected) ? "->" : " "),
687 bubble.getLastActivity(),
688 (bubble.isOngoing() ? 1 : 0),
689 bubble.getKey()));
690 }
691 }
692 return sb.toString();
693 }
694
Mady Mellore80930e2019-03-21 16:00:45 -0700695 /**
696 * Return true if the applications with the package name is running in foreground.
697 *
Steven Wu8ba8ca92019-04-11 10:47:42 -0400698 * @param context application context.
Mady Mellore80930e2019-03-21 16:00:45 -0700699 * @param pkgName application package name.
700 */
Steven Wu8ba8ca92019-04-11 10:47:42 -0400701 public static boolean isForegroundApp(Context context, String pkgName) {
702 ActivityManager am = context.getSystemService(ActivityManager.class);
Mady Mellore80930e2019-03-21 16:00:45 -0700703 List<RunningTaskInfo> tasks = am.getRunningTasks(1 /* maxNum */);
704 return !tasks.isEmpty() && pkgName.equals(tasks.get(0).topActivity.getPackageName());
705 }
706
Mark Renoufcecc77b2019-01-30 16:32:24 -0500707 /**
708 * This task stack listener is responsible for responding to tasks moved to the front
709 * which are on the default (main) display. When this happens, expanded bubbles must be
710 * collapsed so the user may interact with the app which was just moved to the front.
711 * <p>
712 * This listener is registered with SystemUI's ActivityManagerWrapper which dispatches
713 * these calls via a main thread Handler.
714 */
715 @MainThread
716 private class BubbleTaskStackListener extends TaskStackChangeListener {
717
Mark Renoufcecc77b2019-01-30 16:32:24 -0500718 @Override
Mark Renoufc808f062019-02-07 15:20:37 -0500719 public void onTaskMovedToFront(RunningTaskInfo taskInfo) {
720 if (mStackView != null && taskInfo.displayId == Display.DEFAULT_DISPLAY) {
Mark Renouf71a3af62019-04-08 15:02:54 -0400721 mBubbleData.setExpanded(false);
Mark Renoufcecc77b2019-01-30 16:32:24 -0500722 }
723 }
724
Mark Renoufcecc77b2019-01-30 16:32:24 -0500725 @Override
Mark Renoufa12e8762019-03-07 15:43:01 -0500726 public void onActivityLaunchOnSecondaryDisplayRerouted() {
Mark Renoufcecc77b2019-01-30 16:32:24 -0500727 if (mStackView != null) {
Mark Renouf71a3af62019-04-08 15:02:54 -0400728 mBubbleData.setExpanded(false);
Mark Renoufcecc77b2019-01-30 16:32:24 -0500729 }
730 }
Mark Renouf446251d2019-04-26 10:22:41 -0400731
732 @Override
733 public void onBackPressedOnTaskRoot(RunningTaskInfo taskInfo) {
734 if (mStackView != null && taskInfo.displayId == getExpandedDisplayId(mContext)) {
735 mBubbleData.setExpanded(false);
736 }
737 }
Mark Renoufcecc77b2019-01-30 16:32:24 -0500738 }
739
Mady Mellorceced172018-11-27 11:18:39 -0800740 private static boolean shouldAutoBubbleMessages(Context context) {
741 return Settings.Secure.getInt(context.getContentResolver(),
742 ENABLE_AUTO_BUBBLE_MESSAGES, 0) != 0;
743 }
744
745 private static boolean shouldAutoBubbleOngoing(Context context) {
746 return Settings.Secure.getInt(context.getContentResolver(),
747 ENABLE_AUTO_BUBBLE_ONGOING, 0) != 0;
748 }
749
750 private static boolean shouldAutoBubbleAll(Context context) {
751 return Settings.Secure.getInt(context.getContentResolver(),
752 ENABLE_AUTO_BUBBLE_ALL, 0) != 0;
Mady Mellor5549dd22018-11-06 18:07:34 -0800753 }
Mark Renouf89b1a4a2018-12-04 14:59:45 -0500754
Mady Mellor3dff9e62019-02-05 18:12:53 -0800755 static boolean shouldUseContentIntent(Context context) {
Mark Renouf89b1a4a2018-12-04 14:59:45 -0500756 return Settings.Secure.getInt(context.getContentResolver(),
757 ENABLE_BUBBLE_CONTENT_INTENT, 0) != 0;
758 }
Mady Mellorf6e3ac02019-01-29 10:37:52 -0800759
760 private static boolean areBubblesEnabled(Context context) {
761 return Settings.Secure.getInt(context.getContentResolver(),
762 ENABLE_BUBBLES, 1) != 0;
763 }
Joshua Tsujia19515f2019-02-13 18:02:29 -0500764
Joshua Tsuji010c2b12019-02-25 18:11:25 -0500765 /** Default stiffness to use for bubble physics animations. */
766 public static int getBubbleStiffness(Context context, int defaultStiffness) {
767 return Settings.Secure.getInt(
768 context.getContentResolver(), BUBBLE_STIFFNESS, defaultStiffness);
769 }
770
771 /** Default bounciness/damping ratio to use for bubble physics animations. */
772 public static float getBubbleBounciness(Context context, float defaultBounciness) {
773 return Settings.Secure.getInt(
774 context.getContentResolver(),
775 BUBBLE_BOUNCINESS,
776 (int) (defaultBounciness * 100)) / 100f;
777 }
778
Joshua Tsujia19515f2019-02-13 18:02:29 -0500779 /** PinnedStackListener that dispatches IME visibility updates to the stack. */
780 private class BubblesImeListener extends IPinnedStackListener.Stub {
781
782 @Override
783 public void onListenerRegistered(IPinnedStackController controller) throws RemoteException {
784 }
785
786 @Override
787 public void onMovementBoundsChanged(Rect insetBounds, Rect normalBounds,
788 Rect animatingBounds, boolean fromImeAdjustment, boolean fromShelfAdjustment,
789 int displayRotation) throws RemoteException {}
790
791 @Override
Joshua Tsujid9422832019-03-05 13:32:37 -0500792 public void onImeVisibilityChanged(boolean imeVisible, int imeHeight) {
793 if (mStackView != null && mStackView.getBubbleCount() > 0) {
794 mStackView.post(() -> mStackView.onImeVisibilityChanged(imeVisible, imeHeight));
Joshua Tsujia19515f2019-02-13 18:02:29 -0500795 }
796 }
797
798 @Override
799 public void onShelfVisibilityChanged(boolean shelfVisible, int shelfHeight)
800 throws RemoteException {}
801
802 @Override
803 public void onMinimizedStateChanged(boolean isMinimized) throws RemoteException {}
804
805 @Override
806 public void onActionsChanged(ParceledListSlice actions) throws RemoteException {}
807 }
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800808}