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

Commit a1d1e118 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add adaptive scale to vibration stats metrics" into main

parents e198cdf6 fbd7063f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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);
+15 −1
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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) {
+7 −3
Original line number Diff line number Diff line
@@ -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();
        }
@@ -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) {