Loading services/core/java/com/android/server/vibrator/HalVibration.java +1 −0 Original line number Diff line number Diff line Loading @@ -133,6 +133,7 @@ final class HalVibration extends Vibration { // Save scale values for debugging purposes. mScaleLevel = scaler.getScaleLevel(vibrationUsage); mAdaptiveScale = scaler.getAdaptiveHapticsScale(vibrationUsage); stats.reportAdaptiveScale(mAdaptiveScale); // Scale all VibrationEffect instances in given CombinedVibration. CombinedVibration newEffect = mEffectToPlay.transform(scaler::scale, vibrationUsage); Loading services/core/java/com/android/server/vibrator/VibrationStats.java +15 −1 Original line number Diff line number Diff line Loading @@ -61,6 +61,10 @@ final class VibrationStats { private int mEndedByUsage; private int mInterruptedUsage; // Vibration parameters. // Set by VibrationThread only (single-threaded). private float mAdaptiveScale; // All following counters are set by VibrationThread only (single-threaded): // Counts how many times the VibrationEffect was repeated. private int mRepeatCount; Loading Loading @@ -188,6 +192,14 @@ final class VibrationStats { } } /** Report the adaptive scale that was applied to this vibration. */ void reportAdaptiveScale(float scale) { // Only report adaptive scale if it was set for this vibration. if (Float.compare(scale, VibrationScaler.ADAPTIVE_SCALE_NONE) != 0) { mAdaptiveScale = scale; } } /** Report the vibration has looped a few more times. */ void reportRepetition(int loops) { mRepeatCount += loops; Loading Loading @@ -287,6 +299,7 @@ final class VibrationStats { public final int vibrationType; public final int usage; public final int status; public final float adaptiveScale; public final boolean endedBySameUid; public final int endedByUsage; public final int interruptedUsage; Loading Loading @@ -316,6 +329,7 @@ final class VibrationStats { this.vibrationType = vibrationType; this.usage = usage; this.status = status.getProtoEnumValue(); this.adaptiveScale = stats.mAdaptiveScale; endedBySameUid = (uid == stats.mEndedByUid); endedByUsage = stats.mEndedByUsage; interruptedUsage = stats.mInterruptedUsage; Loading Loading @@ -376,7 +390,7 @@ final class VibrationStats { halOnCount, halOffCount, halPerformCount, halSetAmplitudeCount, halSetExternalControlCount, halSupportedCompositionPrimitivesUsed, halSupportedEffectsUsed, halUnsupportedCompositionPrimitivesUsed, halUnsupportedEffectsUsed, halCompositionSize, halPwleSize); halUnsupportedEffectsUsed, halCompositionSize, halPwleSize, adaptiveScale); } private static int[] filteredKeys(SparseBooleanArray supportArray, boolean supported) { Loading services/core/java/com/android/server/vibrator/VibratorManagerService.java +7 −3 Original line number Diff line number Diff line Loading @@ -1628,6 +1628,12 @@ public class VibratorManagerService extends IVibratorManagerService.Stub { mStatus = Vibration.Status.RUNNING; } public void scale(VibrationScaler scaler, int usage) { scale.scaleLevel = scaler.getScaleLevel(usage); scale.adaptiveHapticsScale = scaler.getAdaptiveHapticsScale(usage); stats.reportAdaptiveScale(scale.adaptiveHapticsScale); } public void mute() { externalVibration.mute(); } Loading Loading @@ -2044,9 +2050,7 @@ public class VibratorManagerService extends IVibratorManagerService.Stub { mCurrentExternalVibration = vibHolder; vibHolder.linkToDeath(); vibHolder.scale.scaleLevel = mVibrationScaler.getScaleLevel(attrs.getUsage()); vibHolder.scale.adaptiveHapticsScale = mVibrationScaler.getAdaptiveHapticsScale(attrs.getUsage()); vibHolder.scale(mVibrationScaler, attrs.getUsage()); } if (waitForCompletion) { Loading Loading
services/core/java/com/android/server/vibrator/HalVibration.java +1 −0 Original line number Diff line number Diff line Loading @@ -133,6 +133,7 @@ final class HalVibration extends Vibration { // Save scale values for debugging purposes. mScaleLevel = scaler.getScaleLevel(vibrationUsage); mAdaptiveScale = scaler.getAdaptiveHapticsScale(vibrationUsage); stats.reportAdaptiveScale(mAdaptiveScale); // Scale all VibrationEffect instances in given CombinedVibration. CombinedVibration newEffect = mEffectToPlay.transform(scaler::scale, vibrationUsage); Loading
services/core/java/com/android/server/vibrator/VibrationStats.java +15 −1 Original line number Diff line number Diff line Loading @@ -61,6 +61,10 @@ final class VibrationStats { private int mEndedByUsage; private int mInterruptedUsage; // Vibration parameters. // Set by VibrationThread only (single-threaded). private float mAdaptiveScale; // All following counters are set by VibrationThread only (single-threaded): // Counts how many times the VibrationEffect was repeated. private int mRepeatCount; Loading Loading @@ -188,6 +192,14 @@ final class VibrationStats { } } /** Report the adaptive scale that was applied to this vibration. */ void reportAdaptiveScale(float scale) { // Only report adaptive scale if it was set for this vibration. if (Float.compare(scale, VibrationScaler.ADAPTIVE_SCALE_NONE) != 0) { mAdaptiveScale = scale; } } /** Report the vibration has looped a few more times. */ void reportRepetition(int loops) { mRepeatCount += loops; Loading Loading @@ -287,6 +299,7 @@ final class VibrationStats { public final int vibrationType; public final int usage; public final int status; public final float adaptiveScale; public final boolean endedBySameUid; public final int endedByUsage; public final int interruptedUsage; Loading Loading @@ -316,6 +329,7 @@ final class VibrationStats { this.vibrationType = vibrationType; this.usage = usage; this.status = status.getProtoEnumValue(); this.adaptiveScale = stats.mAdaptiveScale; endedBySameUid = (uid == stats.mEndedByUid); endedByUsage = stats.mEndedByUsage; interruptedUsage = stats.mInterruptedUsage; Loading Loading @@ -376,7 +390,7 @@ final class VibrationStats { halOnCount, halOffCount, halPerformCount, halSetAmplitudeCount, halSetExternalControlCount, halSupportedCompositionPrimitivesUsed, halSupportedEffectsUsed, halUnsupportedCompositionPrimitivesUsed, halUnsupportedEffectsUsed, halCompositionSize, halPwleSize); halUnsupportedEffectsUsed, halCompositionSize, halPwleSize, adaptiveScale); } private static int[] filteredKeys(SparseBooleanArray supportArray, boolean supported) { Loading
services/core/java/com/android/server/vibrator/VibratorManagerService.java +7 −3 Original line number Diff line number Diff line Loading @@ -1628,6 +1628,12 @@ public class VibratorManagerService extends IVibratorManagerService.Stub { mStatus = Vibration.Status.RUNNING; } public void scale(VibrationScaler scaler, int usage) { scale.scaleLevel = scaler.getScaleLevel(usage); scale.adaptiveHapticsScale = scaler.getAdaptiveHapticsScale(usage); stats.reportAdaptiveScale(scale.adaptiveHapticsScale); } public void mute() { externalVibration.mute(); } Loading Loading @@ -2044,9 +2050,7 @@ public class VibratorManagerService extends IVibratorManagerService.Stub { mCurrentExternalVibration = vibHolder; vibHolder.linkToDeath(); vibHolder.scale.scaleLevel = mVibrationScaler.getScaleLevel(attrs.getUsage()); vibHolder.scale.adaptiveHapticsScale = mVibrationScaler.getAdaptiveHapticsScale(attrs.getUsage()); vibHolder.scale(mVibrationScaler, attrs.getUsage()); } if (waitForCompletion) { Loading