blob: e8b054ede18d369a4441deb70564f37875272f3c [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 Renoufcecc77b2019-01-30 16:32:24 -050053import android.view.Display;
Joshua Tsujia19515f2019-02-13 18:02:29 -050054import android.view.IPinnedStackController;
55import android.view.IPinnedStackListener;
Mady Mellorc3d6f7d2018-11-07 09:36:56 -080056import android.view.ViewGroup;
Mady Mellorc3d6f7d2018-11-07 09:36:56 -080057import android.widget.FrameLayout;
58
Mark Renouf08bc42a2019-03-07 13:01:59 -050059import androidx.annotation.IntDef;
Mark Renouf658c6bc2019-01-30 10:26:54 -050060import androidx.annotation.MainThread;
61
Mady Mellorebdbbb92018-11-15 14:36:48 -080062import com.android.internal.annotations.VisibleForTesting;
Mady Mellora54e9fa2019-04-18 13:26:18 -070063import com.android.internal.statusbar.IStatusBarService;
Ned Burns01e38212019-01-03 16:32:52 -050064import com.android.systemui.Dependency;
Mady Mellorc3d6f7d2018-11-07 09:36:56 -080065import com.android.systemui.R;
Beverly8fdb5332019-02-04 14:29:49 -050066import com.android.systemui.plugins.statusbar.StatusBarStateController;
Mark Renoufcecc77b2019-01-30 16:32:24 -050067import com.android.systemui.shared.system.ActivityManagerWrapper;
68import com.android.systemui.shared.system.TaskStackChangeListener;
Joshua Tsujia19515f2019-02-13 18:02:29 -050069import com.android.systemui.shared.system.WindowManagerWrapper;
Mady Mellorc2ff0112019-03-28 14:18:06 -070070import com.android.systemui.statusbar.NotificationRemoveInterceptor;
Ned Burns01e38212019-01-03 16:32:52 -050071import com.android.systemui.statusbar.notification.NotificationEntryListener;
72import com.android.systemui.statusbar.notification.NotificationEntryManager;
Mady Mellor3f2efdb2018-11-21 11:30:45 -080073import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
Ned Burnsf81c4c42019-01-07 14:10:43 -050074import com.android.systemui.statusbar.notification.collection.NotificationEntry;
Ned Burns1a5e22f2019-02-14 15:11:52 -050075import com.android.systemui.statusbar.notification.row.NotificationContentInflater.InflationFlag;
Mady Mellorc3d6f7d2018-11-07 09:36:56 -080076import com.android.systemui.statusbar.phone.StatusBarWindowController;
Lyn Hanf1c9b8b2019-03-14 16:49:48 -070077import com.android.systemui.statusbar.policy.ConfigurationController;
Mady Mellorc3d6f7d2018-11-07 09:36:56 -080078
Mark Renouf08bc42a2019-03-07 13:01:59 -050079import java.lang.annotation.Retention;
Mark Renoufba5ab512019-05-02 15:21:01 -040080import java.lang.annotation.Target;
Mady Mellore80930e2019-03-21 16:00:45 -070081import java.util.List;
Mark Renouf08bc42a2019-03-07 13:01:59 -050082
Jason Monk27d01a622018-12-10 15:57:09 -050083import javax.inject.Inject;
84import javax.inject.Singleton;
85
Mady Mellorc3d6f7d2018-11-07 09:36:56 -080086/**
87 * Bubbles are a special type of content that can "float" on top of other apps or System UI.
88 * Bubbles can be expanded to show more content.
89 *
90 * The controller manages addition, removal, and visible state of bubbles on screen.
91 */
Jason Monk27d01a622018-12-10 15:57:09 -050092@Singleton
Mark Renouf71a3af62019-04-08 15:02:54 -040093public class BubbleController implements ConfigurationController.ConfigurationListener {
Mady Mellorc3d6f7d2018-11-07 09:36:56 -080094
95 private static final String TAG = "BubbleController";
Mark Renoufba5ab512019-05-02 15:21:01 -040096 private static final boolean DEBUG = false;
Mady Mellorc3d6f7d2018-11-07 09:36:56 -080097
Mark Renouf08bc42a2019-03-07 13:01:59 -050098 @Retention(SOURCE)
99 @IntDef({DISMISS_USER_GESTURE, DISMISS_AGED, DISMISS_TASK_FINISHED, DISMISS_BLOCKED,
Mady Melloraa8fef22019-04-11 13:36:40 -0700100 DISMISS_NOTIF_CANCEL, DISMISS_ACCESSIBILITY_ACTION, DISMISS_NO_LONGER_BUBBLE})
Mark Renoufba5ab512019-05-02 15:21:01 -0400101 @Target({FIELD, LOCAL_VARIABLE, PARAMETER})
Mark Renouf08bc42a2019-03-07 13:01:59 -0500102 @interface DismissReason {}
Lyn Hanf1c9b8b2019-03-14 16:49:48 -0700103
Mark Renouf08bc42a2019-03-07 13:01:59 -0500104 static final int DISMISS_USER_GESTURE = 1;
105 static final int DISMISS_AGED = 2;
106 static final int DISMISS_TASK_FINISHED = 3;
107 static final int DISMISS_BLOCKED = 4;
108 static final int DISMISS_NOTIF_CANCEL = 5;
109 static final int DISMISS_ACCESSIBILITY_ACTION = 6;
Mady Melloraa8fef22019-04-11 13:36:40 -0700110 static final int DISMISS_NO_LONGER_BUBBLE = 7;
Mark Renouf08bc42a2019-03-07 13:01:59 -0500111
Joshua Tsuji4accf5982019-04-22 17:36:11 -0400112 public static final int MAX_BUBBLES = 5; // TODO: actually enforce this
Joshua Tsuji25a4b7b2019-03-22 14:11:06 -0400113
Mady Mellor5549dd22018-11-06 18:07:34 -0800114 // Enables some subset of notifs to automatically become bubbles
Ned Burns01e38212019-01-03 16:32:52 -0500115 private static final boolean DEBUG_ENABLE_AUTO_BUBBLE = false;
Mady Mellor5549dd22018-11-06 18:07:34 -0800116
Mady Mellor44ee2fe2019-01-30 17:51:16 -0800117 /** Flag to enable or disable the entire feature */
Mady Mellorf6e3ac02019-01-29 10:37:52 -0800118 private static final String ENABLE_BUBBLES = "experiment_enable_bubbles";
Mady Mellor44ee2fe2019-01-30 17:51:16 -0800119 /** Auto bubble flags set whether different notif types should be presented as a bubble */
Mady Mellorceced172018-11-27 11:18:39 -0800120 private static final String ENABLE_AUTO_BUBBLE_MESSAGES = "experiment_autobubble_messaging";
121 private static final String ENABLE_AUTO_BUBBLE_ONGOING = "experiment_autobubble_ongoing";
122 private static final String ENABLE_AUTO_BUBBLE_ALL = "experiment_autobubble_all";
Mady Mellor44ee2fe2019-01-30 17:51:16 -0800123
124 /** Use an activityView for an auto-bubbled notifs if it has an appropriate content intent */
Mark Renouf89b1a4a2018-12-04 14:59:45 -0500125 private static final String ENABLE_BUBBLE_CONTENT_INTENT = "experiment_bubble_content_intent";
Mady Mellorceced172018-11-27 11:18:39 -0800126
Joshua Tsuji010c2b12019-02-25 18:11:25 -0500127 private static final String BUBBLE_STIFFNESS = "experiment_bubble_stiffness";
128 private static final String BUBBLE_BOUNCINESS = "experiment_bubble_bounciness";
129
Ned Burns01e38212019-01-03 16:32:52 -0500130 private final Context mContext;
131 private final NotificationEntryManager mNotificationEntryManager;
Mark Renoufcecc77b2019-01-30 16:32:24 -0500132 private final IActivityTaskManager mActivityTaskManager;
133 private final BubbleTaskStackListener mTaskStackListener;
Mady Mellord1c78b262018-11-06 18:04:40 -0800134 private BubbleStateChangeListener mStateChangeListener;
Mady Mellorcd9b1302018-11-06 18:08:04 -0800135 private BubbleExpandListener mExpandListener;
Issei Suzukic0387542019-03-08 17:31:14 +0100136 @Nullable private BubbleStackView.SurfaceSynchronizer mSurfaceSynchronizer;
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800137
Mady Mellor3dff9e62019-02-05 18:12:53 -0800138 private BubbleData mBubbleData;
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800139 private BubbleStackView mStackView;
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800140
141 // Bubbles get added to the status bar view
Ned Burns01e38212019-01-03 16:32:52 -0500142 private final StatusBarWindowController mStatusBarWindowController;
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800143 private StatusBarStateListener mStatusBarStateListener;
144
Mady Melloraa8fef22019-04-11 13:36:40 -0700145 private final NotificationInterruptionStateProvider mNotificationInterruptionStateProvider;
Mady Mellora54e9fa2019-04-18 13:26:18 -0700146 private IStatusBarService mBarService;
Mady Mellorb4991e62019-01-10 15:14:51 -0800147
Mady Mellord1c78b262018-11-06 18:04:40 -0800148 // Used for determining view rect for touch interaction
149 private Rect mTempRect = new Rect();
150
Joshua Tsujif418f9e2019-04-04 17:09:53 -0400151 /** Last known orientation, used to detect orientation changes in {@link #onConfigChanged}. */
152 private int mOrientation = Configuration.ORIENTATION_UNDEFINED;
153
Mady Mellor5549dd22018-11-06 18:07:34 -0800154 /**
Mady Mellord1c78b262018-11-06 18:04:40 -0800155 * Listener to be notified when some states of the bubbles change.
156 */
157 public interface BubbleStateChangeListener {
158 /**
159 * Called when the stack has bubbles or no longer has bubbles.
160 */
161 void onHasBubblesChanged(boolean hasBubbles);
162 }
163
Mady Mellorcd9b1302018-11-06 18:08:04 -0800164 /**
165 * Listener to find out about stack expansion / collapse events.
166 */
167 public interface BubbleExpandListener {
168 /**
169 * Called when the expansion state of the bubble stack changes.
Lyn Hanf1c9b8b2019-03-14 16:49:48 -0700170 *
Mady Mellorcd9b1302018-11-06 18:08:04 -0800171 * @param isExpanding whether it's expanding or collapsing
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800172 * @param key the notification key associated with bubble being expanded
Mady Mellorcd9b1302018-11-06 18:08:04 -0800173 */
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800174 void onBubbleExpandChanged(boolean isExpanding, String key);
175 }
176
177 /**
178 * Listens for the current state of the status bar and updates the visibility state
179 * of bubbles as needed.
180 */
181 private class StatusBarStateListener implements StatusBarStateController.StateListener {
182 private int mState;
183 /**
184 * Returns the current status bar state.
185 */
186 public int getCurrentState() {
187 return mState;
188 }
189
190 @Override
191 public void onStateChanged(int newState) {
192 mState = newState;
Mark Renouf71a3af62019-04-08 15:02:54 -0400193 boolean shouldCollapse = (mState != SHADE);
194 if (shouldCollapse) {
195 collapseStack();
196 }
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800197 updateVisibility();
198 }
Mady Mellorcd9b1302018-11-06 18:08:04 -0800199 }
200
Jason Monk27d01a622018-12-10 15:57:09 -0500201 @Inject
Mady Mellorcfd06c12019-02-13 14:32:12 -0800202 public BubbleController(Context context, StatusBarWindowController statusBarWindowController,
Mady Melloraa8fef22019-04-11 13:36:40 -0700203 BubbleData data, ConfigurationController configurationController,
204 NotificationInterruptionStateProvider interruptionStateProvider) {
Lyn Hanf1c9b8b2019-03-14 16:49:48 -0700205 this(context, statusBarWindowController, data, null /* synchronizer */,
Mady Melloraa8fef22019-04-11 13:36:40 -0700206 configurationController, interruptionStateProvider);
Issei Suzukic0387542019-03-08 17:31:14 +0100207 }
208
209 public BubbleController(Context context, StatusBarWindowController statusBarWindowController,
Lyn Hanf1c9b8b2019-03-14 16:49:48 -0700210 BubbleData data, @Nullable BubbleStackView.SurfaceSynchronizer synchronizer,
Mady Melloraa8fef22019-04-11 13:36:40 -0700211 ConfigurationController configurationController,
212 NotificationInterruptionStateProvider interruptionStateProvider) {
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800213 mContext = context;
Mady Melloraa8fef22019-04-11 13:36:40 -0700214 mNotificationInterruptionStateProvider = interruptionStateProvider;
215
Lyn Hanf1c9b8b2019-03-14 16:49:48 -0700216 configurationController.addCallback(this /* configurationListener */);
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800217
Mark Renouf9ba6cea2019-04-17 11:53:50 -0400218 mBubbleData = data;
219 mBubbleData.setListener(mBubbleDataListener);
220
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800221 mNotificationEntryManager = Dependency.get(NotificationEntryManager.class);
Ned Burns01e38212019-01-03 16:32:52 -0500222 mNotificationEntryManager.addNotificationEntryListener(mEntryListener);
Mady Mellorc2ff0112019-03-28 14:18:06 -0700223 mNotificationEntryManager.setNotificationRemoveInterceptor(mRemoveInterceptor);
Mady Mellorb4991e62019-01-10 15:14:51 -0800224
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800225 mStatusBarWindowController = statusBarWindowController;
226 mStatusBarStateListener = new StatusBarStateListener();
227 Dependency.get(StatusBarStateController.class).addCallback(mStatusBarStateListener);
Mark Renoufcecc77b2019-01-30 16:32:24 -0500228
229 mActivityTaskManager = ActivityTaskManager.getService();
230 mTaskStackListener = new BubbleTaskStackListener();
231 ActivityManagerWrapper.getInstance().registerTaskStackListener(mTaskStackListener);
Mady Mellor3dff9e62019-02-05 18:12:53 -0800232
Joshua Tsujia19515f2019-02-13 18:02:29 -0500233 try {
234 WindowManagerWrapper.getInstance().addPinnedStackListener(new BubblesImeListener());
235 } catch (RemoteException e) {
236 e.printStackTrace();
237 }
Issei Suzukic0387542019-03-08 17:31:14 +0100238 mSurfaceSynchronizer = synchronizer;
Mady Mellora54e9fa2019-04-18 13:26:18 -0700239
240 mBarService = IStatusBarService.Stub.asInterface(
241 ServiceManager.getService(Context.STATUS_BAR_SERVICE));
Mady Mellor5549dd22018-11-06 18:07:34 -0800242 }
243
Mark Renouf8b6a3c62019-04-09 10:17:40 -0400244 /**
245 * BubbleStackView is lazily created by this method the first time a Bubble is added. This
246 * method initializes the stack view and adds it to the StatusBar just above the scrim.
247 */
248 private void ensureStackViewCreated() {
249 if (mStackView == null) {
250 mStackView = new BubbleStackView(mContext, mBubbleData, mSurfaceSynchronizer);
251 ViewGroup sbv = mStatusBarWindowController.getStatusBarView();
252 // TODO(b/130237686): When you expand the shade on top of expanded bubble, there is no
253 // scrim between bubble and the shade
254 int bubblePosition = sbv.indexOfChild(sbv.findViewById(R.id.scrim_behind)) + 1;
255 sbv.addView(mStackView, bubblePosition,
256 new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
257 if (mExpandListener != null) {
258 mStackView.setExpandListener(mExpandListener);
259 }
Mark Renouf8b6a3c62019-04-09 10:17:40 -0400260 }
261 }
262
Lyn Hanf1c9b8b2019-03-14 16:49:48 -0700263 @Override
264 public void onUiModeChanged() {
265 if (mStackView != null) {
Lyn Han02cca812019-04-02 16:27:32 -0700266 mStackView.onThemeChanged();
Lyn Hanf1c9b8b2019-03-14 16:49:48 -0700267 }
268 }
269
270 @Override
271 public void onOverlayChanged() {
272 if (mStackView != null) {
Lyn Han02cca812019-04-02 16:27:32 -0700273 mStackView.onThemeChanged();
Lyn Hanf1c9b8b2019-03-14 16:49:48 -0700274 }
275 }
276
Joshua Tsujif418f9e2019-04-04 17:09:53 -0400277 @Override
278 public void onConfigChanged(Configuration newConfig) {
279 if (mStackView != null && newConfig != null && newConfig.orientation != mOrientation) {
280 mStackView.onOrientationChanged();
281 mOrientation = newConfig.orientation;
282 }
283 }
284
Mady Mellor5549dd22018-11-06 18:07:34 -0800285 /**
Mady Mellord1c78b262018-11-06 18:04:40 -0800286 * Set a listener to be notified when some states of the bubbles change.
287 */
288 public void setBubbleStateChangeListener(BubbleStateChangeListener listener) {
289 mStateChangeListener = listener;
290 }
291
292 /**
Mady Mellorcd9b1302018-11-06 18:08:04 -0800293 * Set a listener to be notified of bubble expand events.
294 */
295 public void setExpandListener(BubbleExpandListener listener) {
Issei Suzukiac9fcb72019-02-04 17:45:57 +0100296 mExpandListener = ((isExpanding, key) -> {
297 if (listener != null) {
298 listener.onBubbleExpandChanged(isExpanding, key);
299 }
300 mStatusBarWindowController.setBubbleExpanded(isExpanding);
301 });
Mady Mellorcd9b1302018-11-06 18:08:04 -0800302 if (mStackView != null) {
303 mStackView.setExpandListener(mExpandListener);
304 }
305 }
306
307 /**
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800308 * Whether or not there are bubbles present, regardless of them being visible on the
309 * screen (e.g. if on AOD).
310 */
311 public boolean hasBubbles() {
Mady Mellor3dff9e62019-02-05 18:12:53 -0800312 if (mStackView == null) {
313 return false;
314 }
Mark Renouf71a3af62019-04-08 15:02:54 -0400315 return mBubbleData.hasBubbles();
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800316 }
317
318 /**
319 * Whether the stack of bubbles is expanded or not.
320 */
321 public boolean isStackExpanded() {
Mark Renouf71a3af62019-04-08 15:02:54 -0400322 return mBubbleData.isExpanded();
323 }
324
325 /**
326 * Tell the stack of bubbles to expand.
327 */
328 public void expandStack() {
329 mBubbleData.setExpanded(true);
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800330 }
331
332 /**
333 * Tell the stack of bubbles to collapse.
334 */
335 public void collapseStack() {
Mark Renouf71a3af62019-04-08 15:02:54 -0400336 mBubbleData.setExpanded(false /* expanded */);
337 }
338
339 void selectBubble(Bubble bubble) {
340 mBubbleData.setSelectedBubble(bubble);
341 }
342
343 @VisibleForTesting
344 void selectBubble(String key) {
345 Bubble bubble = mBubbleData.getBubbleWithKey(key);
346 selectBubble(bubble);
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800347 }
348
349 /**
Mark Renouffec45da2019-03-13 13:24:27 -0400350 * Request the stack expand if needed, then select the specified Bubble as current.
351 *
352 * @param notificationKey the notification key for the bubble to be selected
353 */
354 public void expandStackAndSelectBubble(String notificationKey) {
Mark Renouf71a3af62019-04-08 15:02:54 -0400355 Bubble bubble = mBubbleData.getBubbleWithKey(notificationKey);
356 if (bubble != null) {
357 mBubbleData.setSelectedBubble(bubble);
358 mBubbleData.setExpanded(true);
Mark Renouffec45da2019-03-13 13:24:27 -0400359 }
360 }
361
362 /**
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800363 * Tell the stack of bubbles to be dismissed, this will remove all of the bubbles in the stack.
364 */
Mark Renouf08bc42a2019-03-07 13:01:59 -0500365 void dismissStack(@DismissReason int reason) {
Mark Renouf71a3af62019-04-08 15:02:54 -0400366 mBubbleData.dismissAll(reason);
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800367 }
368
369 /**
Mark Renouf041d7262019-02-06 12:09:41 -0500370 * Directs a back gesture at the bubble stack. When opened, the current expanded bubble
371 * is forwarded a back key down/up pair.
372 */
373 public void performBackPressIfNeeded() {
374 if (mStackView != null) {
375 mStackView.performBackPressIfNeeded();
376 }
377 }
378
379 /**
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800380 * Adds or updates a bubble associated with the provided notification entry.
381 *
Mark Renouf8b6a3c62019-04-09 10:17:40 -0400382 * @param notif the notification associated with this bubble.
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800383 */
Mark Renouff97ed462019-04-05 13:46:24 -0400384 void updateBubble(NotificationEntry notif) {
Mady Mellor66efd5e2019-05-15 13:38:11 -0700385 // If this is an interruptive notif, mark that it's interrupted
386 if (notif.importance >= NotificationManager.IMPORTANCE_HIGH) {
387 notif.setInterruption();
388 }
Mark Renouf71a3af62019-04-08 15:02:54 -0400389 mBubbleData.notificationEntryUpdated(notif);
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800390 }
391
392 /**
393 * Removes the bubble associated with the {@param uri}.
Mark Renouf658c6bc2019-01-30 10:26:54 -0500394 * <p>
395 * Must be called from the main thread.
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800396 */
Mark Renouf658c6bc2019-01-30 10:26:54 -0500397 @MainThread
Mark Renouf08bc42a2019-03-07 13:01:59 -0500398 void removeBubble(String key, int reason) {
Mark Renouf71a3af62019-04-08 15:02:54 -0400399 // TEMP: refactor to change this to pass entry
400 Bubble bubble = mBubbleData.getBubbleWithKey(key);
401 if (bubble != null) {
402 mBubbleData.notificationEntryRemoved(bubble.entry, reason);
Mady Mellore8e07712019-01-23 12:45:33 -0800403 }
404 }
405
Ned Burns01e38212019-01-03 16:32:52 -0500406 @SuppressWarnings("FieldCanBeLocal")
Mady Mellorc2ff0112019-03-28 14:18:06 -0700407 private final NotificationRemoveInterceptor mRemoveInterceptor =
408 new NotificationRemoveInterceptor() {
409 @Override
410 public boolean onNotificationRemoveRequested(String key, int reason) {
411 if (!mBubbleData.hasBubbleWithKey(key)) {
412 return false;
413 }
414 NotificationEntry entry = mBubbleData.getBubbleWithKey(key).entry;
415
416 final boolean isClearAll = reason == REASON_CANCEL_ALL;
417 final boolean isUserDimiss = reason == REASON_CANCEL;
418 final boolean isAppCancel = reason == REASON_APP_CANCEL
419 || reason == REASON_APP_CANCEL_ALL;
420
421 // Need to check for !appCancel here because the notification may have
422 // previously been dismissed & entry.isRowDismissed would still be true
423 boolean userRemovedNotif = (entry.isRowDismissed() && !isAppCancel)
424 || isClearAll || isUserDimiss;
425
426 // The bubble notification sticks around in the data as long as the bubble is
427 // not dismissed and the app hasn't cancelled the notification.
428 boolean bubbleExtended = entry.isBubble() && !entry.isBubbleDismissed()
429 && userRemovedNotif;
430 if (bubbleExtended) {
431 entry.setShowInShadeWhenBubble(false);
432 if (mStackView != null) {
433 mStackView.updateDotVisibility(entry.key);
434 }
435 mNotificationEntryManager.updateNotifications();
436 return true;
437 } else if (!userRemovedNotif && !entry.isBubbleDismissed()) {
438 // This wasn't a user removal so we should remove the bubble as well
439 mBubbleData.notificationEntryRemoved(entry, DISMISS_NOTIF_CANCEL);
440 return false;
441 }
442 return false;
443 }
444 };
445
446 @SuppressWarnings("FieldCanBeLocal")
Ned Burns01e38212019-01-03 16:32:52 -0500447 private final NotificationEntryListener mEntryListener = new NotificationEntryListener() {
448 @Override
Ned Burnsf81c4c42019-01-07 14:10:43 -0500449 public void onPendingEntryAdded(NotificationEntry entry) {
Mady Mellorf6e3ac02019-01-29 10:37:52 -0800450 if (!areBubblesEnabled(mContext)) {
451 return;
452 }
Mady Melloraa8fef22019-04-11 13:36:40 -0700453 if (mNotificationInterruptionStateProvider.shouldBubbleUp(entry)) {
Mady Mellor8a1f0252019-04-01 11:31:34 -0700454 updateShowInShadeForSuppressNotification(entry);
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800455 }
456 }
457
458 @Override
Ned Burns1a5e22f2019-02-14 15:11:52 -0500459 public void onEntryInflated(NotificationEntry entry, @InflationFlag int inflatedFlags) {
Mady Mellorf6e3ac02019-01-29 10:37:52 -0800460 if (!areBubblesEnabled(mContext)) {
461 return;
462 }
Mady Melloraa8fef22019-04-11 13:36:40 -0700463 if (mNotificationInterruptionStateProvider.shouldBubbleUp(entry)) {
Mark Renouff97ed462019-04-05 13:46:24 -0400464 updateBubble(entry);
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800465 }
466 }
467
468 @Override
469 public void onPreEntryUpdated(NotificationEntry entry) {
Mady Mellorf6e3ac02019-01-29 10:37:52 -0800470 if (!areBubblesEnabled(mContext)) {
471 return;
472 }
Mady Melloraa8fef22019-04-11 13:36:40 -0700473 boolean shouldBubble = mNotificationInterruptionStateProvider.shouldBubbleUp(entry);
474 if (!shouldBubble && mBubbleData.hasBubbleWithKey(entry.key)) {
475 // It was previously a bubble but no longer a bubble -- lets remove it
476 removeBubble(entry.key, DISMISS_NO_LONGER_BUBBLE);
Mady Mellorff40e012019-05-03 15:34:41 -0700477 } else if (shouldBubble) {
Mady Mellor8a1f0252019-04-01 11:31:34 -0700478 updateShowInShadeForSuppressNotification(entry);
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800479 entry.setBubbleDismissed(false); // updates come back as bubbles even if dismissed
Mark Renouff97ed462019-04-05 13:46:24 -0400480 updateBubble(entry);
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800481 }
482 }
Ned Burns01e38212019-01-03 16:32:52 -0500483 };
484
Mark Renouf71a3af62019-04-08 15:02:54 -0400485 @SuppressWarnings("FieldCanBeLocal")
Mark Renouf3bc5b362019-04-05 14:37:59 -0400486 private final BubbleData.Listener mBubbleDataListener = new BubbleData.Listener() {
Mark Renouf71a3af62019-04-08 15:02:54 -0400487
Mark Renouf3bc5b362019-04-05 14:37:59 -0400488 @Override
489 public void onBubbleAdded(Bubble bubble) {
Mark Renouf71a3af62019-04-08 15:02:54 -0400490 ensureStackViewCreated();
491 mStackView.addBubble(bubble);
Mark Renouf3bc5b362019-04-05 14:37:59 -0400492 }
493
494 @Override
Mady Mellorc2ff0112019-03-28 14:18:06 -0700495 public void onBubbleRemoved(Bubble bubble, @DismissReason int reason) {
Mark Renouf71a3af62019-04-08 15:02:54 -0400496 if (mStackView != null) {
497 mStackView.removeBubble(bubble);
498 }
Mady Mellorc2ff0112019-03-28 14:18:06 -0700499 if (!mBubbleData.hasBubbleWithKey(bubble.getKey())
500 && !bubble.entry.showInShadeWhenBubble()) {
501 // The bubble is gone & the notification is gone, time to actually remove it
502 mNotificationEntryManager.performRemoveNotification(bubble.entry.notification,
Mady Mellor1a4e86f2019-05-03 16:07:23 -0700503 UNDEFINED_DISMISS_REASON);
Mady Mellora54e9fa2019-04-18 13:26:18 -0700504 } else {
505 // The notification is still in the shade but we've removed the bubble so
506 // lets make sure NoMan knows it's not a bubble anymore
507 try {
508 mBarService.onNotificationBubbleChanged(bubble.getKey(), false /* isBubble */);
509 } catch (RemoteException e) {
510 // Bad things have happened
511 }
512 }
Mark Renouf3bc5b362019-04-05 14:37:59 -0400513 }
514
515 public void onBubbleUpdated(Bubble bubble) {
Mark Renouf71a3af62019-04-08 15:02:54 -0400516 if (mStackView != null) {
517 mStackView.updateBubble(bubble);
518 }
Mark Renouf3bc5b362019-04-05 14:37:59 -0400519 }
520
521 @Override
522 public void onOrderChanged(List<Bubble> bubbles) {
Mark Renoufba5ab512019-05-02 15:21:01 -0400523 if (mStackView != null) {
524 mStackView.updateBubbleOrder(bubbles);
525 }
Mark Renouf3bc5b362019-04-05 14:37:59 -0400526 }
527
528 @Override
Mark Renouf9ba6cea2019-04-17 11:53:50 -0400529 public void onSelectionChanged(@Nullable Bubble selectedBubble) {
Mark Renouf71a3af62019-04-08 15:02:54 -0400530 if (mStackView != null) {
531 mStackView.setSelectedBubble(selectedBubble);
532 }
Mark Renouf3bc5b362019-04-05 14:37:59 -0400533 }
534
535 @Override
536 public void onExpandedChanged(boolean expanded) {
Mark Renouf71a3af62019-04-08 15:02:54 -0400537 if (mStackView != null) {
538 mStackView.setExpanded(expanded);
539 }
Mark Renouf3bc5b362019-04-05 14:37:59 -0400540 }
541
542 @Override
Mark Renouf3bc5b362019-04-05 14:37:59 -0400543 public void apply() {
Mark Renouf71a3af62019-04-08 15:02:54 -0400544 mNotificationEntryManager.updateNotifications();
545 updateVisibility();
Mark Renouf9ba6cea2019-04-17 11:53:50 -0400546
547 if (DEBUG) {
548 Log.d(TAG, "[BubbleData]");
549 Log.d(TAG, formatBubblesString(mBubbleData.getBubbles(),
550 mBubbleData.getSelectedBubble()));
551
552 if (mStackView != null) {
553 Log.d(TAG, "[BubbleStackView]");
554 Log.d(TAG, formatBubblesString(mStackView.getBubblesOnScreen(),
555 mStackView.getExpandedBubble()));
556 }
557 }
Mark Renouf3bc5b362019-04-05 14:37:59 -0400558 }
559 };
560
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800561 /**
562 * Lets any listeners know if bubble state has changed.
563 */
Mady Mellord1c78b262018-11-06 18:04:40 -0800564 private void updateBubblesShowing() {
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800565 if (mStackView == null) {
566 return;
Mady Mellord1c78b262018-11-06 18:04:40 -0800567 }
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800568
Mady Mellord1c78b262018-11-06 18:04:40 -0800569 boolean hadBubbles = mStatusBarWindowController.getBubblesShowing();
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800570 boolean hasBubblesShowing = hasBubbles() && mStackView.getVisibility() == VISIBLE;
Mady Mellord1c78b262018-11-06 18:04:40 -0800571 mStatusBarWindowController.setBubblesShowing(hasBubblesShowing);
Mady Mellord1c78b262018-11-06 18:04:40 -0800572 if (mStateChangeListener != null && hadBubbles != hasBubblesShowing) {
573 mStateChangeListener.onHasBubblesChanged(hasBubblesShowing);
574 }
Mady Mellor5549dd22018-11-06 18:07:34 -0800575 }
576
577 /**
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800578 * Updates the visibility of the bubbles based on current state.
579 * Does not un-bubble, just hides or un-hides. Will notify any
580 * {@link BubbleStateChangeListener}s if visibility changes.
Mady Mellor5549dd22018-11-06 18:07:34 -0800581 */
Mady Mellor3f2efdb2018-11-21 11:30:45 -0800582 public void updateVisibility() {
583 if (mStatusBarStateListener.getCurrentState() == SHADE && hasBubbles()) {
584 // Bubbles only appear in unlocked shade
585 mStackView.setVisibility(hasBubbles() ? VISIBLE : INVISIBLE);
586 } else if (mStackView != null) {
587 mStackView.setVisibility(INVISIBLE);
Mady Mellor5549dd22018-11-06 18:07:34 -0800588 }
Mady Mellord1c78b262018-11-06 18:04:40 -0800589 updateBubblesShowing();
590 }
591
592 /**
593 * Rect indicating the touchable region for the bubble stack / expanded stack.
594 */
595 public Rect getTouchableRegion() {
596 if (mStackView == null || mStackView.getVisibility() != VISIBLE) {
597 return null;
598 }
599 mStackView.getBoundsOnScreen(mTempRect);
600 return mTempRect;
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800601 }
602
Mady Mellor390bff42019-04-05 15:09:01 -0700603 /**
604 * The display id of the expanded view, if the stack is expanded and not occluded by the
605 * status bar, otherwise returns {@link Display#INVALID_DISPLAY}.
606 */
607 public int getExpandedDisplayId(Context context) {
Joel Galenson4071ddb2019-04-18 13:30:45 -0700608 if (mStackView == null) {
609 return INVALID_DISPLAY;
610 }
Mady Mellor390bff42019-04-05 15:09:01 -0700611 boolean defaultDisplay = context.getDisplay() != null
612 && context.getDisplay().getDisplayId() == DEFAULT_DISPLAY;
613 Bubble b = mStackView.getExpandedBubble();
614 if (defaultDisplay && b != null && isStackExpanded()
615 && !mStatusBarWindowController.getPanelExpanded()) {
616 return b.expandedView.getVirtualDisplayId();
617 }
618 return INVALID_DISPLAY;
619 }
620
Mady Mellorf6e3ac02019-01-29 10:37:52 -0800621 @VisibleForTesting
622 BubbleStackView getStackView() {
623 return mStackView;
624 }
625
Mady Mellor5549dd22018-11-06 18:07:34 -0800626 /**
Mady Mellorf6e3ac02019-01-29 10:37:52 -0800627 * Whether the notification should automatically bubble or not. Gated by secure settings flags.
Mady Mellor5549dd22018-11-06 18:07:34 -0800628 */
Mady Mellor9bad2242019-01-28 11:21:51 -0800629 @VisibleForTesting
Mady Mellorf6e3ac02019-01-29 10:37:52 -0800630 protected boolean shouldAutoBubbleForFlags(Context context, NotificationEntry entry) {
Mady Mellorceced172018-11-27 11:18:39 -0800631 if (entry.isBubbleDismissed()) {
Mady Mellor5549dd22018-11-06 18:07:34 -0800632 return false;
633 }
Mady Mellorb4991e62019-01-10 15:14:51 -0800634 StatusBarNotification n = entry.notification;
Mady Mellorceced172018-11-27 11:18:39 -0800635
636 boolean autoBubbleMessages = shouldAutoBubbleMessages(context) || DEBUG_ENABLE_AUTO_BUBBLE;
637 boolean autoBubbleOngoing = shouldAutoBubbleOngoing(context) || DEBUG_ENABLE_AUTO_BUBBLE;
638 boolean autoBubbleAll = shouldAutoBubbleAll(context) || DEBUG_ENABLE_AUTO_BUBBLE;
639
Mady Mellor5549dd22018-11-06 18:07:34 -0800640 boolean hasRemoteInput = false;
641 if (n.getNotification().actions != null) {
642 for (Notification.Action action : n.getNotification().actions) {
643 if (action.getRemoteInputs() != null) {
644 hasRemoteInput = true;
645 break;
646 }
647 }
648 }
Mady Mellor711f9562018-12-05 14:53:46 -0800649 boolean isCall = Notification.CATEGORY_CALL.equals(n.getNotification().category)
650 && n.isOngoing();
651 boolean isMusic = n.getNotification().hasMediaSession();
652 boolean isImportantOngoing = isMusic || isCall;
Mady Mellorceced172018-11-27 11:18:39 -0800653
Mady Mellor5549dd22018-11-06 18:07:34 -0800654 Class<? extends Notification.Style> style = n.getNotification().getNotificationStyle();
Mady Mellore3175372018-12-04 17:05:11 -0800655 boolean isMessageType = Notification.CATEGORY_MESSAGE.equals(n.getNotification().category);
656 boolean isMessageStyle = Notification.MessagingStyle.class.equals(style);
Mady Mellorf6e3ac02019-01-29 10:37:52 -0800657 return (((isMessageType && hasRemoteInput) || isMessageStyle) && autoBubbleMessages)
Mady Mellor711f9562018-12-05 14:53:46 -0800658 || (isImportantOngoing && autoBubbleOngoing)
Mady Mellorceced172018-11-27 11:18:39 -0800659 || autoBubbleAll;
660 }
661
Mady Mellore80930e2019-03-21 16:00:45 -0700662 private boolean shouldAutoExpand(NotificationEntry entry) {
663 Notification.BubbleMetadata metadata = entry.getBubbleMetadata();
664 return metadata != null && metadata.getAutoExpandBubble()
Steven Wu8ba8ca92019-04-11 10:47:42 -0400665 && isForegroundApp(mContext, entry.notification.getPackageName());
Mady Mellore80930e2019-03-21 16:00:45 -0700666 }
667
Mady Mellor8a1f0252019-04-01 11:31:34 -0700668 private void updateShowInShadeForSuppressNotification(NotificationEntry entry) {
669 boolean suppressNotification = entry.getBubbleMetadata() != null
Mady Mellorc529d6d2019-04-16 14:22:52 -0700670 && entry.getBubbleMetadata().isNotificationSuppressed()
Steven Wu8ba8ca92019-04-11 10:47:42 -0400671 && isForegroundApp(mContext, entry.notification.getPackageName());
Mady Mellor8a1f0252019-04-01 11:31:34 -0700672 entry.setShowInShadeWhenBubble(!suppressNotification);
673 }
674
Mark Renouf9ba6cea2019-04-17 11:53:50 -0400675 static String formatBubblesString(List<Bubble> bubbles, Bubble selected) {
676 StringBuilder sb = new StringBuilder();
677 for (Bubble bubble : bubbles) {
678 if (bubble == null) {
679 sb.append(" <null> !!!!!\n");
680 } else {
681 boolean isSelected = (bubble == selected);
682 sb.append(String.format("%s Bubble{act=%12d, ongoing=%d, key=%s}\n",
683 ((isSelected) ? "->" : " "),
684 bubble.getLastActivity(),
685 (bubble.isOngoing() ? 1 : 0),
686 bubble.getKey()));
687 }
688 }
689 return sb.toString();
690 }
691
Mady Mellore80930e2019-03-21 16:00:45 -0700692 /**
693 * Return true if the applications with the package name is running in foreground.
694 *
Steven Wu8ba8ca92019-04-11 10:47:42 -0400695 * @param context application context.
Mady Mellore80930e2019-03-21 16:00:45 -0700696 * @param pkgName application package name.
697 */
Steven Wu8ba8ca92019-04-11 10:47:42 -0400698 public static boolean isForegroundApp(Context context, String pkgName) {
699 ActivityManager am = context.getSystemService(ActivityManager.class);
Mady Mellore80930e2019-03-21 16:00:45 -0700700 List<RunningTaskInfo> tasks = am.getRunningTasks(1 /* maxNum */);
701 return !tasks.isEmpty() && pkgName.equals(tasks.get(0).topActivity.getPackageName());
702 }
703
Mark Renoufcecc77b2019-01-30 16:32:24 -0500704 /**
705 * This task stack listener is responsible for responding to tasks moved to the front
706 * which are on the default (main) display. When this happens, expanded bubbles must be
707 * collapsed so the user may interact with the app which was just moved to the front.
708 * <p>
709 * This listener is registered with SystemUI's ActivityManagerWrapper which dispatches
710 * these calls via a main thread Handler.
711 */
712 @MainThread
713 private class BubbleTaskStackListener extends TaskStackChangeListener {
714
Mark Renoufcecc77b2019-01-30 16:32:24 -0500715 @Override
Mark Renoufc808f062019-02-07 15:20:37 -0500716 public void onTaskMovedToFront(RunningTaskInfo taskInfo) {
717 if (mStackView != null && taskInfo.displayId == Display.DEFAULT_DISPLAY) {
Mark Renouf71a3af62019-04-08 15:02:54 -0400718 mBubbleData.setExpanded(false);
Mark Renoufcecc77b2019-01-30 16:32:24 -0500719 }
720 }
721
Mark Renoufcecc77b2019-01-30 16:32:24 -0500722 @Override
Mark Renoufa12e8762019-03-07 15:43:01 -0500723 public void onActivityLaunchOnSecondaryDisplayRerouted() {
Mark Renoufcecc77b2019-01-30 16:32:24 -0500724 if (mStackView != null) {
Mark Renouf71a3af62019-04-08 15:02:54 -0400725 mBubbleData.setExpanded(false);
Mark Renoufcecc77b2019-01-30 16:32:24 -0500726 }
727 }
Mark Renouf446251d2019-04-26 10:22:41 -0400728
729 @Override
730 public void onBackPressedOnTaskRoot(RunningTaskInfo taskInfo) {
731 if (mStackView != null && taskInfo.displayId == getExpandedDisplayId(mContext)) {
732 mBubbleData.setExpanded(false);
733 }
734 }
Mark Renoufcecc77b2019-01-30 16:32:24 -0500735 }
736
Mady Mellorceced172018-11-27 11:18:39 -0800737 private static boolean shouldAutoBubbleMessages(Context context) {
738 return Settings.Secure.getInt(context.getContentResolver(),
739 ENABLE_AUTO_BUBBLE_MESSAGES, 0) != 0;
740 }
741
742 private static boolean shouldAutoBubbleOngoing(Context context) {
743 return Settings.Secure.getInt(context.getContentResolver(),
744 ENABLE_AUTO_BUBBLE_ONGOING, 0) != 0;
745 }
746
747 private static boolean shouldAutoBubbleAll(Context context) {
748 return Settings.Secure.getInt(context.getContentResolver(),
749 ENABLE_AUTO_BUBBLE_ALL, 0) != 0;
Mady Mellor5549dd22018-11-06 18:07:34 -0800750 }
Mark Renouf89b1a4a2018-12-04 14:59:45 -0500751
Mady Mellor3dff9e62019-02-05 18:12:53 -0800752 static boolean shouldUseContentIntent(Context context) {
Mark Renouf89b1a4a2018-12-04 14:59:45 -0500753 return Settings.Secure.getInt(context.getContentResolver(),
754 ENABLE_BUBBLE_CONTENT_INTENT, 0) != 0;
755 }
Mady Mellorf6e3ac02019-01-29 10:37:52 -0800756
757 private static boolean areBubblesEnabled(Context context) {
758 return Settings.Secure.getInt(context.getContentResolver(),
759 ENABLE_BUBBLES, 1) != 0;
760 }
Joshua Tsujia19515f2019-02-13 18:02:29 -0500761
Joshua Tsuji010c2b12019-02-25 18:11:25 -0500762 /** Default stiffness to use for bubble physics animations. */
763 public static int getBubbleStiffness(Context context, int defaultStiffness) {
764 return Settings.Secure.getInt(
765 context.getContentResolver(), BUBBLE_STIFFNESS, defaultStiffness);
766 }
767
768 /** Default bounciness/damping ratio to use for bubble physics animations. */
769 public static float getBubbleBounciness(Context context, float defaultBounciness) {
770 return Settings.Secure.getInt(
771 context.getContentResolver(),
772 BUBBLE_BOUNCINESS,
773 (int) (defaultBounciness * 100)) / 100f;
774 }
775
Joshua Tsujia19515f2019-02-13 18:02:29 -0500776 /** PinnedStackListener that dispatches IME visibility updates to the stack. */
777 private class BubblesImeListener extends IPinnedStackListener.Stub {
778
779 @Override
780 public void onListenerRegistered(IPinnedStackController controller) throws RemoteException {
781 }
782
783 @Override
784 public void onMovementBoundsChanged(Rect insetBounds, Rect normalBounds,
785 Rect animatingBounds, boolean fromImeAdjustment, boolean fromShelfAdjustment,
786 int displayRotation) throws RemoteException {}
787
788 @Override
Joshua Tsujid9422832019-03-05 13:32:37 -0500789 public void onImeVisibilityChanged(boolean imeVisible, int imeHeight) {
790 if (mStackView != null && mStackView.getBubbleCount() > 0) {
791 mStackView.post(() -> mStackView.onImeVisibilityChanged(imeVisible, imeHeight));
Joshua Tsujia19515f2019-02-13 18:02:29 -0500792 }
793 }
794
795 @Override
796 public void onShelfVisibilityChanged(boolean shelfVisible, int shelfHeight)
797 throws RemoteException {}
798
799 @Override
800 public void onMinimizedStateChanged(boolean isMinimized) throws RemoteException {}
801
802 @Override
803 public void onActionsChanged(ParceledListSlice actions) throws RemoteException {}
804 }
Mady Mellorc3d6f7d2018-11-07 09:36:56 -0800805}