Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9878e969 authored by Dave Mankoff's avatar Dave Mankoff Committed by Android (Google) Code Review
Browse files

Merge "Remove calls to `new SystemUIDialog(context)`" into main

parents 5a07aaeb 5af566de
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -28,12 +28,11 @@ import javax.inject.Inject
/**
 * Factory to create dialogs for consenting to show app panels for specific apps.
 *
 * [internalDialogFactory] is for facilitating testing.
 * [dialogFactory] is for facilitating testing.
 */
class PanelConfirmationDialogFactory(
    private val internalDialogFactory: (Context) -> SystemUIDialog
class PanelConfirmationDialogFactory @Inject constructor(
        private val dialogFactory: SystemUIDialog.Factory
) {
    @Inject constructor() : this({ SystemUIDialog(it) })

    /**
     * Creates a dialog to show to the user. [response] will be true if an only if the user responds
@@ -48,7 +47,7 @@ class PanelConfirmationDialogFactory(
            DialogInterface.OnClickListener { _, which ->
                response.accept(which == DialogInterface.BUTTON_POSITIVE)
            }
        return internalDialogFactory(context).apply {
        return dialogFactory.create(context).apply {
            setTitle(this.context.getString(R.string.controls_panel_authorization_title, appName))
            setMessage(this.context.getString(R.string.controls_panel_authorization, appName))
            setCanceledOnTouchOutside(true)
+7 −6
Original line number Diff line number Diff line
@@ -25,9 +25,10 @@ import com.android.systemui.statusbar.phone.SystemUIDialog
import java.util.function.Consumer
import javax.inject.Inject

class ControlsDialogsFactory(private val internalDialogFactory: (Context) -> SystemUIDialog) {
class ControlsDialogsFactory @Inject constructor(
        private val dialogFactory: SystemUIDialog.Factory
) {

    @Inject constructor() : this({ SystemUIDialog(it) })

    fun createRemoveAppDialog(
            context: Context,
@@ -38,7 +39,7 @@ class ControlsDialogsFactory(private val internalDialogFactory: (Context) -> Sys
            DialogInterface.OnClickListener { _, which ->
                response.accept(which == DialogInterface.BUTTON_POSITIVE)
            }
        return internalDialogFactory(context).apply {
        return dialogFactory.create(context).apply {
            setTitle(context.getString(R.string.controls_panel_remove_app_authorization, appName))
            setCanceledOnTouchOutside(true)
            setOnCancelListener { response.accept(false) }
+15 −7
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ import java.util.Locale;
import java.util.Objects;

import javax.inject.Inject;
import javax.inject.Provider;

/**
 */
@@ -149,6 +150,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
    public static final String EXTRA_CONFIRM_ONLY = "extra_confirm_only";

    private final Context mContext;
    private final SystemUIDialog.Factory mSystemUIDialogFactory;
    private final NotificationManager mNoMan;
    private final PowerManager mPowerMan;
    private final KeyguardManager mKeyguard;
@@ -186,11 +188,17 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
    /**
     */
    @Inject
    public PowerNotificationWarnings(Context context, ActivityStarter activityStarter,
            BroadcastSender broadcastSender, Lazy<BatteryController> batteryControllerLazy,
            DialogLaunchAnimator dialogLaunchAnimator, UiEventLogger uiEventLogger,
            GlobalSettings globalSettings, UserTracker userTracker) {
    public PowerNotificationWarnings(
            Context context,
            ActivityStarter activityStarter,
            BroadcastSender broadcastSender,
            Lazy<BatteryController> batteryControllerLazy,
            DialogLaunchAnimator dialogLaunchAnimator,
            UiEventLogger uiEventLogger,
            UserTracker userTracker,
            SystemUIDialog.Factory systemUIDialogFactory) {
        mContext = context;
        mSystemUIDialogFactory = systemUIDialogFactory;
        mNoMan = mContext.getSystemService(NotificationManager.class);
        mPowerMan = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        mKeyguard = mContext.getSystemService(KeyguardManager.class);
@@ -444,7 +452,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {

    private void showHighTemperatureDialog() {
        if (mHighTempDialog != null) return;
        final SystemUIDialog d = new SystemUIDialog(mContext);
        final SystemUIDialog d = mSystemUIDialogFactory.create();
        d.setIconAttribute(android.R.attr.alertDialogIcon);
        d.setTitle(R.string.high_temp_title);
        d.setMessage(R.string.high_temp_dialog_message);
@@ -479,7 +487,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {

    private void showThermalShutdownDialog() {
        if (mThermalShutdownDialog != null) return;
        final SystemUIDialog d = new SystemUIDialog(mContext);
        final SystemUIDialog d = mSystemUIDialogFactory.create();
        d.setIconAttribute(android.R.attr.alertDialogIcon);
        d.setTitle(R.string.thermal_shutdown_title);
        d.setMessage(R.string.thermal_shutdown_dialog_message);
@@ -643,7 +651,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {

    private void showStartSaverConfirmation(Bundle extras) {
        if (mSaverConfirmation != null || mUseExtraSaverConfirmation) return;
        final SystemUIDialog d = new SystemUIDialog(mContext);
        final SystemUIDialog d = mSystemUIDialogFactory.create();
        final boolean confirmOnly = extras.getBoolean(BatterySaverUtils.EXTRA_CONFIRM_TEXT_ONLY);
        final int batterySaverTriggerMode =
                extras.getInt(BatterySaverUtils.EXTRA_POWER_SAVE_MODE_TRIGGER,
+3 −2
Original line number Diff line number Diff line
@@ -148,7 +148,8 @@ class FgsManagerControllerImpl @Inject constructor(
    private val deviceConfigProxy: DeviceConfigProxy,
    private val dialogLaunchAnimator: DialogLaunchAnimator,
    private val broadcastDispatcher: BroadcastDispatcher,
    private val dumpManager: DumpManager
    private val dumpManager: DumpManager,
    private val systemUIDialogFactory: SystemUIDialog.Factory,
) : Dumpable, FgsManagerController {

    companion object {
@@ -375,7 +376,7 @@ class FgsManagerControllerImpl @Inject constructor(
    override fun showDialog(expandable: Expandable?) {
        synchronized(lock) {
            if (dialog == null) {
                val dialog = SystemUIDialog(context)
                val dialog = systemUIDialogFactory.create()
                dialog.setTitle(R.string.fgs_manager_dialog_title)
                dialog.setMessage(R.string.fgs_manager_dialog_message)

+5 −2
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ public class DataSaverTile extends QSTileImpl<BooleanState> implements

    private final DataSaverController mDataSaverController;
    private final DialogLaunchAnimator mDialogLaunchAnimator;
    private final SystemUIDialog.Factory mSystemUIDialogFactory;

    @Inject
    public DataSaverTile(
@@ -68,12 +69,14 @@ public class DataSaverTile extends QSTileImpl<BooleanState> implements
            ActivityStarter activityStarter,
            QSLogger qsLogger,
            DataSaverController dataSaverController,
            DialogLaunchAnimator dialogLaunchAnimator
            DialogLaunchAnimator dialogLaunchAnimator,
            SystemUIDialog.Factory systemUIDialogFactory
    ) {
        super(host, uiEventLogger, backgroundLooper, mainHandler, falsingManager, metricsLogger,
                statusBarStateController, activityStarter, qsLogger);
        mDataSaverController = dataSaverController;
        mDialogLaunchAnimator = dialogLaunchAnimator;
        mSystemUIDialogFactory = systemUIDialogFactory;
        mDataSaverController.observe(getLifecycle(), this);
    }

@@ -98,7 +101,7 @@ public class DataSaverTile extends QSTileImpl<BooleanState> implements
        // Show a dialog to confirm first. Dialogs shown by the DialogLaunchAnimator must be created
        // and shown on the main thread, so we post it to the UI handler.
        mUiHandler.post(() -> {
            SystemUIDialog dialog = new SystemUIDialog(mContext);
            SystemUIDialog dialog = mSystemUIDialogFactory.create();
            dialog.setTitle(com.android.internal.R.string.data_saver_enable_title);
            dialog.setMessage(com.android.internal.R.string.data_saver_description);
            dialog.setPositiveButton(com.android.internal.R.string.data_saver_enable_button,
Loading