summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2020-02-19 22:31:25 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-02-19 22:31:25 +0000
commit40e124cac986d578bd63563c114767eff99e131d (patch)
treeba889348926033b18e81587a33cc6b1e341724f0
parent79a42a6cf9f4b42a1588c05da2519e9782336964 (diff)
parent25400fdcb92305814e1ee614f05947e51b502375 (diff)
Merge "DO NOT MERGE Have volume UI dismiss on home button press." into qt-qpr1-dev
-rw-r--r--packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java b/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java
index f91c90ec636f..b87844ea74a1 100644
--- a/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java
+++ b/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java
@@ -26,8 +26,11 @@ import android.app.KeyguardManager;
import android.car.Car;
import android.car.Car.CarServiceLifecycleListener;
import android.car.media.CarAudioManager;
+import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.IntentFilter;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.graphics.Color;
@@ -39,6 +42,7 @@ import android.os.Debug;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
+import android.os.UserHandle;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
@@ -175,6 +179,17 @@ public class CarVolumeDialogImpl implements VolumeDialog {
mCarAudioManager.registerCarVolumeCallback(mVolumeChangeCallback);
};
+ private final BroadcastReceiver mHomeButtonPressedBroadcastReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (!intent.getAction().equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)) {
+ return;
+ }
+
+ dismiss(Events.DISMISS_REASON_VOLUME_CONTROLLER);
+ }
+ };
+
public CarVolumeDialogImpl(Context context) {
mContext = context;
mKeyguard = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
@@ -204,6 +219,10 @@ public class CarVolumeDialogImpl implements VolumeDialog {
public void init(int windowType, Callback callback) {
initDialog();
+ mContext.registerReceiverAsUser(mHomeButtonPressedBroadcastReceiver, UserHandle.CURRENT,
+ new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS), /* broadcastPermission= */
+ null, /* scheduler= */ null);
+
((CarSystemUIFactory) SystemUIFactory.getInstance()).getCarServiceProvider(mContext)
.addListener(mCarServiceLifecycleListener);
}
@@ -212,6 +231,8 @@ public class CarVolumeDialogImpl implements VolumeDialog {
public void destroy() {
mHandler.removeCallbacksAndMessages(/* token= */ null);
+ mContext.unregisterReceiver(mHomeButtonPressedBroadcastReceiver);
+
cleanupAudioManager();
}