Loading api/current.txt +5 −2 Original line number Original line Diff line number Diff line Loading @@ -37160,9 +37160,9 @@ package android.os { } } public abstract class Vibrator { public abstract class Vibrator { method @Nullable public final Boolean areAllEffectsSupported(@NonNull int...); method public final int areAllEffectsSupported(@NonNull int...); method public final boolean areAllPrimitivesSupported(@NonNull int...); method public final boolean areAllPrimitivesSupported(@NonNull int...); method @Nullable public boolean[] areEffectsSupported(@NonNull int...); method @NonNull public int[] areEffectsSupported(@NonNull int...); method @NonNull public boolean[] arePrimitivesSupported(@NonNull int...); method @NonNull public boolean[] arePrimitivesSupported(@NonNull int...); method @RequiresPermission(android.Manifest.permission.VIBRATE) public abstract void cancel(); method @RequiresPermission(android.Manifest.permission.VIBRATE) public abstract void cancel(); method public abstract boolean hasAmplitudeControl(); method public abstract boolean hasAmplitudeControl(); Loading @@ -37173,6 +37173,9 @@ package android.os { method @Deprecated @RequiresPermission(android.Manifest.permission.VIBRATE) public void vibrate(long[], int, android.media.AudioAttributes); method @Deprecated @RequiresPermission(android.Manifest.permission.VIBRATE) public void vibrate(long[], int, android.media.AudioAttributes); method @RequiresPermission(android.Manifest.permission.VIBRATE) public void vibrate(android.os.VibrationEffect); method @RequiresPermission(android.Manifest.permission.VIBRATE) public void vibrate(android.os.VibrationEffect); method @RequiresPermission(android.Manifest.permission.VIBRATE) public void vibrate(android.os.VibrationEffect, android.media.AudioAttributes); method @RequiresPermission(android.Manifest.permission.VIBRATE) public void vibrate(android.os.VibrationEffect, android.media.AudioAttributes); field public static final int VIBRATION_EFFECT_SUPPORT_NO = 2; // 0x2 field public static final int VIBRATION_EFFECT_SUPPORT_UNKNOWN = 0; // 0x0 field public static final int VIBRATION_EFFECT_SUPPORT_YES = 1; // 0x1 } } public class WorkSource implements android.os.Parcelable { public class WorkSource implements android.os.Parcelable { core/java/android/os/IVibratorService.aidl +1 −1 Original line number Original line Diff line number Diff line Loading @@ -28,7 +28,7 @@ interface IVibratorService boolean registerVibratorStateListener(in IVibratorStateListener listener); boolean registerVibratorStateListener(in IVibratorStateListener listener); boolean unregisterVibratorStateListener(in IVibratorStateListener listener); boolean unregisterVibratorStateListener(in IVibratorStateListener listener); boolean hasAmplitudeControl(); boolean hasAmplitudeControl(); boolean[] areEffectsSupported(in int[] effectIds); int[] areEffectsSupported(in int[] effectIds); boolean[] arePrimitivesSupported(in int[] primitiveIds); boolean[] arePrimitivesSupported(in int[] primitiveIds); boolean setAlwaysOnEffect(int uid, String opPkg, int alwaysOnId, in VibrationEffect effect, boolean setAlwaysOnEffect(int uid, String opPkg, int alwaysOnId, in VibrationEffect effect, in VibrationAttributes attributes); in VibrationAttributes attributes); Loading core/java/android/os/SystemVibrator.java +6 −5 Original line number Original line Diff line number Diff line Loading @@ -21,12 +21,13 @@ import android.annotation.NonNull; import android.compat.annotation.UnsupportedAppUsage; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.Context; import android.media.AudioAttributes; import android.media.AudioAttributes; import android.os.IVibratorStateListener; import android.util.ArrayMap; import android.util.ArrayMap; import android.util.Log; import android.util.Log; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.GuardedBy; import java.util.concurrent.Executor; import java.util.Objects; import java.util.Objects; import java.util.concurrent.Executor; /** /** * Vibrator implementation that controls the main system vibrator. * Vibrator implementation that controls the main system vibrator. Loading Loading @@ -238,13 +239,13 @@ public class SystemVibrator extends Vibrator { } } @Override @Override public boolean[] areEffectsSupported(@VibrationEffect.EffectType int... effectIds) { public int[] areEffectsSupported(@VibrationEffect.EffectType int... effectIds) { try { try { return mService.areEffectsSupported(effectIds); return mService.areEffectsSupported(effectIds); } catch (RemoteException e) { } catch (RemoteException e) { Log.w(TAG, "Failed to query effect support"); Log.w(TAG, "Failed to query effect support"); throw e.rethrowAsRuntimeException(); } } return new boolean[effectIds.length]; } } @Override @Override Loading @@ -254,8 +255,8 @@ public class SystemVibrator extends Vibrator { return mService.arePrimitivesSupported(primitiveIds); return mService.arePrimitivesSupported(primitiveIds); } catch (RemoteException e) { } catch (RemoteException e) { Log.w(TAG, "Failed to query effect support"); Log.w(TAG, "Failed to query effect support"); throw e.rethrowAsRuntimeException(); } } return new boolean[primitiveIds.length]; } } Loading core/java/android/os/Vibrator.java +69 −23 Original line number Original line Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.util.Log; import java.lang.annotation.Retention; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy; import java.util.Arrays; import java.util.concurrent.Executor; import java.util.concurrent.Executor; /** /** Loading Loading @@ -72,6 +73,37 @@ public abstract class Vibrator { */ */ public static final int VIBRATION_INTENSITY_HIGH = 3; public static final int VIBRATION_INTENSITY_HIGH = 3; /** * Vibration effect support: unknown * * The hardware doesn't report it's supported effects, so we can't determine whether the * effect is supported or not. */ public static final int VIBRATION_EFFECT_SUPPORT_UNKNOWN = 0; /** * Vibration effect support: supported * * This effect is supported by the underlying hardware. */ public static final int VIBRATION_EFFECT_SUPPORT_YES = 1; /** * Vibration effect support: unsupported * * This effect is <b>not</b> supported by the underlying hardware. */ public static final int VIBRATION_EFFECT_SUPPORT_NO = 2; /** @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef(prefix = {"VIBRATION_EFFECT_SUPPORT_"}, value = { VIBRATION_EFFECT_SUPPORT_UNKNOWN, VIBRATION_EFFECT_SUPPORT_YES, VIBRATION_EFFECT_SUPPORT_NO, }) public @interface VibrationEffectSupport {} /** @hide */ /** @hide */ @Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE) @IntDef(prefix = {"VIBRATION_INTENSITY_"}, value = { @IntDef(prefix = {"VIBRATION_INTENSITY_"}, value = { Loading Loading @@ -318,47 +350,61 @@ public abstract class Vibrator { /** /** * Query whether the vibrator supports the given effects. * Query whether the vibrator supports the given effects. * * * If the returned array is {@code null}, the hardware doesn't support querying its supported * Not all hardware reports its effect capabilities, so the system may not necessarily know * effects. It may support any or all effects, but there's no way to programmatically know * whether an effect is supported or not. * whether a {@link #vibrate} call will be successful. * * * If the returned array is non-null, then it will be the same length as the query array and * The returned array will be the same length as the query array and the value at a given index * the value at a given index will contain whether the effect at that same index in the * will contain {@link #VIBRATION_EFFECT_SUPPORT_YES} if the effect at that same index in the * querying array is supported or not. * querying array is supported, {@link #VIBRATION_EFFECT_SUPPORT_NO} if it isn't supported, or * {@link #VIBRATION_EFFECT_SUPPORT_UNKNOWN} if the system can't determine whether it's * supported or not. * * * @param effectIds Which effects to query for. * @param effectIds Which effects to query for. * @return Whether the effects are supported. Null when the hardware doesn't tell us what it * @return An array containing the systems current knowledge about whether the given effects * supports. * are supported or not. */ */ @Nullable @NonNull public boolean[] areEffectsSupported( @VibrationEffectSupport public int[] areEffectsSupported( @NonNull @VibrationEffect.EffectType int... effectIds) { @NonNull @VibrationEffect.EffectType int... effectIds) { return new boolean[effectIds.length]; final int[] support = new int[effectIds.length]; Arrays.fill(support, VIBRATION_EFFECT_SUPPORT_NO); return support; } } /** /** * Query whether the vibrator supports all of the given effects. * Query whether the vibrator supports all of the given effects. * * * If the result is {@code null}, the hardware doesn't support querying its supported * Not all hardware reports its effect capabilities, so the system may not necessarily know * effects. It may support any or all effects, but there's no way to programmatically know * whether an effect is supported or not. * whether a {@link #vibrate} call will be successful. * * * If the returned array is non-null, then it will return whether all of the effects are * If the result is {@link #VIBRATION_EFFECT_SUPPORT_YES}, all effects in the query are * supported by the hardware. * supported by the hardware. * * * If the result is {@link #VIBRATION_EFFECT_SUPPORT_NO}, at least one of the effects in the * query is not supported. * * If the result is {@link #VIBRATION_EFFECT_SUPPORT_UNKNOWN}, the system doesn't know whether * all of the effects are supported. It may support any or all of the queried effects, * but there's no way to programmatically know whether a {@link #vibrate} call will successfully * cause a vibration. It's guaranteed, however, that none of the queried effects are * definitively unsupported by the hardware. * * @param effectIds Which effects to query for. * @param effectIds Which effects to query for. * @return Whether the effects are supported. {@code null} when the hardware doesn't tell us * @return Whether all of the effects are supported. * what it supports. */ */ @Nullable @VibrationEffectSupport public final Boolean areAllEffectsSupported( public final int areAllEffectsSupported( @NonNull @VibrationEffect.EffectType int... effectIds) { @NonNull @VibrationEffect.EffectType int... effectIds) { for (boolean supported : areEffectsSupported(effectIds)) { int support = VIBRATION_EFFECT_SUPPORT_YES; if (!supported) { for (int supported : areEffectsSupported(effectIds)) { return false; if (supported == VIBRATION_EFFECT_SUPPORT_NO) { return VIBRATION_EFFECT_SUPPORT_NO; } else if (supported == VIBRATION_EFFECT_SUPPORT_UNKNOWN) { support = VIBRATION_EFFECT_SUPPORT_UNKNOWN; } } } } return true; return support; } } Loading services/core/java/com/android/server/VibratorService.java +9 −8 Original line number Original line Diff line number Diff line Loading @@ -605,15 +605,16 @@ public class VibratorService extends IVibratorService.Stub } } @Override // Binder call @Override // Binder call public boolean[] areEffectsSupported(int[] effectIds) { public int[] areEffectsSupported(int[] effectIds) { // Return null to indicate that the HAL doesn't actually tell us what effects are int[] supported = new int[effectIds.length]; // supported. if (mSupportedEffects == null) { if (mSupportedEffects == null) { return null; Arrays.fill(supported, Vibrator.VIBRATION_EFFECT_SUPPORT_UNKNOWN); } } else { boolean[] supported = new boolean[effectIds.length]; for (int i = 0; i < effectIds.length; i++) { for (int i = 0; i < effectIds.length; i++) { supported[i] = mSupportedEffects.contains(effectIds[i]); supported[i] = mSupportedEffects.contains(effectIds[i]) ? Vibrator.VIBRATION_EFFECT_SUPPORT_YES : Vibrator.VIBRATION_EFFECT_SUPPORT_NO; } } } return supported; return supported; } } Loading Loading
api/current.txt +5 −2 Original line number Original line Diff line number Diff line Loading @@ -37160,9 +37160,9 @@ package android.os { } } public abstract class Vibrator { public abstract class Vibrator { method @Nullable public final Boolean areAllEffectsSupported(@NonNull int...); method public final int areAllEffectsSupported(@NonNull int...); method public final boolean areAllPrimitivesSupported(@NonNull int...); method public final boolean areAllPrimitivesSupported(@NonNull int...); method @Nullable public boolean[] areEffectsSupported(@NonNull int...); method @NonNull public int[] areEffectsSupported(@NonNull int...); method @NonNull public boolean[] arePrimitivesSupported(@NonNull int...); method @NonNull public boolean[] arePrimitivesSupported(@NonNull int...); method @RequiresPermission(android.Manifest.permission.VIBRATE) public abstract void cancel(); method @RequiresPermission(android.Manifest.permission.VIBRATE) public abstract void cancel(); method public abstract boolean hasAmplitudeControl(); method public abstract boolean hasAmplitudeControl(); Loading @@ -37173,6 +37173,9 @@ package android.os { method @Deprecated @RequiresPermission(android.Manifest.permission.VIBRATE) public void vibrate(long[], int, android.media.AudioAttributes); method @Deprecated @RequiresPermission(android.Manifest.permission.VIBRATE) public void vibrate(long[], int, android.media.AudioAttributes); method @RequiresPermission(android.Manifest.permission.VIBRATE) public void vibrate(android.os.VibrationEffect); method @RequiresPermission(android.Manifest.permission.VIBRATE) public void vibrate(android.os.VibrationEffect); method @RequiresPermission(android.Manifest.permission.VIBRATE) public void vibrate(android.os.VibrationEffect, android.media.AudioAttributes); method @RequiresPermission(android.Manifest.permission.VIBRATE) public void vibrate(android.os.VibrationEffect, android.media.AudioAttributes); field public static final int VIBRATION_EFFECT_SUPPORT_NO = 2; // 0x2 field public static final int VIBRATION_EFFECT_SUPPORT_UNKNOWN = 0; // 0x0 field public static final int VIBRATION_EFFECT_SUPPORT_YES = 1; // 0x1 } } public class WorkSource implements android.os.Parcelable { public class WorkSource implements android.os.Parcelable {
core/java/android/os/IVibratorService.aidl +1 −1 Original line number Original line Diff line number Diff line Loading @@ -28,7 +28,7 @@ interface IVibratorService boolean registerVibratorStateListener(in IVibratorStateListener listener); boolean registerVibratorStateListener(in IVibratorStateListener listener); boolean unregisterVibratorStateListener(in IVibratorStateListener listener); boolean unregisterVibratorStateListener(in IVibratorStateListener listener); boolean hasAmplitudeControl(); boolean hasAmplitudeControl(); boolean[] areEffectsSupported(in int[] effectIds); int[] areEffectsSupported(in int[] effectIds); boolean[] arePrimitivesSupported(in int[] primitiveIds); boolean[] arePrimitivesSupported(in int[] primitiveIds); boolean setAlwaysOnEffect(int uid, String opPkg, int alwaysOnId, in VibrationEffect effect, boolean setAlwaysOnEffect(int uid, String opPkg, int alwaysOnId, in VibrationEffect effect, in VibrationAttributes attributes); in VibrationAttributes attributes); Loading
core/java/android/os/SystemVibrator.java +6 −5 Original line number Original line Diff line number Diff line Loading @@ -21,12 +21,13 @@ import android.annotation.NonNull; import android.compat.annotation.UnsupportedAppUsage; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.Context; import android.media.AudioAttributes; import android.media.AudioAttributes; import android.os.IVibratorStateListener; import android.util.ArrayMap; import android.util.ArrayMap; import android.util.Log; import android.util.Log; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.GuardedBy; import java.util.concurrent.Executor; import java.util.Objects; import java.util.Objects; import java.util.concurrent.Executor; /** /** * Vibrator implementation that controls the main system vibrator. * Vibrator implementation that controls the main system vibrator. Loading Loading @@ -238,13 +239,13 @@ public class SystemVibrator extends Vibrator { } } @Override @Override public boolean[] areEffectsSupported(@VibrationEffect.EffectType int... effectIds) { public int[] areEffectsSupported(@VibrationEffect.EffectType int... effectIds) { try { try { return mService.areEffectsSupported(effectIds); return mService.areEffectsSupported(effectIds); } catch (RemoteException e) { } catch (RemoteException e) { Log.w(TAG, "Failed to query effect support"); Log.w(TAG, "Failed to query effect support"); throw e.rethrowAsRuntimeException(); } } return new boolean[effectIds.length]; } } @Override @Override Loading @@ -254,8 +255,8 @@ public class SystemVibrator extends Vibrator { return mService.arePrimitivesSupported(primitiveIds); return mService.arePrimitivesSupported(primitiveIds); } catch (RemoteException e) { } catch (RemoteException e) { Log.w(TAG, "Failed to query effect support"); Log.w(TAG, "Failed to query effect support"); throw e.rethrowAsRuntimeException(); } } return new boolean[primitiveIds.length]; } } Loading
core/java/android/os/Vibrator.java +69 −23 Original line number Original line Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.util.Log; import java.lang.annotation.Retention; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy; import java.util.Arrays; import java.util.concurrent.Executor; import java.util.concurrent.Executor; /** /** Loading Loading @@ -72,6 +73,37 @@ public abstract class Vibrator { */ */ public static final int VIBRATION_INTENSITY_HIGH = 3; public static final int VIBRATION_INTENSITY_HIGH = 3; /** * Vibration effect support: unknown * * The hardware doesn't report it's supported effects, so we can't determine whether the * effect is supported or not. */ public static final int VIBRATION_EFFECT_SUPPORT_UNKNOWN = 0; /** * Vibration effect support: supported * * This effect is supported by the underlying hardware. */ public static final int VIBRATION_EFFECT_SUPPORT_YES = 1; /** * Vibration effect support: unsupported * * This effect is <b>not</b> supported by the underlying hardware. */ public static final int VIBRATION_EFFECT_SUPPORT_NO = 2; /** @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef(prefix = {"VIBRATION_EFFECT_SUPPORT_"}, value = { VIBRATION_EFFECT_SUPPORT_UNKNOWN, VIBRATION_EFFECT_SUPPORT_YES, VIBRATION_EFFECT_SUPPORT_NO, }) public @interface VibrationEffectSupport {} /** @hide */ /** @hide */ @Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE) @IntDef(prefix = {"VIBRATION_INTENSITY_"}, value = { @IntDef(prefix = {"VIBRATION_INTENSITY_"}, value = { Loading Loading @@ -318,47 +350,61 @@ public abstract class Vibrator { /** /** * Query whether the vibrator supports the given effects. * Query whether the vibrator supports the given effects. * * * If the returned array is {@code null}, the hardware doesn't support querying its supported * Not all hardware reports its effect capabilities, so the system may not necessarily know * effects. It may support any or all effects, but there's no way to programmatically know * whether an effect is supported or not. * whether a {@link #vibrate} call will be successful. * * * If the returned array is non-null, then it will be the same length as the query array and * The returned array will be the same length as the query array and the value at a given index * the value at a given index will contain whether the effect at that same index in the * will contain {@link #VIBRATION_EFFECT_SUPPORT_YES} if the effect at that same index in the * querying array is supported or not. * querying array is supported, {@link #VIBRATION_EFFECT_SUPPORT_NO} if it isn't supported, or * {@link #VIBRATION_EFFECT_SUPPORT_UNKNOWN} if the system can't determine whether it's * supported or not. * * * @param effectIds Which effects to query for. * @param effectIds Which effects to query for. * @return Whether the effects are supported. Null when the hardware doesn't tell us what it * @return An array containing the systems current knowledge about whether the given effects * supports. * are supported or not. */ */ @Nullable @NonNull public boolean[] areEffectsSupported( @VibrationEffectSupport public int[] areEffectsSupported( @NonNull @VibrationEffect.EffectType int... effectIds) { @NonNull @VibrationEffect.EffectType int... effectIds) { return new boolean[effectIds.length]; final int[] support = new int[effectIds.length]; Arrays.fill(support, VIBRATION_EFFECT_SUPPORT_NO); return support; } } /** /** * Query whether the vibrator supports all of the given effects. * Query whether the vibrator supports all of the given effects. * * * If the result is {@code null}, the hardware doesn't support querying its supported * Not all hardware reports its effect capabilities, so the system may not necessarily know * effects. It may support any or all effects, but there's no way to programmatically know * whether an effect is supported or not. * whether a {@link #vibrate} call will be successful. * * * If the returned array is non-null, then it will return whether all of the effects are * If the result is {@link #VIBRATION_EFFECT_SUPPORT_YES}, all effects in the query are * supported by the hardware. * supported by the hardware. * * * If the result is {@link #VIBRATION_EFFECT_SUPPORT_NO}, at least one of the effects in the * query is not supported. * * If the result is {@link #VIBRATION_EFFECT_SUPPORT_UNKNOWN}, the system doesn't know whether * all of the effects are supported. It may support any or all of the queried effects, * but there's no way to programmatically know whether a {@link #vibrate} call will successfully * cause a vibration. It's guaranteed, however, that none of the queried effects are * definitively unsupported by the hardware. * * @param effectIds Which effects to query for. * @param effectIds Which effects to query for. * @return Whether the effects are supported. {@code null} when the hardware doesn't tell us * @return Whether all of the effects are supported. * what it supports. */ */ @Nullable @VibrationEffectSupport public final Boolean areAllEffectsSupported( public final int areAllEffectsSupported( @NonNull @VibrationEffect.EffectType int... effectIds) { @NonNull @VibrationEffect.EffectType int... effectIds) { for (boolean supported : areEffectsSupported(effectIds)) { int support = VIBRATION_EFFECT_SUPPORT_YES; if (!supported) { for (int supported : areEffectsSupported(effectIds)) { return false; if (supported == VIBRATION_EFFECT_SUPPORT_NO) { return VIBRATION_EFFECT_SUPPORT_NO; } else if (supported == VIBRATION_EFFECT_SUPPORT_UNKNOWN) { support = VIBRATION_EFFECT_SUPPORT_UNKNOWN; } } } } return true; return support; } } Loading
services/core/java/com/android/server/VibratorService.java +9 −8 Original line number Original line Diff line number Diff line Loading @@ -605,15 +605,16 @@ public class VibratorService extends IVibratorService.Stub } } @Override // Binder call @Override // Binder call public boolean[] areEffectsSupported(int[] effectIds) { public int[] areEffectsSupported(int[] effectIds) { // Return null to indicate that the HAL doesn't actually tell us what effects are int[] supported = new int[effectIds.length]; // supported. if (mSupportedEffects == null) { if (mSupportedEffects == null) { return null; Arrays.fill(supported, Vibrator.VIBRATION_EFFECT_SUPPORT_UNKNOWN); } } else { boolean[] supported = new boolean[effectIds.length]; for (int i = 0; i < effectIds.length; i++) { for (int i = 0; i < effectIds.length; i++) { supported[i] = mSupportedEffects.contains(effectIds[i]); supported[i] = mSupportedEffects.contains(effectIds[i]) ? Vibrator.VIBRATION_EFFECT_SUPPORT_YES : Vibrator.VIBRATION_EFFECT_SUPPORT_NO; } } } return supported; return supported; } } Loading