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

Commit 556691b2 authored by Michael Mikhail's avatar Michael Mikhail
Browse files

Add setting for volume dialog timeout

Bug: 294408608
Test: atest VolumeDialogImplTest
Change-Id: Ia7a091974be5fea2609ad8ae82fc308ffa5b0e7a
parent 2c24ddf1
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -11091,6 +11091,12 @@ public final class Settings {
        @Readable
        public static final String BLUETOOTH_ON_WHILE_DRIVING = "bluetooth_on_while_driving";
        /**
         * Volume dialog timeout in ms.
         * @hide
         */
        public static final String VOLUME_DIALOG_DISMISS_TIMEOUT = "volume_dialog_dismiss_timeout";
        /**
         * What behavior should be invoked when the volume hush gesture is triggered
         * One of VOLUME_HUSH_OFF, VOLUME_HUSH_VIBRATE, VOLUME_HUSH_MUTE.
+1 −0
Original line number Diff line number Diff line
@@ -143,6 +143,7 @@ public class SecureSettings {
        Settings.Secure.SCREENSAVER_ACTIVATE_ON_SLEEP,
        Settings.Secure.SCREENSAVER_HOME_CONTROLS_ENABLED,
        Settings.Secure.SHOW_FIRST_CRASH_DIALOG_DEV_OPTION,
        Settings.Secure.VOLUME_DIALOG_DISMISS_TIMEOUT,
        Settings.Secure.VOLUME_HUSH_GESTURE,
        Settings.Secure.MANUAL_RINGER_TOGGLE_COUNT,
        Settings.Secure.LOW_POWER_WARNING_ACKNOWLEDGED,
+1 −0
Original line number Diff line number Diff line
@@ -212,6 +212,7 @@ public class SecureSettingsValidators {
        VALIDATORS.put(Secure.SCREENSAVER_ACTIVATE_ON_SLEEP, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.SCREENSAVER_HOME_CONTROLS_ENABLED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.SHOW_FIRST_CRASH_DIALOG_DEV_OPTION, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.VOLUME_DIALOG_DISMISS_TIMEOUT, NON_NEGATIVE_INTEGER_VALIDATOR);
        VALIDATORS.put(Secure.VOLUME_HUSH_GESTURE, NON_NEGATIVE_INTEGER_VALIDATOR);
        VALIDATORS.put(
                Secure.ENABLED_NOTIFICATION_LISTENERS,
+11 −3
Original line number Diff line number Diff line
@@ -135,6 +135,7 @@ import com.android.systemui.statusbar.policy.DevicePostureController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.util.AlphaTintDrawableWrapper;
import com.android.systemui.util.RoundedCornerProgressDrawable;
import com.android.systemui.util.settings.SecureSettings;

import java.io.PrintWriter;
import java.util.ArrayList;
@@ -304,6 +305,8 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
    private @DevicePostureController.DevicePostureInt int mDevicePosture;
    private int mOrientation;
    private final FeatureFlags mFeatureFlags;
    private final SecureSettings mSecureSettings;
    private int mDialogTimeoutMillis;

    public VolumeDialogImpl(
            Context context,
@@ -320,7 +323,8 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
            DevicePostureController devicePostureController,
            Looper looper,
            DumpManager dumpManager,
            FeatureFlags featureFlags) {
            FeatureFlags featureFlags,
            SecureSettings secureSettings) {
        mFeatureFlags = featureFlags;
        mContext =
                new ContextThemeWrapper(context, R.style.volume_dialog_theme);
@@ -351,6 +355,8 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
        mUseBackgroundBlur =
            mContext.getResources().getBoolean(R.bool.config_volumeDialogUseBackgroundBlur);
        mInteractionJankMonitor = interactionJankMonitor;
        mSecureSettings = secureSettings;
        mDialogTimeoutMillis = DIALOG_TIMEOUT_MILLIS;

        dumpManager.registerDumpable("VolumeDialogImpl", this);

@@ -515,6 +521,8 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
        mDialog.setContentView(R.layout.volume_dialog);
        mDialogView = mDialog.findViewById(R.id.volume_dialog);
        mDialogView.setAlpha(0);
        mDialogTimeoutMillis = mSecureSettings.getInt(Settings.Secure.VOLUME_DIALOG_DISMISS_TIMEOUT,
                DIALOG_TIMEOUT_MILLIS);
        mDialog.setCanceledOnTouchOutside(true);
        mDialog.setOnShowListener(dialog -> {
            mDialogView.getViewTreeObserver().addOnComputeInternalInsetsListener(this);
@@ -527,7 +535,7 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
                    .alpha(1)
                    .translationX(0)
                    .setDuration(mDialogShowAnimationDurationMs)
                    .setListener(getJankListener(getDialogView(), TYPE_SHOW, DIALOG_TIMEOUT_MILLIS))
                    .setListener(getJankListener(getDialogView(), TYPE_SHOW, mDialogTimeoutMillis))
                    .setInterpolator(new SystemUIInterpolators.LogDecelerateInterpolator())
                    .withEndAction(() -> {
                        if (!Prefs.getBoolean(mContext, Prefs.Key.TOUCHED_RINGER_TOGGLE, false)) {
@@ -1514,7 +1522,7 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
                    AccessibilityManager.FLAG_CONTENT_TEXT
                            | AccessibilityManager.FLAG_CONTENT_CONTROLS);
        }
        return mAccessibilityMgr.getRecommendedTimeoutMillis(DIALOG_TIMEOUT_MILLIS,
        return mAccessibilityMgr.getRecommendedTimeoutMillis(mDialogTimeoutMillis,
                AccessibilityManager.FLAG_CONTENT_CONTROLS);
    }

+5 −2
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.DevicePostureController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.util.settings.SecureSettings;
import com.android.systemui.volume.CsdWarningDialog;
import com.android.systemui.volume.VolumeComponent;
import com.android.systemui.volume.VolumeDialogComponent;
@@ -63,7 +64,8 @@ public interface VolumeModule {
            CsdWarningDialog.Factory csdFactory,
            DevicePostureController devicePostureController,
            DumpManager dumpManager,
            FeatureFlags featureFlags) {
            FeatureFlags featureFlags,
            SecureSettings secureSettings) {
        VolumeDialogImpl impl = new VolumeDialogImpl(
                context,
                volumeDialogController,
@@ -79,7 +81,8 @@ public interface VolumeModule {
                devicePostureController,
                Looper.getMainLooper(),
                dumpManager,
                featureFlags);
                featureFlags,
                secureSettings);
        impl.setStreamImportant(AudioManager.STREAM_SYSTEM, false);
        impl.setAutomute(true);
        impl.setSilentMode(false);
Loading