Loading packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java +24 −10 Original line number Diff line number Diff line Loading @@ -173,9 +173,9 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable, private static final String TYPE_DISMISS = "dismiss"; /** Volume dialog slider animation. */ private static final String TYPE_UPDATE = "update"; static final short PROGRESS_HAPTICS_DISABLED = 0; static final short PROGRESS_HAPTICS_EAGER = 1; static final short PROGRESS_HAPTICS_ANIMATED = 2; static final int PROGRESS_HAPTICS_DISABLED = 0; static final int PROGRESS_HAPTICS_EAGER = 1; static final int PROGRESS_HAPTICS_ANIMATED = 2; /** * TODO(b/290612381): remove lingering animations or tolerate them Loading Loading @@ -851,10 +851,7 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable, row.header.setFilters(new InputFilter[] {new InputFilter.LengthFilter(13)}); } row.slider = row.view.findViewById(R.id.volume_row_slider); if (hapticVolumeSlider()) { row.createPlugin(mVibratorHelper, mSystemClock); HapticSliderViewBinder.bind(row.slider, row.mHapticPlugin); } addSliderHapticsToRow(row); row.slider.setOnSeekBarChangeListener(new VolumeSeekBarChangeListener(row)); row.number = row.view.findViewById(R.id.volume_number); Loading Loading @@ -915,6 +912,23 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable, } } private void addSliderHapticsToRow(VolumeRow row) { if (hapticVolumeSlider()) { row.createPlugin(mVibratorHelper, mSystemClock); HapticSliderViewBinder.bind(row.slider, row.mHapticPlugin); } } @VisibleForTesting void addSliderHapticsToRows() { for (VolumeRow row: mRows) { addSliderHapticsToRow(row); } } @VisibleForTesting void removeDismissMessages() { mHandler.removeMessages(H.DISMISS); } private void setRingerMode(int newRingerMode) { Events.writeEvent(Events.EVENT_RINGER_TOGGLE, newRingerMode); incrementManualToggleCount(); Loading Loading @@ -2105,7 +2119,7 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable, } } @VisibleForTesting short progressHapticsForStream(int stream) { @VisibleForTesting int progressHapticsForStream(int stream) { for (VolumeRow row: mRows) { if (row.stream == stream) { return row.mProgressHapticsType; Loading Loading @@ -2619,7 +2633,7 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable, private int animTargetProgress; private int lastAudibleLevel = 1; private SeekableSliderHapticPlugin mHapticPlugin; private short mProgressHapticsType = PROGRESS_HAPTICS_DISABLED; private int mProgressHapticsType = PROGRESS_HAPTICS_DISABLED; void setIcon(int iconRes, Resources.Theme theme) { if (icon != null) { Loading Loading @@ -2661,7 +2675,7 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable, slider.setOnTouchListener(null); } void deliverOnProgressChangedHaptics(boolean fromUser, int progress, short hapticsType) { void deliverOnProgressChangedHaptics(boolean fromUser, int progress, int hapticsType) { if (mHapticPlugin == null) return; mHapticPlugin.onProgressChanged(slider, progress, fromUser); Loading packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogImplTest.java +14 −12 Original line number Diff line number Diff line Loading @@ -95,7 +95,6 @@ import junit.framework.Assert; import org.junit.After; import org.junit.Before; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; Loading Loading @@ -272,50 +271,53 @@ public class VolumeDialogImplTest extends SysuiTestCase { @Test @DisableFlags(FLAG_HAPTIC_VOLUME_SLIDER) public void testVolumeChange_noSliderHaptics_doesNotDeliverOnProgressChangedHaptics() { // Initialize the dialog again with haptic sliders disabled mDialog.init(0, null); final State shellState = createShellState(); VolumeDialogController.StreamState musicStreamState = shellState.states.get(AudioSystem.STREAM_MUSIC); mDialog.show(SHOW_REASON_UNKNOWN); mTestableLooper.processMessages(1); //Only the SHOW message mDialog.removeDismissMessages(); // Temporarily remove the rescheduled DISMISS // Change the volume two times musicStreamState.level += 10; mDialog.onStateChangedH(shellState); mAnimatorTestRule.advanceTimeBy(10); musicStreamState.level += 10; mDialog.onStateChangedH(shellState); // expected: the type of the progress haptics for the stream should be DISABLED short type = mDialog.progressHapticsForStream(AudioSystem.STREAM_MUSIC); // expected: the type of the latest progress haptics for the stream should be DISABLED int type = mDialog.progressHapticsForStream(AudioSystem.STREAM_MUSIC); assertEquals(VolumeDialogImpl.PROGRESS_HAPTICS_DISABLED, type); mDialog.dismiss(DISMISS_REASON_UNKNOWN); // Dismiss mTestableLooper.processAllMessages(); } @Ignore("Causing breakages so ignoring to resolve, b/329099861") @Test @EnableFlags(FLAG_HAPTIC_VOLUME_SLIDER) public void testVolumeChange_withSliderHaptics_deliversOnProgressChangedHapticsEagerly() { // Initialize the dialog again to create haptic plugins on the rows with the flag enabled mDialog.init(0, null); // create haptic plugins on the rows with the flag enabled mDialog.addSliderHapticsToRows(); final State shellState = createShellState(); VolumeDialogController.StreamState musicStreamState = shellState.states.get(AudioSystem.STREAM_MUSIC); mDialog.show(SHOW_REASON_UNKNOWN); mTestableLooper.processMessages(1); //Only the SHOW message mDialog.removeDismissMessages(); // Temporarily remove the rescheduled DISMISS // Change the volume two times musicStreamState.level += 10; mDialog.onStateChangedH(shellState); mAnimatorTestRule.advanceTimeBy(10); musicStreamState.level += 10; mDialog.onStateChangedH(shellState); // expected: the type of the progress haptics for the stream should be EAGER short type = mDialog.progressHapticsForStream(AudioSystem.STREAM_MUSIC); // expected: the type of the latest progress haptics for the stream should be EAGER int type = mDialog.progressHapticsForStream(AudioSystem.STREAM_MUSIC); assertEquals(VolumeDialogImpl.PROGRESS_HAPTICS_EAGER, type); mDialog.dismiss(DISMISS_REASON_UNKNOWN); // Dismiss mTestableLooper.processAllMessages(); } @Test Loading Loading
packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java +24 −10 Original line number Diff line number Diff line Loading @@ -173,9 +173,9 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable, private static final String TYPE_DISMISS = "dismiss"; /** Volume dialog slider animation. */ private static final String TYPE_UPDATE = "update"; static final short PROGRESS_HAPTICS_DISABLED = 0; static final short PROGRESS_HAPTICS_EAGER = 1; static final short PROGRESS_HAPTICS_ANIMATED = 2; static final int PROGRESS_HAPTICS_DISABLED = 0; static final int PROGRESS_HAPTICS_EAGER = 1; static final int PROGRESS_HAPTICS_ANIMATED = 2; /** * TODO(b/290612381): remove lingering animations or tolerate them Loading Loading @@ -851,10 +851,7 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable, row.header.setFilters(new InputFilter[] {new InputFilter.LengthFilter(13)}); } row.slider = row.view.findViewById(R.id.volume_row_slider); if (hapticVolumeSlider()) { row.createPlugin(mVibratorHelper, mSystemClock); HapticSliderViewBinder.bind(row.slider, row.mHapticPlugin); } addSliderHapticsToRow(row); row.slider.setOnSeekBarChangeListener(new VolumeSeekBarChangeListener(row)); row.number = row.view.findViewById(R.id.volume_number); Loading Loading @@ -915,6 +912,23 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable, } } private void addSliderHapticsToRow(VolumeRow row) { if (hapticVolumeSlider()) { row.createPlugin(mVibratorHelper, mSystemClock); HapticSliderViewBinder.bind(row.slider, row.mHapticPlugin); } } @VisibleForTesting void addSliderHapticsToRows() { for (VolumeRow row: mRows) { addSliderHapticsToRow(row); } } @VisibleForTesting void removeDismissMessages() { mHandler.removeMessages(H.DISMISS); } private void setRingerMode(int newRingerMode) { Events.writeEvent(Events.EVENT_RINGER_TOGGLE, newRingerMode); incrementManualToggleCount(); Loading Loading @@ -2105,7 +2119,7 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable, } } @VisibleForTesting short progressHapticsForStream(int stream) { @VisibleForTesting int progressHapticsForStream(int stream) { for (VolumeRow row: mRows) { if (row.stream == stream) { return row.mProgressHapticsType; Loading Loading @@ -2619,7 +2633,7 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable, private int animTargetProgress; private int lastAudibleLevel = 1; private SeekableSliderHapticPlugin mHapticPlugin; private short mProgressHapticsType = PROGRESS_HAPTICS_DISABLED; private int mProgressHapticsType = PROGRESS_HAPTICS_DISABLED; void setIcon(int iconRes, Resources.Theme theme) { if (icon != null) { Loading Loading @@ -2661,7 +2675,7 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable, slider.setOnTouchListener(null); } void deliverOnProgressChangedHaptics(boolean fromUser, int progress, short hapticsType) { void deliverOnProgressChangedHaptics(boolean fromUser, int progress, int hapticsType) { if (mHapticPlugin == null) return; mHapticPlugin.onProgressChanged(slider, progress, fromUser); Loading
packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogImplTest.java +14 −12 Original line number Diff line number Diff line Loading @@ -95,7 +95,6 @@ import junit.framework.Assert; import org.junit.After; import org.junit.Before; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; Loading Loading @@ -272,50 +271,53 @@ public class VolumeDialogImplTest extends SysuiTestCase { @Test @DisableFlags(FLAG_HAPTIC_VOLUME_SLIDER) public void testVolumeChange_noSliderHaptics_doesNotDeliverOnProgressChangedHaptics() { // Initialize the dialog again with haptic sliders disabled mDialog.init(0, null); final State shellState = createShellState(); VolumeDialogController.StreamState musicStreamState = shellState.states.get(AudioSystem.STREAM_MUSIC); mDialog.show(SHOW_REASON_UNKNOWN); mTestableLooper.processMessages(1); //Only the SHOW message mDialog.removeDismissMessages(); // Temporarily remove the rescheduled DISMISS // Change the volume two times musicStreamState.level += 10; mDialog.onStateChangedH(shellState); mAnimatorTestRule.advanceTimeBy(10); musicStreamState.level += 10; mDialog.onStateChangedH(shellState); // expected: the type of the progress haptics for the stream should be DISABLED short type = mDialog.progressHapticsForStream(AudioSystem.STREAM_MUSIC); // expected: the type of the latest progress haptics for the stream should be DISABLED int type = mDialog.progressHapticsForStream(AudioSystem.STREAM_MUSIC); assertEquals(VolumeDialogImpl.PROGRESS_HAPTICS_DISABLED, type); mDialog.dismiss(DISMISS_REASON_UNKNOWN); // Dismiss mTestableLooper.processAllMessages(); } @Ignore("Causing breakages so ignoring to resolve, b/329099861") @Test @EnableFlags(FLAG_HAPTIC_VOLUME_SLIDER) public void testVolumeChange_withSliderHaptics_deliversOnProgressChangedHapticsEagerly() { // Initialize the dialog again to create haptic plugins on the rows with the flag enabled mDialog.init(0, null); // create haptic plugins on the rows with the flag enabled mDialog.addSliderHapticsToRows(); final State shellState = createShellState(); VolumeDialogController.StreamState musicStreamState = shellState.states.get(AudioSystem.STREAM_MUSIC); mDialog.show(SHOW_REASON_UNKNOWN); mTestableLooper.processMessages(1); //Only the SHOW message mDialog.removeDismissMessages(); // Temporarily remove the rescheduled DISMISS // Change the volume two times musicStreamState.level += 10; mDialog.onStateChangedH(shellState); mAnimatorTestRule.advanceTimeBy(10); musicStreamState.level += 10; mDialog.onStateChangedH(shellState); // expected: the type of the progress haptics for the stream should be EAGER short type = mDialog.progressHapticsForStream(AudioSystem.STREAM_MUSIC); // expected: the type of the latest progress haptics for the stream should be EAGER int type = mDialog.progressHapticsForStream(AudioSystem.STREAM_MUSIC); assertEquals(VolumeDialogImpl.PROGRESS_HAPTICS_EAGER, type); mDialog.dismiss(DISMISS_REASON_UNKNOWN); // Dismiss mTestableLooper.processAllMessages(); } @Test Loading