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 Original line Diff line number Diff line
@@ -301,6 +301,9 @@
    <!-- Enable the default volume dialog -->
    <!-- Enable the default volume dialog -->
    <bool name="enable_volume_ui">true</bool>
    <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 -->
    <!-- Whether to show operator name in the status bar -->
    <bool name="config_showOperatorNameInStatusBar">false</bool>
    <bool name="config_showOperatorNameInStatusBar">false</bool>


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


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

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


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


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

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


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


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


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


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


    @Test
    @Test