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

Commit e9fd98ab authored by Luke Song's avatar Luke Song Committed by Android (Google) Code Review
Browse files

Merge "Separate volume ui and safety warning configs"

parents 2ff754c1 e003666f
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