Loading core/java/android/os/VibrationEffect.java +6 −6 Original line number Diff line number Diff line Loading @@ -525,14 +525,14 @@ public abstract class VibrationEffect implements Parcelable { public abstract long getDuration(); /** * Checks if a given {@link Vibrator} can play this effect as intended. * Checks if a vibrator with a given {@link VibratorInfo} can play this effect as intended. * * <p>See @link Vibrator#areVibrationFeaturesSupported(VibrationEffect)} for more information * about what counts as supported by a vibrator, and what counts as not. * <p>See {@link VibratorInfo#areVibrationFeaturesSupported(VibrationEffect)} for more * information about what counts as supported by a vibrator, and what counts as not. * * @hide */ public abstract boolean areVibrationFeaturesSupported(@NonNull Vibrator vibrator); public abstract boolean areVibrationFeaturesSupported(@NonNull VibratorInfo vibratorInfo); /** * Returns true if this effect could represent a touch haptic feedback. Loading Loading @@ -813,9 +813,9 @@ public abstract class VibrationEffect implements Parcelable { /** @hide */ @Override public boolean areVibrationFeaturesSupported(@NonNull Vibrator vibrator) { public boolean areVibrationFeaturesSupported(@NonNull VibratorInfo vibratorInfo) { for (VibrationEffectSegment segment : mSegments) { if (!segment.areVibrationFeaturesSupported(vibrator)) { if (!segment.areVibrationFeaturesSupported(vibratorInfo)) { return false; } } Loading core/java/android/os/Vibrator.java +2 −4 Original line number Diff line number Diff line Loading @@ -216,9 +216,7 @@ public abstract class Vibrator { */ @TestApi public boolean hasFrequencyControl() { // We currently can only control frequency of the vibration using the compose PWLE method. return getInfo().hasCapability( IVibrator.CAP_FREQUENCY_CONTROL | IVibrator.CAP_COMPOSE_PWLE_EFFECTS); return getInfo().hasFrequencyControl(); } /** Loading @@ -240,7 +238,7 @@ public abstract class Vibrator { * @hide */ public boolean areVibrationFeaturesSupported(@NonNull VibrationEffect effect) { return effect.areVibrationFeaturesSupported(this); return getInfo().areVibrationFeaturesSupported(effect); } /** Loading core/java/android/os/VibratorInfo.java +28 −0 Original line number Diff line number Diff line Loading @@ -241,6 +241,17 @@ public class VibratorInfo implements Parcelable { return hasCapability(IVibrator.CAP_AMPLITUDE_CONTROL); } /** * Check whether the vibrator has frequency control. * * @return True if the hardware can control the frequency of the vibrations, otherwise false. */ public boolean hasFrequencyControl() { // We currently can only control frequency of the vibration using the compose PWLE method. return hasCapability( IVibrator.CAP_FREQUENCY_CONTROL | IVibrator.CAP_COMPOSE_PWLE_EFFECTS); } /** * Returns a default value to be applied to composed PWLE effects for braking. * Loading Loading @@ -322,6 +333,23 @@ public class VibratorInfo implements Parcelable { && (mSupportedPrimitives.indexOfKey(primitiveId) >= 0); } /** * Query whether or not the vibrator supports all components of a given {@link VibrationEffect} * (i.e. the vibrator can play the given effect as intended). * * <p>See {@link Vibrator#areVibrationFeaturesSupported(VibrationEffect)} for more * information on how the vibrator support is determined. * * @param effect the {@link VibrationEffect} to check if it is supported * @return {@code true} if the vibrator can play the given {@code effect} as intended, * {@code false} otherwise. * * @hide */ public boolean areVibrationFeaturesSupported(@NonNull VibrationEffect effect) { return effect.areVibrationFeaturesSupported(this); } /** * Query the estimated duration of given primitive. * Loading core/java/android/os/vibrator/PrebakedSegment.java +3 −2 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.os.Parcel; import android.os.Parcelable; import android.os.VibrationEffect; import android.os.Vibrator; import android.os.VibratorInfo; import java.util.Objects; Loading Loading @@ -77,8 +78,8 @@ public final class PrebakedSegment extends VibrationEffectSegment { /** @hide */ @Override public boolean areVibrationFeaturesSupported(@NonNull Vibrator vibrator) { if (vibrator.areAllEffectsSupported(mEffectId) == Vibrator.VIBRATION_EFFECT_SUPPORT_YES) { public boolean areVibrationFeaturesSupported(@NonNull VibratorInfo vibratorInfo) { if (vibratorInfo.isEffectSupported(mEffectId) == Vibrator.VIBRATION_EFFECT_SUPPORT_YES) { return true; } if (!mFallback) { Loading core/java/android/os/vibrator/PrimitiveSegment.java +3 −3 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ import android.annotation.TestApi; import android.os.Parcel; import android.os.Parcelable; import android.os.VibrationEffect; import android.os.Vibrator; import android.os.VibratorInfo; import com.android.internal.util.Preconditions; Loading Loading @@ -77,8 +77,8 @@ public final class PrimitiveSegment extends VibrationEffectSegment { /** @hide */ @Override public boolean areVibrationFeaturesSupported(@NonNull Vibrator vibrator) { return vibrator.areAllPrimitivesSupported(mPrimitiveId); public boolean areVibrationFeaturesSupported(@NonNull VibratorInfo vibratorInfo) { return vibratorInfo.isPrimitiveSupported(mPrimitiveId); } /** @hide */ Loading Loading
core/java/android/os/VibrationEffect.java +6 −6 Original line number Diff line number Diff line Loading @@ -525,14 +525,14 @@ public abstract class VibrationEffect implements Parcelable { public abstract long getDuration(); /** * Checks if a given {@link Vibrator} can play this effect as intended. * Checks if a vibrator with a given {@link VibratorInfo} can play this effect as intended. * * <p>See @link Vibrator#areVibrationFeaturesSupported(VibrationEffect)} for more information * about what counts as supported by a vibrator, and what counts as not. * <p>See {@link VibratorInfo#areVibrationFeaturesSupported(VibrationEffect)} for more * information about what counts as supported by a vibrator, and what counts as not. * * @hide */ public abstract boolean areVibrationFeaturesSupported(@NonNull Vibrator vibrator); public abstract boolean areVibrationFeaturesSupported(@NonNull VibratorInfo vibratorInfo); /** * Returns true if this effect could represent a touch haptic feedback. Loading Loading @@ -813,9 +813,9 @@ public abstract class VibrationEffect implements Parcelable { /** @hide */ @Override public boolean areVibrationFeaturesSupported(@NonNull Vibrator vibrator) { public boolean areVibrationFeaturesSupported(@NonNull VibratorInfo vibratorInfo) { for (VibrationEffectSegment segment : mSegments) { if (!segment.areVibrationFeaturesSupported(vibrator)) { if (!segment.areVibrationFeaturesSupported(vibratorInfo)) { return false; } } Loading
core/java/android/os/Vibrator.java +2 −4 Original line number Diff line number Diff line Loading @@ -216,9 +216,7 @@ public abstract class Vibrator { */ @TestApi public boolean hasFrequencyControl() { // We currently can only control frequency of the vibration using the compose PWLE method. return getInfo().hasCapability( IVibrator.CAP_FREQUENCY_CONTROL | IVibrator.CAP_COMPOSE_PWLE_EFFECTS); return getInfo().hasFrequencyControl(); } /** Loading @@ -240,7 +238,7 @@ public abstract class Vibrator { * @hide */ public boolean areVibrationFeaturesSupported(@NonNull VibrationEffect effect) { return effect.areVibrationFeaturesSupported(this); return getInfo().areVibrationFeaturesSupported(effect); } /** Loading
core/java/android/os/VibratorInfo.java +28 −0 Original line number Diff line number Diff line Loading @@ -241,6 +241,17 @@ public class VibratorInfo implements Parcelable { return hasCapability(IVibrator.CAP_AMPLITUDE_CONTROL); } /** * Check whether the vibrator has frequency control. * * @return True if the hardware can control the frequency of the vibrations, otherwise false. */ public boolean hasFrequencyControl() { // We currently can only control frequency of the vibration using the compose PWLE method. return hasCapability( IVibrator.CAP_FREQUENCY_CONTROL | IVibrator.CAP_COMPOSE_PWLE_EFFECTS); } /** * Returns a default value to be applied to composed PWLE effects for braking. * Loading Loading @@ -322,6 +333,23 @@ public class VibratorInfo implements Parcelable { && (mSupportedPrimitives.indexOfKey(primitiveId) >= 0); } /** * Query whether or not the vibrator supports all components of a given {@link VibrationEffect} * (i.e. the vibrator can play the given effect as intended). * * <p>See {@link Vibrator#areVibrationFeaturesSupported(VibrationEffect)} for more * information on how the vibrator support is determined. * * @param effect the {@link VibrationEffect} to check if it is supported * @return {@code true} if the vibrator can play the given {@code effect} as intended, * {@code false} otherwise. * * @hide */ public boolean areVibrationFeaturesSupported(@NonNull VibrationEffect effect) { return effect.areVibrationFeaturesSupported(this); } /** * Query the estimated duration of given primitive. * Loading
core/java/android/os/vibrator/PrebakedSegment.java +3 −2 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.os.Parcel; import android.os.Parcelable; import android.os.VibrationEffect; import android.os.Vibrator; import android.os.VibratorInfo; import java.util.Objects; Loading Loading @@ -77,8 +78,8 @@ public final class PrebakedSegment extends VibrationEffectSegment { /** @hide */ @Override public boolean areVibrationFeaturesSupported(@NonNull Vibrator vibrator) { if (vibrator.areAllEffectsSupported(mEffectId) == Vibrator.VIBRATION_EFFECT_SUPPORT_YES) { public boolean areVibrationFeaturesSupported(@NonNull VibratorInfo vibratorInfo) { if (vibratorInfo.isEffectSupported(mEffectId) == Vibrator.VIBRATION_EFFECT_SUPPORT_YES) { return true; } if (!mFallback) { Loading
core/java/android/os/vibrator/PrimitiveSegment.java +3 −3 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ import android.annotation.TestApi; import android.os.Parcel; import android.os.Parcelable; import android.os.VibrationEffect; import android.os.Vibrator; import android.os.VibratorInfo; import com.android.internal.util.Preconditions; Loading Loading @@ -77,8 +77,8 @@ public final class PrimitiveSegment extends VibrationEffectSegment { /** @hide */ @Override public boolean areVibrationFeaturesSupported(@NonNull Vibrator vibrator) { return vibrator.areAllPrimitivesSupported(mPrimitiveId); public boolean areVibrationFeaturesSupported(@NonNull VibratorInfo vibratorInfo) { return vibratorInfo.isPrimitiveSupported(mPrimitiveId); } /** @hide */ Loading