From cfe50f47493965c8593ab8587911246dc7f44148 Mon Sep 17 00:00:00 2001 From: Jordan Demeulenaere Date: Tue, 30 Aug 2022 15:13:16 +0200 Subject: Use ActivityStarter to start Settings activity This CL fixes the Activity started when clicking the "Settings" button of the Volume dialog. This ensures that the keyguard is dismissed if we are showing the Dialog on the keyguard. Bug: 202262476 Test: Manual Change-Id: I3fcfba5a46cbef2e60733e3dbe93578d10db6f3a --- .../src/com/android/systemui/volume/VolumePanelDialog.java | 12 +++++++++--- .../src/com/android/systemui/volume/VolumePanelFactory.kt | 4 +++- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'packages/SystemUI') diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumePanelDialog.java b/packages/SystemUI/src/com/android/systemui/volume/VolumePanelDialog.java index 2c74fb911688..87a167baf9bf 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumePanelDialog.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumePanelDialog.java @@ -52,6 +52,7 @@ import com.android.settingslib.bluetooth.LocalBluetoothManager; import com.android.settingslib.bluetooth.LocalBluetoothProfileManager; import com.android.settingslib.media.MediaOutputConstants; import com.android.systemui.R; +import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.statusbar.phone.SystemUIDialog; import java.util.ArrayList; @@ -69,6 +70,7 @@ public class VolumePanelDialog extends SystemUIDialog implements LifecycleOwner private static final int DURATION_SLICE_BINDING_TIMEOUT_MS = 200; private static final int DEFAULT_SLICE_SIZE = 4; + private final ActivityStarter mActivityStarter; private RecyclerView mVolumePanelSlices; private VolumePanelSlicesAdapter mVolumePanelSlicesAdapter; private final LifecycleRegistry mLifecycleRegistry; @@ -78,8 +80,10 @@ public class VolumePanelDialog extends SystemUIDialog implements LifecycleOwner private boolean mSlicesReadyToLoad; private LocalBluetoothProfileManager mProfileManager; - public VolumePanelDialog(Context context, boolean aboveStatusBar) { + public VolumePanelDialog(Context context, + ActivityStarter activityStarter, boolean aboveStatusBar) { super(context); + mActivityStarter = activityStarter; mLifecycleRegistry = new LifecycleRegistry(this); if (!aboveStatusBar) { getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY); @@ -100,9 +104,11 @@ public class VolumePanelDialog extends SystemUIDialog implements LifecycleOwner doneButton.setOnClickListener(v -> dismiss()); Button settingsButton = dialogView.findViewById(R.id.settings_button); settingsButton.setOnClickListener(v -> { - getContext().startActivity(new Intent(Settings.ACTION_SOUND_SETTINGS).addFlags( - Intent.FLAG_ACTIVITY_NEW_TASK)); dismiss(); + + Intent intent = new Intent(Settings.ACTION_SOUND_SETTINGS); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + mActivityStarter.startActivity(intent, /* dismissShade= */ true); }); LocalBluetoothManager localBluetoothManager = LocalBluetoothManager.getInstance( diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumePanelFactory.kt b/packages/SystemUI/src/com/android/systemui/volume/VolumePanelFactory.kt index c2fafbf9f55b..0debe0e4cd80 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumePanelFactory.kt +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumePanelFactory.kt @@ -21,6 +21,7 @@ import android.util.Log import android.view.View import com.android.systemui.animation.DialogLaunchAnimator import com.android.systemui.dagger.SysUISingleton +import com.android.systemui.plugins.ActivityStarter import javax.inject.Inject private const val TAG = "VolumePanelFactory" @@ -33,6 +34,7 @@ private val DEBUG = Log.isLoggable(TAG, Log.DEBUG) @SysUISingleton class VolumePanelFactory @Inject constructor( private val context: Context, + private val activityStarter: ActivityStarter, private val dialogLaunchAnimator: DialogLaunchAnimator ) { companion object { @@ -45,7 +47,7 @@ class VolumePanelFactory @Inject constructor( return } - val dialog = VolumePanelDialog(context, aboveStatusBar) + val dialog = VolumePanelDialog(context, activityStarter, aboveStatusBar) volumePanelDialog = dialog // Show the dialog. -- cgit v1.2.3-59-g8ed1b