Loading core/java/android/os/vibrator/flags.aconfig +0 −10 Original line number Diff line number Diff line Loading @@ -110,16 +110,6 @@ flag { } } flag { namespace: "haptics" name: "vibration_thread_handling_hal_failure" description: "Fixes how VibrationThread handled HAL failures" bug: "419572960" metadata { purpose: PURPOSE_BUGFIX } } flag { namespace: "haptics" name: "vibration_scale_device_config_enabled" Loading services/core/java/com/android/server/vibrator/AbstractComposedVibratorStep.java +6 −20 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.server.vibrator; import android.os.SystemClock; import android.os.VibrationEffect; import android.os.vibrator.Flags; import java.util.List; Loading Loading @@ -54,10 +53,7 @@ abstract class AbstractComposedVibratorStep extends AbstractVibratorStep { * current segment from the effect. */ protected List<Step> skipStep() { return Flags.vibrationThreadHandlingHalFailure() ? skipStep(SystemClock.uptimeMillis()) // Preserve old behavior when fix is not enabled. : vibratorOnNextSteps(/* segmentsPlayed= */ 1); return skipStep(SystemClock.uptimeMillis()); } /** Loading @@ -77,7 +73,6 @@ abstract class AbstractComposedVibratorStep extends AbstractVibratorStep { * and it will cancel the playback if the HAL result is unsupported or failure. */ protected List<Step> vibratorOnNextSteps(int segmentsPlayed) { if (Flags.vibrationThreadHandlingHalFailure()) { if (mVibratorOnResult > 0) { // Vibrator was turned on by this step, with mVibratorOnResult as the duration. // Schedule next steps for right after the vibration finishes. Loading @@ -88,15 +83,6 @@ abstract class AbstractComposedVibratorStep extends AbstractVibratorStep { return cancelStep(); } } // Schedule next steps to run right away. long nextStartTime = SystemClock.uptimeMillis(); if (mVibratorOnResult > 0) { // Vibrator was turned on by this step, with mVibratorOnResult as the duration. // Schedule next steps for right after the vibration finishes. nextStartTime += mVibratorOnResult; } return nextSteps(nextStartTime, segmentsPlayed); } /** * Return the {@link VibrationStepConductor#nextVibrateStep} with given start time, Loading services/core/java/com/android/server/vibrator/SetAmplitudeVibratorStep.java +2 −3 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import android.annotation.NonNull; import android.os.SystemClock; import android.os.Trace; import android.os.VibrationEffect; import android.os.vibrator.Flags; import android.os.vibrator.StepSegment; import android.os.vibrator.VibrationEffectSegment; import android.util.Slog; Loading Loading @@ -95,7 +94,7 @@ final class SetAmplitudeVibratorStep extends AbstractComposedVibratorStep { long onDuration = getVibratorOnDuration(effect, segmentIndex); if (onDuration > 0) { long vibratorOnResult = startVibrating(onDuration, amplitude); if (Flags.vibrationThreadHandlingHalFailure() && vibratorOnResult <= 0) { if (vibratorOnResult <= 0) { // Error turning vibrator ON, cancel the waveform playback. return cancelStep(); } Loading Loading @@ -125,7 +124,7 @@ final class SetAmplitudeVibratorStep extends AbstractComposedVibratorStep { float expectedAmplitude = vibrator.getCurrentAmplitude(); long vibratorOnResult = startVibrating(onDuration, expectedAmplitude); if (Flags.vibrationThreadHandlingHalFailure() && vibratorOnResult <= 0) { if (vibratorOnResult <= 0) { // Error turning vibrator back ON, cancel the waveform playback. return cancelStep(); } Loading services/core/java/com/android/server/vibrator/VibrationStepConductor.java +9 −19 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import android.annotation.Nullable; import android.os.Build; import android.os.CombinedVibration; import android.os.VibrationEffect; import android.os.vibrator.Flags; import android.os.vibrator.PrebakedSegment; import android.os.vibrator.PrimitiveSegment; import android.os.vibrator.PwleSegment; Loading Loading @@ -255,7 +254,6 @@ final class VibrationStepConductor { // Vibration still running. return null; } if (Flags.vibrationThreadHandlingHalFailure()) { if (mFailedVibratorOnSteps > 0) { // Some steps failed to dispatch vibration to the vibrator HAL. return new Vibration.EndInfo(Status.IGNORED_ERROR_DISPATCHING); Loading @@ -266,14 +264,6 @@ final class VibrationStepConductor { } // No step was successful or failed, nothing played. return new Vibration.EndInfo(Status.IGNORED_UNSUPPORTED); } else { // No pending steps, and something happened. if (mSuccessfulVibratorOnSteps > 0) { return new Vibration.EndInfo(Status.FINISHED); } // If no step was able to turn the vibrator ON successfully. return new Vibration.EndInfo(Status.IGNORED_UNSUPPORTED); } } /** Loading services/tests/vibrator/src/com/android/server/vibrator/VibrationThreadTest.java +2 −12 Original line number Diff line number Diff line Loading @@ -222,7 +222,6 @@ public class VibrationThreadTest { } @Test @EnableFlags(Flags.FLAG_VIBRATION_THREAD_HANDLING_HAL_FAILURE) public void vibrate_singleVibratorOneShotFailed_doesNotSetAmplitudeAndReturnsFailure() { HalVibratorHelper vibratorHelper = mVibratorHelpers.get(VIBRATOR_ID); vibratorHelper.setCapabilities(IVibrator.CAP_AMPLITUDE_CONTROL); Loading Loading @@ -280,7 +279,6 @@ public class VibrationThreadTest { } @Test @EnableFlags(Flags.FLAG_VIBRATION_THREAD_HANDLING_HAL_FAILURE) public void vibrate_singleVibratorWaveformFailed_stopsVibrationAfterFailure() { HalVibratorHelper vibratorHelper = mVibratorHelpers.get(VIBRATOR_ID); vibratorHelper.setCapabilities(IVibrator.CAP_AMPLITUDE_CONTROL); Loading Loading @@ -830,10 +828,7 @@ public class VibrationThreadTest { } @Test @EnableFlags({ Flags.FLAG_VENDOR_VIBRATION_EFFECTS, Flags.FLAG_VIBRATION_THREAD_HANDLING_HAL_FAILURE, }) @EnableFlags(Flags.FLAG_VENDOR_VIBRATION_EFFECTS) public void vibrate_singleVibratorVendorEffectFailed_returnsFailure() { HalVibratorHelper vibratorHelper = mVibratorHelpers.get(VIBRATOR_ID); vibratorHelper.setCapabilities(IVibrator.CAP_PERFORM_VENDOR_EFFECTS); Loading Loading @@ -912,7 +907,6 @@ public class VibrationThreadTest { } @Test @EnableFlags(Flags.FLAG_VIBRATION_THREAD_HANDLING_HAL_FAILURE) public void vibrate_singleVibratorComposedFailed_returnsFailureAndStopsVibration() { HalVibratorHelper vibratorHelper = mVibratorHelpers.get(VIBRATOR_ID); vibratorHelper.setCapabilities(IVibrator.CAP_COMPOSE_EFFECTS); Loading Loading @@ -1246,10 +1240,7 @@ public class VibrationThreadTest { } @Test @EnableFlags({ Flags.FLAG_NORMALIZED_PWLE_EFFECTS, Flags.FLAG_VIBRATION_THREAD_HANDLING_HAL_FAILURE, }) @EnableFlags(Flags.FLAG_NORMALIZED_PWLE_EFFECTS) public void vibrate_singleVibratorPwleFailed_returnsFailureAndStopsVibration() { HalVibratorHelper vibratorHelper = mVibratorHelpers.get(VIBRATOR_ID); vibratorHelper.setCapabilities(IVibrator.CAP_GET_RESONANT_FREQUENCY, Loading Loading @@ -1671,7 +1662,6 @@ public class VibrationThreadTest { } @Test @EnableFlags(Flags.FLAG_VIBRATION_THREAD_HANDLING_HAL_FAILURE) public void vibrate_multipleSyncedOneVibratorFails_returnsFailureAndStopsVibration() { int[] vibratorIds = new int[]{1, 2}; mockVibrators(vibratorIds); Loading Loading
core/java/android/os/vibrator/flags.aconfig +0 −10 Original line number Diff line number Diff line Loading @@ -110,16 +110,6 @@ flag { } } flag { namespace: "haptics" name: "vibration_thread_handling_hal_failure" description: "Fixes how VibrationThread handled HAL failures" bug: "419572960" metadata { purpose: PURPOSE_BUGFIX } } flag { namespace: "haptics" name: "vibration_scale_device_config_enabled" Loading
services/core/java/com/android/server/vibrator/AbstractComposedVibratorStep.java +6 −20 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.server.vibrator; import android.os.SystemClock; import android.os.VibrationEffect; import android.os.vibrator.Flags; import java.util.List; Loading Loading @@ -54,10 +53,7 @@ abstract class AbstractComposedVibratorStep extends AbstractVibratorStep { * current segment from the effect. */ protected List<Step> skipStep() { return Flags.vibrationThreadHandlingHalFailure() ? skipStep(SystemClock.uptimeMillis()) // Preserve old behavior when fix is not enabled. : vibratorOnNextSteps(/* segmentsPlayed= */ 1); return skipStep(SystemClock.uptimeMillis()); } /** Loading @@ -77,7 +73,6 @@ abstract class AbstractComposedVibratorStep extends AbstractVibratorStep { * and it will cancel the playback if the HAL result is unsupported or failure. */ protected List<Step> vibratorOnNextSteps(int segmentsPlayed) { if (Flags.vibrationThreadHandlingHalFailure()) { if (mVibratorOnResult > 0) { // Vibrator was turned on by this step, with mVibratorOnResult as the duration. // Schedule next steps for right after the vibration finishes. Loading @@ -88,15 +83,6 @@ abstract class AbstractComposedVibratorStep extends AbstractVibratorStep { return cancelStep(); } } // Schedule next steps to run right away. long nextStartTime = SystemClock.uptimeMillis(); if (mVibratorOnResult > 0) { // Vibrator was turned on by this step, with mVibratorOnResult as the duration. // Schedule next steps for right after the vibration finishes. nextStartTime += mVibratorOnResult; } return nextSteps(nextStartTime, segmentsPlayed); } /** * Return the {@link VibrationStepConductor#nextVibrateStep} with given start time, Loading
services/core/java/com/android/server/vibrator/SetAmplitudeVibratorStep.java +2 −3 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import android.annotation.NonNull; import android.os.SystemClock; import android.os.Trace; import android.os.VibrationEffect; import android.os.vibrator.Flags; import android.os.vibrator.StepSegment; import android.os.vibrator.VibrationEffectSegment; import android.util.Slog; Loading Loading @@ -95,7 +94,7 @@ final class SetAmplitudeVibratorStep extends AbstractComposedVibratorStep { long onDuration = getVibratorOnDuration(effect, segmentIndex); if (onDuration > 0) { long vibratorOnResult = startVibrating(onDuration, amplitude); if (Flags.vibrationThreadHandlingHalFailure() && vibratorOnResult <= 0) { if (vibratorOnResult <= 0) { // Error turning vibrator ON, cancel the waveform playback. return cancelStep(); } Loading Loading @@ -125,7 +124,7 @@ final class SetAmplitudeVibratorStep extends AbstractComposedVibratorStep { float expectedAmplitude = vibrator.getCurrentAmplitude(); long vibratorOnResult = startVibrating(onDuration, expectedAmplitude); if (Flags.vibrationThreadHandlingHalFailure() && vibratorOnResult <= 0) { if (vibratorOnResult <= 0) { // Error turning vibrator back ON, cancel the waveform playback. return cancelStep(); } Loading
services/core/java/com/android/server/vibrator/VibrationStepConductor.java +9 −19 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import android.annotation.Nullable; import android.os.Build; import android.os.CombinedVibration; import android.os.VibrationEffect; import android.os.vibrator.Flags; import android.os.vibrator.PrebakedSegment; import android.os.vibrator.PrimitiveSegment; import android.os.vibrator.PwleSegment; Loading Loading @@ -255,7 +254,6 @@ final class VibrationStepConductor { // Vibration still running. return null; } if (Flags.vibrationThreadHandlingHalFailure()) { if (mFailedVibratorOnSteps > 0) { // Some steps failed to dispatch vibration to the vibrator HAL. return new Vibration.EndInfo(Status.IGNORED_ERROR_DISPATCHING); Loading @@ -266,14 +264,6 @@ final class VibrationStepConductor { } // No step was successful or failed, nothing played. return new Vibration.EndInfo(Status.IGNORED_UNSUPPORTED); } else { // No pending steps, and something happened. if (mSuccessfulVibratorOnSteps > 0) { return new Vibration.EndInfo(Status.FINISHED); } // If no step was able to turn the vibrator ON successfully. return new Vibration.EndInfo(Status.IGNORED_UNSUPPORTED); } } /** Loading
services/tests/vibrator/src/com/android/server/vibrator/VibrationThreadTest.java +2 −12 Original line number Diff line number Diff line Loading @@ -222,7 +222,6 @@ public class VibrationThreadTest { } @Test @EnableFlags(Flags.FLAG_VIBRATION_THREAD_HANDLING_HAL_FAILURE) public void vibrate_singleVibratorOneShotFailed_doesNotSetAmplitudeAndReturnsFailure() { HalVibratorHelper vibratorHelper = mVibratorHelpers.get(VIBRATOR_ID); vibratorHelper.setCapabilities(IVibrator.CAP_AMPLITUDE_CONTROL); Loading Loading @@ -280,7 +279,6 @@ public class VibrationThreadTest { } @Test @EnableFlags(Flags.FLAG_VIBRATION_THREAD_HANDLING_HAL_FAILURE) public void vibrate_singleVibratorWaveformFailed_stopsVibrationAfterFailure() { HalVibratorHelper vibratorHelper = mVibratorHelpers.get(VIBRATOR_ID); vibratorHelper.setCapabilities(IVibrator.CAP_AMPLITUDE_CONTROL); Loading Loading @@ -830,10 +828,7 @@ public class VibrationThreadTest { } @Test @EnableFlags({ Flags.FLAG_VENDOR_VIBRATION_EFFECTS, Flags.FLAG_VIBRATION_THREAD_HANDLING_HAL_FAILURE, }) @EnableFlags(Flags.FLAG_VENDOR_VIBRATION_EFFECTS) public void vibrate_singleVibratorVendorEffectFailed_returnsFailure() { HalVibratorHelper vibratorHelper = mVibratorHelpers.get(VIBRATOR_ID); vibratorHelper.setCapabilities(IVibrator.CAP_PERFORM_VENDOR_EFFECTS); Loading Loading @@ -912,7 +907,6 @@ public class VibrationThreadTest { } @Test @EnableFlags(Flags.FLAG_VIBRATION_THREAD_HANDLING_HAL_FAILURE) public void vibrate_singleVibratorComposedFailed_returnsFailureAndStopsVibration() { HalVibratorHelper vibratorHelper = mVibratorHelpers.get(VIBRATOR_ID); vibratorHelper.setCapabilities(IVibrator.CAP_COMPOSE_EFFECTS); Loading Loading @@ -1246,10 +1240,7 @@ public class VibrationThreadTest { } @Test @EnableFlags({ Flags.FLAG_NORMALIZED_PWLE_EFFECTS, Flags.FLAG_VIBRATION_THREAD_HANDLING_HAL_FAILURE, }) @EnableFlags(Flags.FLAG_NORMALIZED_PWLE_EFFECTS) public void vibrate_singleVibratorPwleFailed_returnsFailureAndStopsVibration() { HalVibratorHelper vibratorHelper = mVibratorHelpers.get(VIBRATOR_ID); vibratorHelper.setCapabilities(IVibrator.CAP_GET_RESONANT_FREQUENCY, Loading Loading @@ -1671,7 +1662,6 @@ public class VibrationThreadTest { } @Test @EnableFlags(Flags.FLAG_VIBRATION_THREAD_HANDLING_HAL_FAILURE) public void vibrate_multipleSyncedOneVibratorFails_returnsFailureAndStopsVibration() { int[] vibratorIds = new int[]{1, 2}; mockVibrators(vibratorIds); Loading