summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Beverly <beverlyt@google.com> 2020-02-10 15:27:40 -0500
committer Beverly <beverlyt@google.com> 2020-02-18 14:49:33 -0500
commit95a0802acbd38d31921bd9c5b44bedfe9ea4ed71 (patch)
tree31c3b20c0400c745cb82abe519fe6231997d479b
parent46d77cf71c4091daa2aba353afdfe9f4f718ba48 (diff)
Move SBTouchableRegion out of HeadsUpManagerPhone
Move the StatusBarTouchableRegionManager to StatusBar where it will be recreated whenever new views are created (instead of within HeadsUpManager) Test: atest SystemUITests Change-Id: I802ec8ea122a2cede234ec7536f1177f7b261fd0
-rw-r--r--packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java12
-rw-r--r--packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java5
-rw-r--r--packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java12
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationAlertingManager.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/VisualStabilityManager.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java7
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java270
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java10
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java16
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java229
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java7
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/TestableNotificationEntryManager.kt9
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java5
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java19
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java4
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java4
23 files changed, 380 insertions, 265 deletions
diff --git a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java
index 585acfec410a..a0d5a1bf6978 100644
--- a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java
+++ b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java
@@ -43,9 +43,11 @@ import com.android.systemui.statusbar.notification.NotificationInterruptionState
import com.android.systemui.statusbar.phone.HeadsUpManagerPhone;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.KeyguardEnvironmentImpl;
+import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
+import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.systemui.volume.CarVolumeDialogComponent;
@@ -74,10 +76,14 @@ abstract class CarSystemUIModule {
@Singleton
@Provides
- static HeadsUpManagerPhone provideHeadsUpManagerPhone(Context context,
+ static HeadsUpManagerPhone provideHeadsUpManagerPhone(
+ Context context,
StatusBarStateController statusBarStateController,
- KeyguardBypassController bypassController) {
- return new HeadsUpManagerPhone(context, statusBarStateController, bypassController);
+ KeyguardBypassController bypassController,
+ NotificationGroupManager groupManager,
+ ConfigurationController configurationController) {
+ return new HeadsUpManagerPhone(context, statusBarStateController, bypassController,
+ groupManager, configurationController);
}
@Binds
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
index 210dd321933a..fbca2bc9f0b7 100644
--- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
+++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
@@ -128,6 +128,7 @@ import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.phone.StatusBarNotificationActivityStarter;
+import com.android.systemui.statusbar.phone.StatusBarTouchableRegionManager;
import com.android.systemui.statusbar.phone.dagger.StatusBarComponent;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.ConfigurationController;
@@ -324,6 +325,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
ExtensionController extensionController,
UserInfoControllerImpl userInfoControllerImpl,
DismissCallbackRegistry dismissCallbackRegistry,
+ StatusBarTouchableRegionManager statusBarTouchableRegionManager,
/* Car Settings injected components. */
CarServiceProvider carServiceProvider,
Lazy<PowerManagerHelper> powerManagerHelperLazy,
@@ -405,7 +407,8 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
keyguardDismissUtil,
extensionController,
userInfoControllerImpl,
- dismissCallbackRegistry);
+ dismissCallbackRegistry,
+ statusBarTouchableRegionManager);
mUserSwitcherController = userSwitcherController;
mScrimController = scrimController;
mLockscreenLockIconController = lockscreenLockIconController;
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java
index 7f6499072328..729496580bf6 100644
--- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java
+++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java
@@ -87,6 +87,7 @@ import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.phone.StatusBarNotificationActivityStarter;
+import com.android.systemui.statusbar.phone.StatusBarTouchableRegionManager;
import com.android.systemui.statusbar.phone.dagger.StatusBarComponent;
import com.android.systemui.statusbar.phone.dagger.StatusBarPhoneDependenciesModule;
import com.android.systemui.statusbar.policy.BatteryController;
@@ -197,6 +198,7 @@ public class CarStatusBarModule {
ExtensionController extensionController,
UserInfoControllerImpl userInfoControllerImpl,
DismissCallbackRegistry dismissCallbackRegistry,
+ StatusBarTouchableRegionManager statusBarTouchableRegionManager,
CarServiceProvider carServiceProvider,
Lazy<PowerManagerHelper> powerManagerHelperLazy,
FullscreenUserSwitcher fullscreenUserSwitcher,
@@ -277,6 +279,7 @@ public class CarStatusBarModule {
extensionController,
userInfoControllerImpl,
dismissCallbackRegistry,
+ statusBarTouchableRegionManager,
carServiceProvider,
powerManagerHelperLazy,
fullscreenUserSwitcher,
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java
index a57ec5b483dd..3e257b6173eb 100644
--- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java
+++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java
@@ -38,8 +38,10 @@ import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.phone.HeadsUpManagerPhone;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.KeyguardEnvironmentImpl;
+import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.ShadeControllerImpl;
+import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.DeviceProvisionedControllerImpl;
import com.android.systemui.statusbar.policy.HeadsUpManager;
@@ -92,10 +94,14 @@ public abstract class SystemUIDefaultModule {
@Singleton
@Provides
- static HeadsUpManagerPhone provideHeadsUpManagerPhone(Context context,
+ static HeadsUpManagerPhone provideHeadsUpManagerPhone(
+ Context context,
StatusBarStateController statusBarStateController,
- KeyguardBypassController bypassController) {
- return new HeadsUpManagerPhone(context, statusBarStateController, bypassController);
+ KeyguardBypassController bypassController,
+ NotificationGroupManager groupManager,
+ ConfigurationController configurationController) {
+ return new HeadsUpManagerPhone(context, statusBarStateController, bypassController,
+ groupManager, configurationController);
}
@Binds
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationAlertingManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationAlertingManager.java
index 72a7e11d8543..07cf9d9051c4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationAlertingManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationAlertingManager.java
@@ -53,12 +53,14 @@ public class NotificationAlertingManager {
VisualStabilityManager visualStabilityManager,
StatusBarStateController statusBarStateController,
NotificationInterruptionStateProvider notificationInterruptionStateProvider,
- NotificationListener notificationListener) {
+ NotificationListener notificationListener,
+ HeadsUpManager headsUpManager) {
mRemoteInputManager = remoteInputManager;
mVisualStabilityManager = visualStabilityManager;
mStatusBarStateController = statusBarStateController;
mNotificationInterruptionStateProvider = notificationInterruptionStateProvider;
mNotificationListener = notificationListener;
+ mHeadsUpManager = headsUpManager;
notificationEntryManager.addNotificationEntryListener(new NotificationEntryListener() {
@Override
@@ -81,10 +83,6 @@ public class NotificationAlertingManager {
});
}
- public void setHeadsUpManager(HeadsUpManager headsUpManager) {
- mHeadsUpManager = headsUpManager;
- }
-
/**
* Adds the entry to the respective alerting manager if the content view was inflated and
* the entry should still alert.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
index 4f55e02bddfb..5ebd368a7173 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
@@ -49,9 +49,7 @@ import com.android.systemui.statusbar.notification.collection.notifcollection.Co
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener;
import com.android.systemui.statusbar.notification.dagger.NotificationsModule;
import com.android.systemui.statusbar.notification.logging.NotificationLogger;
-import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
-import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.systemui.util.Assert;
import com.android.systemui.util.leak.LeakDetector;
@@ -230,9 +228,7 @@ public class NotificationEntryManager implements
mRemoveInterceptors.remove(interceptor);
}
- public void setUpWithPresenter(NotificationPresenter presenter,
- NotificationListContainer listContainer,
- HeadsUpManager headsUpManager) {
+ public void setUpWithPresenter(NotificationPresenter presenter) {
mPresenter = presenter;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/VisualStabilityManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/VisualStabilityManager.java
index 616c110ea7cc..fabe3a7bfee4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/VisualStabilityManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/VisualStabilityManager.java
@@ -61,7 +61,8 @@ public class VisualStabilityManager implements OnHeadsUpChangedListener, Dumpabl
* Injected constructor. See {@link NotificationsModule}.
*/
public VisualStabilityManager(
- NotificationEntryManager notificationEntryManager, @Main Handler handler) {
+ NotificationEntryManager notificationEntryManager,
+ @Main Handler handler) {
mHandler = handler;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java
index 8f8f7422c449..d0b553db2100 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java
@@ -47,6 +47,7 @@ import com.android.systemui.statusbar.notification.row.NotificationBlockingHelpe
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.StatusBar;
+import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.systemui.util.leak.LeakDetector;
import java.util.concurrent.Executor;
@@ -123,14 +124,16 @@ public interface NotificationsModule {
VisualStabilityManager visualStabilityManager,
StatusBarStateController statusBarStateController,
NotificationInterruptionStateProvider notificationInterruptionStateProvider,
- NotificationListener notificationListener) {
+ NotificationListener notificationListener,
+ HeadsUpManager headsUpManager) {
return new NotificationAlertingManager(
notificationEntryManager,
remoteInputManager,
visualStabilityManager,
statusBarStateController,
notificationInterruptionStateProvider,
- notificationListener);
+ notificationListener,
+ headsUpManager);
}
/** Provides an instance of {@link NotificationLogger} */
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java
index c6e3fdefe701..63fe7005e703 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java
@@ -19,24 +19,15 @@ package com.android.systemui.statusbar.phone;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
-import android.content.res.Configuration;
import android.content.res.Resources;
-import android.graphics.Rect;
import android.graphics.Region;
-import android.util.Log;
import android.util.Pools;
-import android.view.DisplayCutout;
-import android.view.Gravity;
-import android.view.View;
-import android.view.ViewTreeObserver;
-import android.view.WindowInsets;
import androidx.collection.ArraySet;
import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.Dumpable;
import com.android.systemui.R;
-import com.android.systemui.ScreenDecorations;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener;
import com.android.systemui.statusbar.StatusBarState;
@@ -49,31 +40,27 @@ import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener;
import java.io.FileDescriptor;
import java.io.PrintWriter;
+import java.util.ArrayList;
import java.util.HashSet;
+import java.util.List;
import java.util.Stack;
/**
* A implementation of HeadsUpManager for phone and car.
*/
public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
- VisualStabilityManager.Callback, OnHeadsUpChangedListener,
- ConfigurationController.ConfigurationListener, StateListener {
+ VisualStabilityManager.Callback, OnHeadsUpChangedListener {
private static final String TAG = "HeadsUpManagerPhone";
@VisibleForTesting
final int mExtensionTime;
- private final StatusBarStateController mStatusBarStateController;
private final KeyguardBypassController mBypassController;
+ private final NotificationGroupManager mGroupManager;
+ private final List<OnHeadsUpPhoneListenerChange> mHeadsUpPhoneListeners = new ArrayList<>();
private final int mAutoHeadsUpNotificationDecay;
- private View mNotificationShadeWindowView;
- private NotificationGroupManager mGroupManager;
private VisualStabilityManager mVisualStabilityManager;
- private StatusBarTouchableRegionManager mStatusBarTouchableRegionManager;
private boolean mReleaseOnExpandFinish;
- private int mStatusBarHeight;
- private int mHeadsUpInset;
- private int mDisplayCutoutTouchableRegionSize;
private boolean mTrackingHeadsUp;
private HashSet<String> mSwipedOutKeys = new HashSet<>();
private HashSet<NotificationEntry> mEntriesToRemoveAfterExpand = new HashSet<>();
@@ -81,12 +68,13 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
private ArraySet<NotificationEntry> mEntriesToRemoveWhenReorderingAllowed
= new ArraySet<>();
private boolean mIsExpanded;
- private int[] mTmpTwoArray = new int[2];
private boolean mHeadsUpGoingAway;
private int mStatusBarState;
- private Region mTouchableRegion = new Region();
-
private AnimationStateHandler mAnimationStateHandler;
+ private int mHeadsUpInset;
+
+ // Used for determining the region for touch interaction
+ private final Region mTouchableRegion = new Region();
private final Pools.Pool<HeadsUpEntryPhone> mEntryPool = new Pools.Pool<HeadsUpEntryPhone>() {
private Stack<HeadsUpEntryPhone> mPoolObjects = new Stack<>();
@@ -111,67 +99,87 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
public HeadsUpManagerPhone(@NonNull final Context context,
StatusBarStateController statusBarStateController,
- KeyguardBypassController bypassController) {
+ KeyguardBypassController bypassController,
+ NotificationGroupManager groupManager,
+ ConfigurationController configurationController) {
super(context);
Resources resources = mContext.getResources();
mExtensionTime = resources.getInteger(R.integer.ambient_notification_extension_time);
mAutoHeadsUpNotificationDecay = resources.getInteger(
R.integer.auto_heads_up_notification_decay);
- mStatusBarStateController = statusBarStateController;
- mStatusBarStateController.addCallback(this);
+ statusBarStateController.addCallback(mStatusBarStateListener);
mBypassController = bypassController;
-
- initResources();
- }
-
- public void setUp(@NonNull View notificationShadeWindowView,
- @NonNull NotificationGroupManager groupManager,
- @NonNull StatusBar bar,
- @NonNull VisualStabilityManager visualStabilityManager) {
- mNotificationShadeWindowView = notificationShadeWindowView;
- mStatusBarTouchableRegionManager = new StatusBarTouchableRegionManager(this, bar,
- notificationShadeWindowView);
mGroupManager = groupManager;
- mVisualStabilityManager = visualStabilityManager;
- addListener(new OnHeadsUpChangedListener() {
+ updateResources();
+ configurationController.addCallback(new ConfigurationController.ConfigurationListener() {
@Override
- public void onHeadsUpPinnedModeChanged(boolean hasPinnedNotification) {
- if (Log.isLoggable(TAG, Log.WARN)) {
- Log.w(TAG, "onHeadsUpPinnedModeChanged");
- }
- mStatusBarTouchableRegionManager.updateTouchableRegion();
+ public void onDensityOrFontScaleChanged() {
+ updateResources();
+ }
+
+ @Override
+ public void onOverlayChanged() {
+ updateResources();
}
});
}
+ void setup(VisualStabilityManager visualStabilityManager) {
+ mVisualStabilityManager = visualStabilityManager;
+ }
+
public void setAnimationStateHandler(AnimationStateHandler handler) {
mAnimationStateHandler = handler;
}
- private void initResources() {
+ private void updateResources() {
Resources resources = mContext.getResources();
- mStatusBarHeight = resources.getDimensionPixelSize(
- com.android.internal.R.dimen.status_bar_height);
- mHeadsUpInset = mStatusBarHeight + resources.getDimensionPixelSize(
- R.dimen.heads_up_status_bar_padding);
- mDisplayCutoutTouchableRegionSize = resources.getDimensionPixelSize(
- com.android.internal.R.dimen.display_cutout_touchable_region_size);
+ mHeadsUpInset =
+ resources.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height)
+ + resources.getDimensionPixelSize(R.dimen.heads_up_status_bar_padding);
}
- @Override
- public void onDensityOrFontScaleChanged() {
- super.onDensityOrFontScaleChanged();
- initResources();
- }
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+ // Public methods:
- @Override
- public void onOverlayChanged() {
- initResources();
+ /**
+ * Add a listener to receive callbacks onHeadsUpGoingAway
+ */
+ void addHeadsUpPhoneListener(OnHeadsUpPhoneListenerChange listener) {
+ mHeadsUpPhoneListeners.add(listener);
}
- ///////////////////////////////////////////////////////////////////////////////////////////////
- // Public methods:
+ /**
+ * Gets the touchable region needed for heads up notifications. Returns null if no touchable
+ * region is required (ie: no heads up notification currently exists).
+ */
+ @Nullable Region getTouchableRegion() {
+ NotificationEntry topEntry = getTopEntry();
+
+ // This call could be made in an inconsistent state while the pinnedMode hasn't been
+ // updated yet, but callbacks leading out of the headsUp manager, querying it. Let's
+ // therefore also check if the topEntry is null.
+ if (!hasPinnedHeadsUp() || topEntry == null) {
+ return null;
+ } else {
+ if (topEntry.isChildInGroup()) {
+ final NotificationEntry groupSummary =
+ mGroupManager.getGroupSummary(topEntry.getSbn());
+ if (groupSummary != null) {
+ topEntry = groupSummary;
+ }
+ }
+ ExpandableNotificationRow topRow = topEntry.getRow();
+ int[] tmpArray = new int[2];
+ topRow.getLocationOnScreen(tmpArray);
+ int minX = tmpArray[0];
+ int maxX = tmpArray[0] + topRow.getWidth();
+ int height = topRow.getIntrinsicHeight();
+ mTouchableRegion.set(minX, 0, maxX, mHeadsUpInset + height);
+ return mTouchableRegion;
+ }
+ }
/**
* Decides whether a click is invalid for a notification, i.e it has not been shown long enough
@@ -180,7 +188,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
* @param key the key of the touched notification
* @return whether the touch is invalid and should be discarded
*/
- public boolean shouldSwallowClick(@NonNull String key) {
+ boolean shouldSwallowClick(@NonNull String key) {
HeadsUpManager.HeadsUpEntry entry = getHeadsUpEntry(key);
return entry != null && mClock.currentTimeMillis() < entry.mPostTime;
}
@@ -213,39 +221,12 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
*
* @param isExpanded True to notify expanded, false to notify collapsed.
*/
- public void setIsPanelExpanded(boolean isExpanded) {
+ void setIsPanelExpanded(boolean isExpanded) {
if (isExpanded != mIsExpanded) {
mIsExpanded = isExpanded;
if (isExpanded) {
mHeadsUpGoingAway = false;
}
- mStatusBarTouchableRegionManager.setIsStatusBarExpanded(isExpanded);
- mStatusBarTouchableRegionManager.updateTouchableRegion();
- }
- }
-
- @Override
- public void onStateChanged(int newState) {
- boolean wasKeyguard = mStatusBarState == StatusBarState.KEYGUARD;
- boolean isKeyguard = newState == StatusBarState.KEYGUARD;
- mStatusBarState = newState;
- if (wasKeyguard && !isKeyguard && mKeysToRemoveWhenLeavingKeyguard.size() != 0) {
- String[] keys = mKeysToRemoveWhenLeavingKeyguard.toArray(new String[0]);
- for (String key : keys) {
- removeAlertEntry(key);
- }
- mKeysToRemoveWhenLeavingKeyguard.clear();
- }
- }
-
- @Override
- public void onDozingChanged(boolean isDozing) {
- if (!isDozing) {
- // Let's make sure all huns we got while dozing time out within the normal timeout
- // duration. Otherwise they could get stuck for a very long time
- for (AlertEntry entry : mAlertEntries.values()) {
- entry.updateEntry(true /* updatePostTime */);
- }
}
}
@@ -262,18 +243,16 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
* Set that we are exiting the headsUp pinned mode, but some notifications might still be
* animating out. This is used to keep the touchable regions in a sane state.
*/
- public void setHeadsUpGoingAway(boolean headsUpGoingAway) {
+ void setHeadsUpGoingAway(boolean headsUpGoingAway) {
if (headsUpGoingAway != mHeadsUpGoingAway) {
mHeadsUpGoingAway = headsUpGoingAway;
- if (!headsUpGoingAway) {
- mStatusBarTouchableRegionManager.updateTouchableRegionAfterLayout();
- } else {
- mStatusBarTouchableRegionManager.updateTouchableRegion();
+ for (OnHeadsUpPhoneListenerChange listener : mHeadsUpPhoneListeners) {
+ listener.onHeadsUpGoingAwayStateChanged(headsUpGoingAway);
}
}
}
- public boolean isHeadsUpGoingAway() {
+ boolean isHeadsUpGoingAway() {
return mHeadsUpGoingAway;
}
@@ -346,63 +325,6 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
dumpInternal(fd, pw, args);
}
- /**
- * Update touch insets to include any area needed for touching a heads up notification.
- *
- * @param info Insets that will include heads up notification touch area after execution.
- */
- @Nullable
- public void updateTouchableRegion(ViewTreeObserver.InternalInsetsInfo info) {
- info.setTouchableInsets(ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION);
- info.touchableRegion.set(calculateTouchableRegion());
- }
-
- public Region calculateTouchableRegion() {
- NotificationEntry topEntry = getTopEntry();
- // This call could be made in an inconsistent state while the pinnedMode hasn't been
- // updated yet, but callbacks leading out of the headsUp manager, querying it. Let's
- // therefore also check if the topEntry is null.
- if (!hasPinnedHeadsUp() || topEntry == null) {
- mTouchableRegion.set(0, 0, mNotificationShadeWindowView.getWidth(), mStatusBarHeight);
- updateRegionForNotch(mTouchableRegion);
-
- } else {
- if (topEntry.isChildInGroup()) {
- final NotificationEntry groupSummary =
- mGroupManager.getGroupSummary(topEntry.getSbn());
- if (groupSummary != null) {
- topEntry = groupSummary;
- }
- }
- ExpandableNotificationRow topRow = topEntry.getRow();
- topRow.getLocationOnScreen(mTmpTwoArray);
- int minX = mTmpTwoArray[0];
- int maxX = mTmpTwoArray[0] + topRow.getWidth();
- int height = topRow.getIntrinsicHeight();
- mTouchableRegion.set(minX, 0, maxX, mHeadsUpInset + height);
- }
- return mTouchableRegion;
- }
-
- private void updateRegionForNotch(Region region) {
- WindowInsets windowInsets = mNotificationShadeWindowView.getRootWindowInsets();
- if (windowInsets == null) {
- Log.w(TAG, "StatusBarWindowView is not attached.");
- return;
- }
- DisplayCutout cutout = windowInsets.getDisplayCutout();
- if (cutout == null) {
- return;
- }
-
- // Expand touchable region such that we also catch touches that just start below the notch
- // area.
- Rect bounds = new Rect();
- ScreenDecorations.DisplayCutoutView.boundsFromDirection(cutout, Gravity.TOP, bounds);
- bounds.offset(0, mDisplayCutoutTouchableRegionSize);
- region.union(bounds);
- }
-
@Override
public boolean shouldExtendLifetime(NotificationEntry entry) {
// We should not defer the removal if reordering isn't allowed since otherwise
@@ -411,11 +333,6 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
return mVisualStabilityManager.isReorderingAllowed() && super.shouldExtendLifetime(entry);
}
- @Override
- public void onConfigChanged(Configuration newConfig) {
- initResources();
- }
-
///////////////////////////////////////////////////////////////////////////////////////////////
// VisualStabilityManager.Callback overrides:
@@ -522,8 +439,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
// time out anyway
&& !entry.showingPulsing()) {
mEntriesToRemoveWhenReorderingAllowed.add(entry);
- mVisualStabilityManager.addReorderingAllowedCallback(
- HeadsUpManagerPhone.this);
+ mVisualStabilityManager.addReorderingAllowedCallback(HeadsUpManagerPhone.this);
} else if (mTrackingHeadsUp) {
mEntriesToRemoveAfterExpand.add(entry);
} else if (mIsAutoHeadsUp && mStatusBarState == StatusBarState.KEYGUARD) {
@@ -626,4 +542,42 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
public interface AnimationStateHandler {
void setHeadsUpGoingAwayAnimationsAllowed(boolean allowed);
}
+
+ /**
+ * Listener to register for HeadsUpNotification Phone changes.
+ */
+ public interface OnHeadsUpPhoneListenerChange {
+ /**
+ * Called when a heads up notification is 'going away' or no longer 'going away'.
+ * See {@link HeadsUpManagerPhone#setHeadsUpGoingAway}.
+ */
+ void onHeadsUpGoingAwayStateChanged(boolean headsUpGoingAway);
+ }
+
+ private final StateListener mStatusBarStateListener = new StateListener() {
+ @Override
+ public void onStateChanged(int newState) {
+ boolean wasKeyguard = mStatusBarState == StatusBarState.KEYGUARD;
+ boolean isKeyguard = newState == StatusBarState.KEYGUARD;
+ mStatusBarState = newState;
+ if (wasKeyguard && !isKeyguard && mKeysToRemoveWhenLeavingKeyguard.size() != 0) {
+ String[] keys = mKeysToRemoveWhenLeavingKeyguard.toArray(new String[0]);
+ for (String key : keys) {
+ removeAlertEntry(key);
+ }
+ mKeysToRemoveWhenLeavingKeyguard.clear();
+ }
+ }
+
+ @Override
+ public void onDozingChanged(boolean isDozing) {
+ if (!isDozing) {
+ // Let's make sure all huns we got while dozing time out within the normal timeout
+ // duration. Otherwise they could get stuck for a very long time
+ for (AlertEntry entry : mAlertEntries.values()) {
+ entry.updateEntry(true /* updatePostTime */);
+ }
+ }
+ }
+ };
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
index d2186f959aba..fb7976ff19a8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
@@ -453,10 +453,11 @@ public class NotificationPanelViewController extends PanelViewController {
KeyguardUpdateMonitor keyguardUpdateMonitor, MetricsLogger metricsLogger,
ActivityManager activityManager, ZenModeController zenModeController,
ConfigurationController configurationController,
- FlingAnimationUtils.Builder flingAnimationUtilsBuilder) {
+ FlingAnimationUtils.Builder flingAnimationUtilsBuilder,
+ StatusBarTouchableRegionManager statusBarTouchableRegionManager) {
super(view, falsingManager, dozeLog, keyguardStateController,
(SysuiStatusBarStateController) statusBarStateController, vibratorHelper,
- latencyTracker, flingAnimationUtilsBuilder);
+ latencyTracker, flingAnimationUtilsBuilder, statusBarTouchableRegionManager);
mView = view;
mMetricsLogger = metricsLogger;
mActivityManager = activityManager;
@@ -704,9 +705,9 @@ public class NotificationPanelViewController extends PanelViewController {
private Rect calculateGestureExclusionRect() {
Rect exclusionRect = null;
- Region touchableRegion = mHeadsUpManager.calculateTouchableRegion();
+ Region touchableRegion = mStatusBarTouchableRegionManager.calculateTouchableRegion();
if (isFullyCollapsed() && touchableRegion != null) {
- // Note: The heads up manager also calculates the non-pinned touchable region
+ // Note: The manager also calculates the non-pinned touchable region
exclusionRect = touchableRegion.getBounds();
}
return exclusionRect != null ? exclusionRect : EMPTY_RECT;
@@ -1914,6 +1915,7 @@ public class NotificationPanelViewController extends PanelViewController {
boolean isExpanded = !isFullyCollapsed() || mExpectingSynthesizedDown;
if (mPanelExpanded != isExpanded) {
mHeadsUpManager.setIsPanelExpanded(isExpanded);
+ mStatusBarTouchableRegionManager.setPanelExpanded(isExpanded);
mStatusBar.setPanelExpanded(isExpanded);
mPanelExpanded = isExpanded;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java
index af46f7bfa82d..30367ed026ac 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java
@@ -73,6 +73,7 @@ public abstract class PanelViewController {
protected StatusBar mStatusBar;
protected HeadsUpManagerPhone mHeadsUpManager;
+ protected final StatusBarTouchableRegionManager mStatusBarTouchableRegionManager;
private float mPeekHeight;
private float mHintDistance;
@@ -206,7 +207,9 @@ public abstract class PanelViewController {
FalsingManager falsingManager, DozeLog dozeLog,
KeyguardStateController keyguardStateController,
SysuiStatusBarStateController statusBarStateController, VibratorHelper vibratorHelper,
- LatencyTracker latencyTracker, FlingAnimationUtils.Builder flingAnimationUtilsBuilder) {
+ LatencyTracker latencyTracker,
+ FlingAnimationUtils.Builder flingAnimationUtilsBuilder,
+ StatusBarTouchableRegionManager statusBarTouchableRegionManager) {
mView = view;
mView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
@Override
@@ -251,6 +254,7 @@ public abstract class PanelViewController {
R.bool.config_enableNotificationShadeDrag);
mVibratorHelper = vibratorHelper;
mVibrateOnOpening = mResources.getBoolean(R.bool.config_vibrateOnIconAnimation);
+ mStatusBarTouchableRegionManager = statusBarTouchableRegionManager;
}
protected void loadDimens() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index 301eac2e82bd..d8d96c1845b8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -356,6 +356,7 @@ public class StatusBar extends SystemUI implements DemoMode,
private final KeyguardBypassController mKeyguardBypassController;
private final KeyguardStateController mKeyguardStateController;
private final HeadsUpManagerPhone mHeadsUpManager;
+ private final StatusBarTouchableRegionManager mStatusBarTouchableRegionManager;
private final DynamicPrivacyController mDynamicPrivacyController;
private final BypassHeadsUpNotifier mBypassHeadsUpNotifier;
private final FalsingManager mFalsingManager;
@@ -676,7 +677,8 @@ public class StatusBar extends SystemUI implements DemoMode,
KeyguardDismissUtil keyguardDismissUtil,
ExtensionController extensionController,
UserInfoControllerImpl userInfoControllerImpl,
- DismissCallbackRegistry dismissCallbackRegistry) {
+ DismissCallbackRegistry dismissCallbackRegistry,
+ StatusBarTouchableRegionManager statusBarTouchableRegionManager) {
super(context);
mNotificationsController = notificationsController;
mLightBarController = lightBarController;
@@ -688,6 +690,7 @@ public class StatusBar extends SystemUI implements DemoMode,
mKeyguardBypassController = keyguardBypassController;
mKeyguardStateController = keyguardStateController;
mHeadsUpManager = headsUpManagerPhone;
+ mStatusBarTouchableRegionManager = statusBarTouchableRegionManager;
mDynamicPrivacyController = dynamicPrivacyController;
mBypassHeadsUpNotifier = bypassHeadsUpNotifier;
mFalsingManager = falsingManager;
@@ -1031,9 +1034,8 @@ public class StatusBar extends SystemUI implements DemoMode,
CollapsedStatusBarFragment.TAG)
.commit();
- mHeadsUpManager.setUp(mNotificationShadeWindowView, mGroupManager, this,
- mVisualStabilityManager);
- mConfigurationController.addCallback(mHeadsUpManager);
+ mHeadsUpManager.setup(mVisualStabilityManager);
+ mStatusBarTouchableRegionManager.setup(this, mNotificationShadeWindowView);
mHeadsUpManager.addListener(this);
mHeadsUpManager.addListener(mNotificationPanelViewController.getOnHeadsUpChangedListener());
mHeadsUpManager.addListener(mVisualStabilityManager);
@@ -2468,6 +2470,12 @@ public class StatusBar extends SystemUI implements DemoMode,
pw.println(" mHeadsUpManager: null");
}
+ if (mStatusBarTouchableRegionManager != null) {
+ mStatusBarTouchableRegionManager.dump(fd, pw, args);
+ } else {
+ pw.println(" mStatusBarTouchableRegionManager: null");
+ }
+
if (mLightBarController != null) {
mLightBarController.dump(fd, pw, args);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java
index 2485513abba5..693cdd21884c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java
@@ -209,7 +209,7 @@ public class StatusBarNotificationPresenter implements NotificationPresenter,
};
mViewHierarchyManager.setUpWithPresenter(this, notifListContainer);
- mEntryManager.setUpWithPresenter(this, notifListContainer, mHeadsUpManager);
+ mEntryManager.setUpWithPresenter(this);
mEntryManager.addNotificationEntryListener(notificationEntryListener);
mEntryManager.addNotificationLifetimeExtender(mHeadsUpManager);
mEntryManager.addNotificationLifetimeExtender(mGutsManager);
@@ -230,8 +230,6 @@ public class StatusBarNotificationPresenter implements NotificationPresenter,
onUserSwitched(mLockscreenUserManager.getCurrentUserId());
});
Dependency.get(ConfigurationController.class).addCallback(this);
-
- notificationAlertingManager.setHeadsUpManager(mHeadsUpManager);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java
index b8fb6d3ebacf..5bab86715663 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java
@@ -17,66 +17,187 @@
package com.android.systemui.statusbar.phone;
import android.annotation.NonNull;
+import android.content.Context;
+import android.content.res.Resources;
import android.graphics.Rect;
+import android.graphics.Region;
+import android.util.Log;
+import android.view.DisplayCutout;
+import android.view.Gravity;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnComputeInternalInsetsListener;
+import android.view.WindowInsets;
-import com.android.systemui.Dependency;
+import com.android.systemui.Dumpable;
import com.android.systemui.R;
+import com.android.systemui.ScreenDecorations;
import com.android.systemui.bubbles.BubbleController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener;
+import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener;
+
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
/**
- * Manages what parts of the status bar are touchable. Clients are primarily UI that displays in the
- * status bar even though the UI doesn't look like part of the status bar.
+ * Manages what parts of the status bar are touchable. Clients are primarily UI that display in the
+ * status bar even though the UI doesn't look like part of the status bar. Currently this
+ * includes HeadsUpNotifications and Bubbles.
*/
-public final class StatusBarTouchableRegionManager implements
- OnComputeInternalInsetsListener, ConfigurationListener {
+@Singleton
+public final class StatusBarTouchableRegionManager implements Dumpable {
+ private static final String TAG = "TouchableRegionManager";
- private final BubbleController mBubbleController = Dependency.get(BubbleController.class);
+ private final Context mContext;
private final HeadsUpManagerPhone mHeadsUpManager;
+ private final NotificationShadeWindowController mNotificationShadeWindowController;
+ private final BubbleController mBubbleController;
+
private boolean mIsStatusBarExpanded = false;
private boolean mShouldAdjustInsets = false;
- private final StatusBar mStatusBar;
- private final View mNotificationShadeWindowView;
+ private StatusBar mStatusBar;
+ private View mNotificationShadeWindowView;
private View mNotificationPanelView;
private boolean mForceCollapsedUntilLayout = false;
- private final NotificationShadeWindowController mNotificationShadeWindowController;
- public StatusBarTouchableRegionManager(HeadsUpManagerPhone headsUpManager,
- @NonNull StatusBar statusBar,
- @NonNull View notificationShadeWindowView) {
+ private Region mTouchableRegion = new Region();
+ private int mDisplayCutoutTouchableRegionSize;
+ private int mStatusBarHeight;
+
+ @Inject
+ public StatusBarTouchableRegionManager(
+ Context context,
+ NotificationShadeWindowController notificationShadeWindowController,
+ ConfigurationController configurationController,
+ HeadsUpManagerPhone headsUpManager,
+ BubbleController bubbleController
+ ) {
+ mContext = context;
+ initResources();
+ configurationController.addCallback(new ConfigurationListener() {
+ @Override
+ public void onDensityOrFontScaleChanged() {
+ initResources();
+ }
+
+ @Override
+ public void onOverlayChanged() {
+ initResources();
+ }
+ });
+
mHeadsUpManager = headsUpManager;
- mStatusBar = statusBar;
- mNotificationShadeWindowView = notificationShadeWindowView;
- mNotificationShadeWindowController =
- Dependency.get(NotificationShadeWindowController.class);
+ mHeadsUpManager.addListener(
+ new OnHeadsUpChangedListener() {
+ @Override
+ public void onHeadsUpPinnedModeChanged(boolean hasPinnedNotification) {
+ if (Log.isLoggable(TAG, Log.WARN)) {
+ Log.w(TAG, "onHeadsUpPinnedModeChanged");
+ }
+ updateTouchableRegion();
+ }
+ });
+ mHeadsUpManager.addHeadsUpPhoneListener(
+ new HeadsUpManagerPhone.OnHeadsUpPhoneListenerChange() {
+ @Override
+ public void onHeadsUpGoingAwayStateChanged(boolean headsUpGoingAway) {
+ if (!headsUpGoingAway) {
+ updateTouchableRegionAfterLayout();
+ } else {
+ updateTouchableRegion();
+ }
+ }
+ });
- mBubbleController.setBubbleStateChangeListener((hasBubbles) -> {
+ mNotificationShadeWindowController = notificationShadeWindowController;
+ mNotificationShadeWindowController.setForcePluginOpenListener((forceOpen) -> {
updateTouchableRegion();
});
- mNotificationShadeWindowController.setForcePluginOpenListener((forceOpen) -> {
+ mBubbleController = bubbleController;
+ mBubbleController.setBubbleStateChangeListener((hasBubbles) -> {
updateTouchableRegion();
});
- Dependency.get(ConfigurationController.class).addCallback(this);
- if (mNotificationShadeWindowView != null) {
- mNotificationPanelView = mNotificationShadeWindowView.findViewById(
- R.id.notification_panel);
+ }
+
+ protected void setup(
+ @NonNull StatusBar statusBar,
+ @NonNull View notificationShadeWindowView) {
+ mStatusBar = statusBar;
+ mNotificationShadeWindowView = notificationShadeWindowView;
+ mNotificationPanelView = mNotificationShadeWindowView.findViewById(R.id.notification_panel);
+ }
+
+ @Override
+ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ pw.println("StatusBarTouchableRegionManager state:");
+ pw.print(" mTouchableRegion=");
+ pw.println(mTouchableRegion);
+ }
+
+ /**
+ * Notify that the status bar panel gets expanded or collapsed.
+ *
+ * @param isExpanded True to notify expanded, false to notify collapsed.
+ */
+ void setPanelExpanded(boolean isExpanded) {
+ if (isExpanded != mIsStatusBarExpanded) {
+ mIsStatusBarExpanded = isExpanded;
+ if (isExpanded) {
+ // make sure our state is sane
+ mForceCollapsedUntilLayout = false;
+ }
+ updateTouchableRegion();
}
}
/**
+ * Calculates the touch region needed for heads up notifications, taking into consideration
+ * any existing display cutouts (notch)
+ * @return the heads up notification touch area
+ */
+ Region calculateTouchableRegion() {
+ // Update touchable region for HeadsUp notifications
+ final Region headsUpTouchableRegion = mHeadsUpManager.getTouchableRegion();
+ if (headsUpTouchableRegion != null) {
+ mTouchableRegion.set(headsUpTouchableRegion);
+ } else {
+ // If there aren't any HUNs, update the touch region to the status bar
+ // width/height, potentially adjusting for a display cutout (notch)
+ mTouchableRegion.set(0, 0, mNotificationShadeWindowView.getWidth(),
+ mStatusBarHeight);
+ updateRegionForNotch(mTouchableRegion);
+ }
+
+ // Update touchable region for bubbles
+ Rect bubbleRect = mBubbleController.getTouchableRegion();
+ if (bubbleRect != null) {
+ mTouchableRegion.union(bubbleRect);
+ }
+ return mTouchableRegion;
+ }
+
+ private void initResources() {
+ Resources resources = mContext.getResources();
+ mDisplayCutoutTouchableRegionSize = resources.getDimensionPixelSize(
+ com.android.internal.R.dimen.display_cutout_touchable_region_size);
+ mStatusBarHeight =
+ resources.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);
+ }
+
+ /**
* Set the touchable portion of the status bar based on what elements are visible.
*/
- public void updateTouchableRegion() {
+ private void updateTouchableRegion() {
boolean hasCutoutInset = (mNotificationShadeWindowView != null)
&& (mNotificationShadeWindowView.getRootWindowInsets() != null)
&& (mNotificationShadeWindowView.getRootWindowInsets().getDisplayCutout() != null);
- boolean shouldObserve =
- mHeadsUpManager.hasPinnedHeadsUp() || mHeadsUpManager.isHeadsUpGoingAway()
+ boolean shouldObserve = mHeadsUpManager.hasPinnedHeadsUp()
+ || mHeadsUpManager.isHeadsUpGoingAway()
|| mBubbleController.hasBubbles()
|| mForceCollapsedUntilLayout
|| hasCutoutInset
@@ -87,11 +208,11 @@ public final class StatusBarTouchableRegionManager implements
if (shouldObserve) {
mNotificationShadeWindowView.getViewTreeObserver()
- .addOnComputeInternalInsetsListener(this);
+ .addOnComputeInternalInsetsListener(mOnComputeInternalInsetsListener);
mNotificationShadeWindowView.requestLayout();
} else {
mNotificationShadeWindowView.getViewTreeObserver()
- .removeOnComputeInternalInsetsListener(this);
+ .removeOnComputeInternalInsetsListener(mOnComputeInternalInsetsListener);
}
mShouldAdjustInsets = shouldObserve;
}
@@ -99,7 +220,7 @@ public final class StatusBarTouchableRegionManager implements
/**
* Calls {@code updateTouchableRegion()} after a layout pass completes.
*/
- public void updateTouchableRegionAfterLayout() {
+ private void updateTouchableRegionAfterLayout() {
if (mNotificationPanelView != null) {
mForceCollapsedUntilLayout = true;
mNotificationPanelView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@@ -116,34 +237,38 @@ public final class StatusBarTouchableRegionManager implements
}
}
- /**
- * Notify that the status bar panel gets expanded or collapsed.
- *
- * @param isExpanded True to notify expanded, false to notify collapsed.
- */
- public void setIsStatusBarExpanded(boolean isExpanded) {
- if (isExpanded != mIsStatusBarExpanded) {
- mIsStatusBarExpanded = isExpanded;
- if (isExpanded) {
- // make sure our state is sane
- mForceCollapsedUntilLayout = false;
- }
- updateTouchableRegion();
+ private void updateRegionForNotch(Region touchableRegion) {
+ WindowInsets windowInsets = mNotificationShadeWindowView.getRootWindowInsets();
+ if (windowInsets == null) {
+ Log.w(TAG, "StatusBarWindowView is not attached.");
+ return;
}
- }
-
- @Override
- public void onComputeInternalInsets(ViewTreeObserver.InternalInsetsInfo info) {
- if (mIsStatusBarExpanded || mStatusBar.isBouncerShowing()) {
- // The touchable region is always the full area when expanded
+ DisplayCutout cutout = windowInsets.getDisplayCutout();
+ if (cutout == null) {
return;
}
- mHeadsUpManager.updateTouchableRegion(info);
+ // Expand touchable region such that we also catch touches that just start below the notch
+ // area.
+ Rect bounds = new Rect();
+ ScreenDecorations.DisplayCutoutView.boundsFromDirection(cutout, Gravity.TOP, bounds);
+ bounds.offset(0, mDisplayCutoutTouchableRegionSize);
+ touchableRegion.union(bounds);
+ }
- Rect bubbleRect = mBubbleController.getTouchableRegion();
- if (bubbleRect != null) {
- info.touchableRegion.union(bubbleRect);
+ private final OnComputeInternalInsetsListener mOnComputeInternalInsetsListener =
+ new OnComputeInternalInsetsListener() {
+ @Override
+ public void onComputeInternalInsets(ViewTreeObserver.InternalInsetsInfo info) {
+ if (mIsStatusBarExpanded || mStatusBar.isBouncerShowing()) {
+ // The touchable region is always the full area when expanded
+ return;
+ }
+
+ // Update touch insets to include any area needed for touching features that live in
+ // the status bar (ie: heads up notifications or bubbles)
+ info.setTouchableInsets(ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION);
+ info.touchableRegion.set(calculateTouchableRegion());
}
- }
+ };
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java
index 26459a9a66ba..e64f8214bb71 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java
@@ -85,6 +85,7 @@ import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.phone.StatusBarNotificationActivityStarter;
+import com.android.systemui.statusbar.phone.StatusBarTouchableRegionManager;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
@@ -192,7 +193,8 @@ public interface StatusBarPhoneModule {
KeyguardDismissUtil keyguardDismissUtil,
ExtensionController extensionController,
UserInfoControllerImpl userInfoControllerImpl,
- DismissCallbackRegistry dismissCallbackRegistry) {
+ DismissCallbackRegistry dismissCallbackRegistry,
+ StatusBarTouchableRegionManager statusBarTouchableRegionManager) {
return new StatusBar(
context,
notificationsController,
@@ -267,6 +269,7 @@ public interface StatusBarPhoneModule {
keyguardDismissUtil,
extensionController,
userInfoControllerImpl,
- dismissCallbackRegistry);
+ dismissCallbackRegistry,
+ statusBarTouchableRegionManager);
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java
index 6d83ac32cef5..644ed3d6e2b5 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java
@@ -85,7 +85,7 @@ public class NonPhoneDependencyTest extends SysuiTestCase {
Dependency.get(NotificationLockscreenUserManager.class);
NotificationViewHierarchyManager viewHierarchyManager =
Dependency.get(NotificationViewHierarchyManager.class);
- entryManager.setUpWithPresenter(mPresenter, mListContainer, mHeadsUpManager);
+ entryManager.setUpWithPresenter(mPresenter);
entryManager.addNotificationEntryListener(mEntryListener);
gutsManager.setUpWithPresenter(mPresenter, mListContainer,
mCheckSaveListener, mOnSettingsClickListener);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java
index f1fba792a882..f384067efec0 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java
@@ -256,7 +256,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase {
mLeakDetector,
mock(ForegroundServiceDismissalFeatureController.class)
);
- mEntryManager.setUpWithPresenter(mPresenter, mListContainer, mHeadsUpManager);
+ mEntryManager.setUpWithPresenter(mPresenter);
mEntryManager.addNotificationEntryListener(mEntryListener);
mEntryManager.addNotificationRemoveInterceptor(mRemoveInterceptor);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/TestableNotificationEntryManager.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/TestableNotificationEntryManager.kt
index 0e730e5c3ffb..d522f903c83a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/TestableNotificationEntryManager.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/TestableNotificationEntryManager.kt
@@ -22,11 +22,8 @@ import com.android.systemui.statusbar.NotificationRemoteInputManager
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.collection.NotificationRankingManager
import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinder
-import com.android.systemui.statusbar.notification.stack.NotificationListContainer
-import com.android.systemui.statusbar.phone.HeadsUpManagerPhone
import com.android.systemui.statusbar.phone.NotificationGroupManager
import com.android.systemui.util.leak.LeakDetector
-
import java.util.concurrent.CountDownLatch
/**
@@ -53,11 +50,9 @@ class TestableNotificationEntryManager(
}
fun setUpForTest(
- presenter: NotificationPresenter?,
- listContainer: NotificationListContainer?,
- headsUpManager: HeadsUpManagerPhone?
+ presenter: NotificationPresenter?
) {
- super.setUpWithPresenter(presenter, listContainer, headsUpManager)
+ super.setUpWithPresenter(presenter)
}
fun setActiveNotificationList(activeList: List<NotificationEntry>) {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java
index 9a52ee8d6af7..5a89fc44f970 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java
@@ -56,6 +56,7 @@ import com.android.systemui.statusbar.notification.collection.notifcollection.No
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow.ExpansionLogger;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow.OnExpandClickListener;
import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.InflationFlag;
+import com.android.systemui.statusbar.phone.ConfigurationControllerImpl;
import com.android.systemui.statusbar.phone.HeadsUpManagerPhone;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
@@ -102,8 +103,8 @@ public class NotificationTestHelper {
mStatusBarStateController = mock(StatusBarStateController.class);
mGroupManager = new NotificationGroupManager(mStatusBarStateController);
mHeadsUpManager = new HeadsUpManagerPhone(mContext, mStatusBarStateController,
- mock(KeyguardBypassController.class));
- mHeadsUpManager.setUp(null, mGroupManager, null, null);
+ mock(KeyguardBypassController.class), mock(NotificationGroupManager.class),
+ mock(ConfigurationControllerImpl.class));
mGroupManager.setHeadsUpManager(mHeadsUpManager);
NotificationContentInflater contentBinder = new NotificationContentInflater(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java
index 9ccee75a3d09..a9e08ba79240 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java
@@ -185,7 +185,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
mock(LeakDetector.class),
mock(ForegroundServiceDismissalFeatureController.class)
);
- mEntryManager.setUpForTest(mock(NotificationPresenter.class), null, mHeadsUpManager);
+ mEntryManager.setUpForTest(mock(NotificationPresenter.class));
when(mFeatureFlags.isNewNotifPipelineRenderingEnabled()).thenReturn(false);
NotificationShelf notificationShelf = mock(NotificationShelf.class);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java
index 50d8bf0b02c2..6d642ec44314 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java
@@ -62,16 +62,21 @@ public class HeadsUpManagerPhoneTest extends AlertingNotificationManagerTest {
@Mock private StatusBar mBar;
@Mock private StatusBarStateController mStatusBarStateController;
@Mock private KeyguardBypassController mBypassController;
+ @Mock private ConfigurationControllerImpl mConfigurationController;
private boolean mLivesPastNormalTime;
private final class TestableHeadsUpManagerPhone extends HeadsUpManagerPhone {
- TestableHeadsUpManagerPhone(Context context, View notificationShadeWindowView,
- NotificationGroupManager groupManager, StatusBar bar,
+ TestableHeadsUpManagerPhone(
+ Context context,
+ NotificationGroupManager groupManager,
VisualStabilityManager vsManager,
StatusBarStateController statusBarStateController,
- KeyguardBypassController keyguardBypassController) {
- super(context, statusBarStateController, keyguardBypassController);
- setUp(notificationShadeWindowView, groupManager, bar, vsManager);
+ KeyguardBypassController keyguardBypassController,
+ ConfigurationController configurationController
+ ) {
+ super(context, statusBarStateController, keyguardBypassController,
+ groupManager, configurationController);
+ setup(vsManager);
mMinimumDisplayTime = TEST_MINIMUM_DISPLAY_TIME;
mAutoDismissNotificationDecay = TEST_AUTO_DISMISS_TIME;
}
@@ -91,8 +96,8 @@ public class HeadsUpManagerPhoneTest extends AlertingNotificationManagerTest {
mDependency.injectMockDependency(BubbleController.class);
mDependency.injectMockDependency(NotificationShadeWindowController.class);
mDependency.injectMockDependency(ConfigurationController.class);
- mHeadsUpManager = new TestableHeadsUpManagerPhone(mContext, mNotificationShadeWindowView,
- mGroupManager, mBar, mVSManager, mStatusBarStateController, mBypassController);
+ mHeadsUpManager = new TestableHeadsUpManagerPhone(mContext, mGroupManager, mVSManager,
+ mStatusBarStateController, mBypassController, mConfigurationController);
super.setUp();
mHeadsUpManager.mHandler = mTestHandler;
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java
index 5fb71599e2a0..13bf38c7f0f3 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java
@@ -138,6 +138,8 @@ public class NotificationPanelViewTest extends SysuiTestCase {
@Mock
private NotificationEntryManager mNotificationEntryManager;
@Mock
+ private StatusBarTouchableRegionManager mStatusBarTouchableRegionManager;
+ @Mock
private KeyguardStateController mKeyguardStateController;
@Mock
private DozeLog mDozeLog;
@@ -221,7 +223,7 @@ public class NotificationPanelViewTest extends SysuiTestCase {
mDozeParameters, mCommandQueue, mVibratorHelper,
mLatencyTracker, mPowerManager, mAccessibilityManager, 0, mUpdateMonitor,
mMetricsLogger, mActivityManager, mZenModeController, mConfigurationController,
- mFlingAnimationUtilsBuilder);
+ mFlingAnimationUtilsBuilder, mStatusBarTouchableRegionManager);
mNotificationPanelViewController.initDependencies(mStatusBar, mGroupManager,
mNotificationShelf, mNotificationAreaController, mScrimController);
mNotificationPanelViewController.setHeadsUpManager(mHeadsUpManager);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
index db17a6e106b4..e5ee439d4bb7 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
@@ -236,6 +236,7 @@ public class StatusBarTest extends SysuiTestCase {
@Mock private LightsOutNotifController mLightsOutNotifController;
@Mock private ViewMediatorCallback mViewMediatorCallback;
@Mock private DismissCallbackRegistry mDismissCallbackRegistry;
+ @Mock private StatusBarTouchableRegionManager mStatusBarTouchableRegionManager;
@Mock private ScreenPinningRequest mScreenPinningRequest;
@Mock private LockscreenLockIconController mLockscreenLockIconController;
@Mock private StatusBarNotificationActivityStarter.Builder
@@ -397,7 +398,8 @@ public class StatusBarTest extends SysuiTestCase {
mKeyguardDismissUtil,
mExtensionController,
mUserInfoControllerImpl,
- mDismissCallbackRegistry);
+ mDismissCallbackRegistry,
+ mStatusBarTouchableRegionManager);
when(mNotificationShadeWindowView.findViewById(R.id.lock_icon_container)).thenReturn(
mLockIconContainer);