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

Commit e003666f authored by Luke Song's avatar Luke Song
Browse files

Separate volume ui and safety warning configs

VR headsets want to prevent 2d volume ui from being displayed, but want
to keep the high volume warning dialog.

Bug: 67951608
Bug: 68997348
Test: Tested linearly independent configs
Change-Id: Ic102ce626e199d2e3a3cf8fbb091050977c696bb
parent dfcf9029
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -301,6 +301,9 @@
    <!-- Enable the default volume dialog -->
    <bool name="enable_volume_ui">true</bool>

    <!-- Enable the default volume level warning dialog -->
    <bool name="enable_safety_warning">true</bool>

    <!-- Whether to show operator name in the status bar -->
    <bool name="config_showOperatorNameInStatusBar">false</bool>

+4 −0
Original line number Diff line number Diff line
@@ -134,6 +134,10 @@ public class VolumeDialogComponent implements VolumeComponent, TunerService.Tuna
        mController.setVolumePolicy(mVolumePolicy);
    }

    void setEnableDialogs(boolean volumeUi, boolean safetyWarning) {
        mController.setEnableDialogs(volumeUi, safetyWarning);
    }

    @Override
    public void onUserActivity() {
        final KeyguardViewMediator kvm = mSysui.getComponent(KeyguardViewMediator.class);
+12 −2
Original line number Diff line number Diff line
@@ -103,6 +103,8 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
    private final Vibrator mVibrator;
    private final boolean mHasVibrator;
    private boolean mShowA11yStream;
    private boolean mShowVolumeDialog;
    private boolean mShowSafetyWarning;

    private boolean mDestroyed;
    private VolumePolicy mVolumePolicy;
@@ -282,6 +284,11 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
        mWorker.obtainMessage(W.SET_ACTIVE_STREAM, stream, 0).sendToTarget();
    }

    public void setEnableDialogs(boolean volumeUi, boolean safetyWarning) {
      mShowVolumeDialog = volumeUi;
      mShowSafetyWarning = safetyWarning;
    }

    public void vibrate() {
        if (mHasVibrator) {
            mVibrator.vibrate(VIBRATE_HINT_DURATION);
@@ -311,8 +318,10 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
    }

    private void onShowSafetyWarningW(int flags) {
        if (mShowSafetyWarning) {
            mCallbacks.onShowSafetyWarning(flags);
        }
    }

    private void onAccessibilityModeChanged(Boolean showA11yStream) {
        mCallbacks.onAccessibilityModeChanged(showA11yStream);
@@ -343,7 +352,8 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
                && mStatusBar.getWakefulnessState() != WakefulnessLifecycle.WAKEFULNESS_ASLEEP
                && mStatusBar.getWakefulnessState() != WakefulnessLifecycle.WAKEFULNESS_GOING_TO_SLEEP
                && mStatusBar.isDeviceInteractive()
                && (flags & AudioManager.FLAG_SHOW_UI) != 0;
                && (flags & AudioManager.FLAG_SHOW_UI) != 0
                && mShowVolumeDialog;
    }

    boolean onVolumeChangedW(int stream, int flags) {
+5 −1
Original line number Diff line number Diff line
@@ -40,9 +40,13 @@ public class VolumeUI extends SystemUI {

    @Override
    public void start() {
        mEnabled = mContext.getResources().getBoolean(R.bool.enable_volume_ui);
        boolean enableVolumeUi = mContext.getResources().getBoolean(R.bool.enable_volume_ui);
        boolean enableSafetyWarning =
            mContext.getResources().getBoolean(R.bool.enable_safety_warning);
        mEnabled = enableVolumeUi || enableSafetyWarning;
        if (!mEnabled) return;
        mVolumeComponent = new VolumeDialogComponent(this, mContext, null);
        mVolumeComponent.setEnableDialogs(enableVolumeUi, enableSafetyWarning);
        putComponent(VolumeComponent.class, getVolumeComponent());
        setDefaultVolumeController();
    }
+1 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ public class VolumeDialogControllerImplTest extends SysuiTestCase {
        mCallback = mock(VolumeDialogControllerImpl.C.class);
        mStatusBar = mock(StatusBar.class);
        mVolumeController = new TestableVolumeDialogControllerImpl(mContext, mCallback, mStatusBar);
        mVolumeController.setEnableDialogs(true, true);
    }

    @Test