From c0379bee83f575a2f786ee49e414246de1541c85 Mon Sep 17 00:00:00 2001 From: Heemin Seog Date: Wed, 10 Jun 2020 15:32:16 -0700 Subject: [PATCH] Dismiss panel when requested to close system dialogs Bug: 158470632 Test: manual (open notif panel - adb shell am broadcast -a android.intent.action.CLOSE_SYSTEM_DIALOGS) Change-Id: I3c72673cd0ae7156b2078942c997f72c73019365 --- .../BottomNotificationPanelViewMediator.java | 3 ++ .../NotificationPanelViewMediator.java | 29 +++++++++++++++++++ .../TopNotificationPanelViewMediator.java | 3 ++ 3 files changed, 35 insertions(+) diff --git a/packages/CarSystemUI/src/com/android/systemui/car/notification/BottomNotificationPanelViewMediator.java b/packages/CarSystemUI/src/com/android/systemui/car/notification/BottomNotificationPanelViewMediator.java index 6d140cae5442e..7d353f5acd9a2 100644 --- a/packages/CarSystemUI/src/com/android/systemui/car/notification/BottomNotificationPanelViewMediator.java +++ b/packages/CarSystemUI/src/com/android/systemui/car/notification/BottomNotificationPanelViewMediator.java @@ -16,6 +16,7 @@ package com.android.systemui.car.notification; +import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.car.CarDeviceProvisionedController; import com.android.systemui.car.navigationbar.CarNavigationBarController; import com.android.systemui.car.window.OverlayPanelViewController; @@ -37,6 +38,7 @@ public class BottomNotificationPanelViewMediator extends NotificationPanelViewMe NotificationPanelViewController notificationPanelViewController, PowerManagerHelper powerManagerHelper, + BroadcastDispatcher broadcastDispatcher, CarDeviceProvisionedController carDeviceProvisionedController, ConfigurationController configurationController @@ -44,6 +46,7 @@ public class BottomNotificationPanelViewMediator extends NotificationPanelViewMe super(carNavigationBarController, notificationPanelViewController, powerManagerHelper, + broadcastDispatcher, carDeviceProvisionedController, configurationController); notificationPanelViewController.setOverlayDirection( diff --git a/packages/CarSystemUI/src/com/android/systemui/car/notification/NotificationPanelViewMediator.java b/packages/CarSystemUI/src/com/android/systemui/car/notification/NotificationPanelViewMediator.java index 41349b284147c..0c185bae81998 100644 --- a/packages/CarSystemUI/src/com/android/systemui/car/notification/NotificationPanelViewMediator.java +++ b/packages/CarSystemUI/src/com/android/systemui/car/notification/NotificationPanelViewMediator.java @@ -17,10 +17,17 @@ package com.android.systemui.car.notification; import android.car.hardware.power.CarPowerManager; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; import android.content.res.Configuration; +import android.os.UserHandle; +import android.util.Log; import androidx.annotation.CallSuper; +import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.car.CarDeviceProvisionedController; import com.android.systemui.car.navigationbar.CarNavigationBarController; import com.android.systemui.car.window.OverlayViewMediator; @@ -37,18 +44,36 @@ import javax.inject.Singleton; public class NotificationPanelViewMediator implements OverlayViewMediator, ConfigurationController.ConfigurationListener { + private static final boolean DEBUG = false; + private static final String TAG = "NotificationPanelVM"; + private final CarNavigationBarController mCarNavigationBarController; private final NotificationPanelViewController mNotificationPanelViewController; private final PowerManagerHelper mPowerManagerHelper; + private final BroadcastDispatcher mBroadcastDispatcher; private final CarDeviceProvisionedController mCarDeviceProvisionedController; private final ConfigurationController mConfigurationController; + private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + if (DEBUG) Log.v(TAG, "onReceive: " + intent); + String action = intent.getAction(); + if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) { + if (mNotificationPanelViewController.isPanelExpanded()) { + mNotificationPanelViewController.toggle(); + } + } + } + }; + @Inject public NotificationPanelViewMediator( CarNavigationBarController carNavigationBarController, NotificationPanelViewController notificationPanelViewController, PowerManagerHelper powerManagerHelper, + BroadcastDispatcher broadcastDispatcher, CarDeviceProvisionedController carDeviceProvisionedController, ConfigurationController configurationController @@ -56,6 +81,7 @@ public class NotificationPanelViewMediator implements OverlayViewMediator, mCarNavigationBarController = carNavigationBarController; mNotificationPanelViewController = notificationPanelViewController; mPowerManagerHelper = powerManagerHelper; + mBroadcastDispatcher = broadcastDispatcher; mCarDeviceProvisionedController = carDeviceProvisionedController; mConfigurationController = configurationController; } @@ -84,6 +110,9 @@ public class NotificationPanelViewMediator implements OverlayViewMediator, return mNotificationPanelViewController.isPanelExpanded(); } }); + + mBroadcastDispatcher.registerReceiver(mBroadcastReceiver, + new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS), null, UserHandle.ALL); } @Override diff --git a/packages/CarSystemUI/src/com/android/systemui/car/notification/TopNotificationPanelViewMediator.java b/packages/CarSystemUI/src/com/android/systemui/car/notification/TopNotificationPanelViewMediator.java index 8d3eb4c2bbeed..89c9931ac76e5 100644 --- a/packages/CarSystemUI/src/com/android/systemui/car/notification/TopNotificationPanelViewMediator.java +++ b/packages/CarSystemUI/src/com/android/systemui/car/notification/TopNotificationPanelViewMediator.java @@ -16,6 +16,7 @@ package com.android.systemui.car.notification; +import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.car.CarDeviceProvisionedController; import com.android.systemui.car.navigationbar.CarNavigationBarController; import com.android.systemui.car.window.OverlayPanelViewController; @@ -37,6 +38,7 @@ public class TopNotificationPanelViewMediator extends NotificationPanelViewMedia NotificationPanelViewController notificationPanelViewController, PowerManagerHelper powerManagerHelper, + BroadcastDispatcher broadcastDispatcher, CarDeviceProvisionedController carDeviceProvisionedController, ConfigurationController configurationController @@ -44,6 +46,7 @@ public class TopNotificationPanelViewMediator extends NotificationPanelViewMedia super(carNavigationBarController, notificationPanelViewController, powerManagerHelper, + broadcastDispatcher, carDeviceProvisionedController, configurationController); notificationPanelViewController.setOverlayDirection(