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

Commit 00487cf9 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Also log the value of the IAEs thrown in VibrationEffect" into oc-dev

parents 2880a4b4 0ef6edd0
Loading
Loading
Loading
Loading
+17 −8
Original line number Original line Diff line number Diff line
@@ -189,10 +189,11 @@ public abstract class VibrationEffect implements Parcelable {
            if (mAmplitude < -1 || mAmplitude == 0 || mAmplitude > 255) {
            if (mAmplitude < -1 || mAmplitude == 0 || mAmplitude > 255) {
                throw new IllegalArgumentException(
                throw new IllegalArgumentException(
                        "amplitude must either be DEFAULT_AMPLITUDE, " +
                        "amplitude must either be DEFAULT_AMPLITUDE, " +
                        "or between 1 and 255 inclusive");
                        "or between 1 and 255 inclusive (amplitude=" + mAmplitude + ")");
            }
            }
            if (mTiming <= 0) {
            if (mTiming <= 0) {
                throw new IllegalArgumentException("timing must be positive");
                throw new IllegalArgumentException(
                        "timing must be positive (timing=" + mTiming + ")");
            }
            }
        }
        }


@@ -274,24 +275,31 @@ public abstract class VibrationEffect implements Parcelable {
        public void validate() {
        public void validate() {
            if (mTimings.length != mAmplitudes.length) {
            if (mTimings.length != mAmplitudes.length) {
                throw new IllegalArgumentException(
                throw new IllegalArgumentException(
                        "timing and amplitude arrays must be of equal length");
                        "timing and amplitude arrays must be of equal length" +
                        " (timings.length=" + mTimings.length +
                        ", amplitudes.length=" + mAmplitudes.length + ")");
            }
            }
            if (!hasNonZeroEntry(mTimings)) {
            if (!hasNonZeroEntry(mTimings)) {
                throw new IllegalArgumentException("at least one timing must be non-zero");
                throw new IllegalArgumentException("at least one timing must be non-zero" +
                        " (timings=" + Arrays.toString(mTimings) + ")");
            }
            }
            for (long timing : mTimings) {
            for (long timing : mTimings) {
                if (timing < 0) {
                if (timing < 0) {
                    throw new IllegalArgumentException("timings must all be >= 0");
                    throw new IllegalArgumentException("timings must all be >= 0" +
                            " (timings=" + Arrays.toString(mTimings) + ")");
                }
                }
            }
            }
            for (int amplitude : mAmplitudes) {
            for (int amplitude : mAmplitudes) {
                if (amplitude < -1 || amplitude > 255) {
                if (amplitude < -1 || amplitude > 255) {
                    throw new IllegalArgumentException(
                    throw new IllegalArgumentException(
                            "amplitudes must all be DEFAULT_AMPLITUDE or between 0 and 255");
                            "amplitudes must all be DEFAULT_AMPLITUDE or between 0 and 255" +
                            " (amplitudes=" + Arrays.toString(mAmplitudes) + ")");
                }
                }
            }
            }
            if (mRepeat < -1 || mRepeat >= mTimings.length) {
            if (mRepeat < -1 || mRepeat >= mTimings.length) {
                throw new IllegalArgumentException("repeat index must be >= -1");
                throw new IllegalArgumentException(
                        "repeat index must be within the bounds of the timings array" +
                        " (timings.length=" + mTimings.length + ", index=" + mRepeat +")");
            }
            }
        }
        }


@@ -375,7 +383,8 @@ public abstract class VibrationEffect implements Parcelable {
        @Override
        @Override
        public void validate() {
        public void validate() {
            if (mEffectId != EFFECT_CLICK) {
            if (mEffectId != EFFECT_CLICK) {
                throw new IllegalArgumentException("Unknown prebaked effect type");
                throw new IllegalArgumentException(
                        "Unknown prebaked effect type (value=" + mEffectId + ")");
            }
            }
        }
        }


+2 −0
Original line number Original line Diff line number Diff line
@@ -157,6 +157,8 @@ public abstract class Vibrator {
        // This call needs to continue throwing ArrayIndexOutOfBoundsException but ignore all other
        // This call needs to continue throwing ArrayIndexOutOfBoundsException but ignore all other
        // exceptions for compatibility purposes
        // exceptions for compatibility purposes
        if (repeat < -1 || repeat >= pattern.length) {
        if (repeat < -1 || repeat >= pattern.length) {
            Log.e(TAG, "vibrate called with repeat index out of bounds" +
                    " (pattern.length=" + pattern.length + ", index=" + repeat + ")");
            throw new ArrayIndexOutOfBoundsException();
            throw new ArrayIndexOutOfBoundsException();
        }
        }