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

Commit 9515833d authored by Simon Bowden's avatar Simon Bowden Committed by Android (Google) Code Review
Browse files

Merge "Directly implement areAllEffectsSupported and areAllPrimitivesSupported...

Merge "Directly implement areAllEffectsSupported and areAllPrimitivesSupported rather than creating and throwing away an extra array to pass into the non-All version."
parents 231a8bb5 5b14477d
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
@@ -546,18 +546,22 @@ public abstract class Vibrator {
    @VibrationEffectSupport
    public final int areAllEffectsSupported(
            @NonNull @VibrationEffect.EffectType int... effectIds) {
        int support = VIBRATION_EFFECT_SUPPORT_YES;
        for (int supported : areEffectsSupported(effectIds)) {
            if (supported == VIBRATION_EFFECT_SUPPORT_NO) {
        VibratorInfo info = getInfo();
        int allSupported = VIBRATION_EFFECT_SUPPORT_YES;
        for (int effectId : effectIds) {
            switch (info.isEffectSupported(effectId)) {
                case VIBRATION_EFFECT_SUPPORT_NO:
                    return VIBRATION_EFFECT_SUPPORT_NO;
            } else if (supported == VIBRATION_EFFECT_SUPPORT_UNKNOWN) {
                support = VIBRATION_EFFECT_SUPPORT_UNKNOWN;
                case VIBRATION_EFFECT_SUPPORT_YES:
                    continue;
                default: // VIBRATION_EFFECT_SUPPORT_UNKNOWN
                    allSupported = VIBRATION_EFFECT_SUPPORT_UNKNOWN;
                    break;
            }
        }
        return support;
        return allSupported;
    }


    /**
     * Query whether the vibrator supports the given primitives.
     *
@@ -598,8 +602,9 @@ public abstract class Vibrator {
     */
    public final boolean areAllPrimitivesSupported(
            @NonNull @VibrationEffect.Composition.PrimitiveType int... primitiveIds) {
        for (boolean supported : arePrimitivesSupported(primitiveIds)) {
            if (!supported) {
        VibratorInfo info = getInfo();
        for (int primitiveId : primitiveIds) {
            if (!info.isPrimitiveSupported(primitiveId)) {
                return false;
            }
        }