Loading core/java/android/os/IVibratorManagerService.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -18,10 +18,12 @@ package android.os; import android.os.CombinedVibrationEffect; import android.os.VibrationAttributes; import android.os.VibratorInfo; /** {@hide} */ interface IVibratorManagerService { int[] getVibratorIds(); VibratorInfo getVibratorInfo(int vibratorId); boolean setAlwaysOnEffect(int uid, String opPkg, int alwaysOnId, in CombinedVibrationEffect effect, in VibrationAttributes attributes); void vibrate(int uid, String opPkg, in CombinedVibrationEffect effect, Loading core/java/android/os/IVibratorService.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.os; import android.os.VibrationEffect; import android.os.VibrationAttributes; import android.os.VibratorInfo; import android.os.IVibratorStateListener; /** {@hide} */ Loading @@ -25,11 +26,10 @@ interface IVibratorService { boolean hasVibrator(); boolean isVibrating(); VibratorInfo getVibratorInfo(); boolean registerVibratorStateListener(in IVibratorStateListener listener); boolean unregisterVibratorStateListener(in IVibratorStateListener listener); boolean hasAmplitudeControl(); int[] areEffectsSupported(in int[] effectIds); boolean[] arePrimitivesSupported(in int[] primitiveIds); void vibrate(int uid, String opPkg, in VibrationEffect effect, in VibrationAttributes attributes, String reason, IBinder token); void cancelVibrate(IBinder token); Loading core/java/android/os/SystemVibrator.java +35 −10 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.os; import android.annotation.CallbackExecutor; import android.annotation.NonNull; import android.annotation.Nullable; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; import android.media.AudioAttributes; Loading @@ -39,8 +40,11 @@ public class SystemVibrator extends Vibrator { private final IVibratorService mService; private final IVibratorManagerService mManagerService; private final Object mLock = new Object(); private final Binder mToken = new Binder(); private final Context mContext; @GuardedBy("mLock") private VibratorInfo mVibratorInfo; @GuardedBy("mDelegates") private final ArrayMap<OnVibratorStateChangedListener, Loading Loading @@ -242,23 +246,26 @@ public class SystemVibrator extends Vibrator { @Override public int[] areEffectsSupported(@VibrationEffect.EffectType int... effectIds) { try { return mService.areEffectsSupported(effectIds); } catch (RemoteException e) { Log.w(TAG, "Failed to query effect support"); throw e.rethrowAsRuntimeException(); VibratorInfo vibratorInfo = getVibratorInfo(); int[] supported = new int[effectIds.length]; for (int i = 0; i < effectIds.length; i++) { supported[i] = vibratorInfo == null ? Vibrator.VIBRATION_EFFECT_SUPPORT_UNKNOWN : vibratorInfo.isEffectSupported(effectIds[i]); } return supported; } @Override public boolean[] arePrimitivesSupported( @NonNull @VibrationEffect.Composition.Primitive int... primitiveIds) { try { return mService.arePrimitivesSupported(primitiveIds); } catch (RemoteException e) { Log.w(TAG, "Failed to query effect support"); throw e.rethrowAsRuntimeException(); VibratorInfo vibratorInfo = getVibratorInfo(); boolean[] supported = new boolean[primitiveIds.length]; for (int i = 0; i < primitiveIds.length; i++) { supported[i] = vibratorInfo == null ? false : vibratorInfo.isPrimitiveSupported(primitiveIds[i]); } return supported; } @Override Loading @@ -272,4 +279,22 @@ public class SystemVibrator extends Vibrator { Log.w(TAG, "Failed to cancel vibration.", e); } } @Nullable private VibratorInfo getVibratorInfo() { try { synchronized (mLock) { if (mVibratorInfo != null) { return mVibratorInfo; } if (mService == null) { return null; } return mVibratorInfo = mService.getVibratorInfo(); } } catch (RemoteException e) { Log.w(TAG, "Failed to query vibrator info"); throw e.rethrowFromSystemServer(); } } } core/java/android/os/VibrationEffect.java +22 −2 Original line number Diff line number Diff line Loading @@ -476,6 +476,28 @@ public abstract class VibrationEffect implements Parcelable { return a * fx; } /** @hide */ public static String effectIdToString(int effectId) { switch (effectId) { case EFFECT_CLICK: return "CLICK"; case EFFECT_TICK: return "TICK"; case EFFECT_HEAVY_CLICK: return "HEAVY_CLICK"; case EFFECT_DOUBLE_CLICK: return "DOUBLE_CLICK"; case EFFECT_POP: return "POP"; case EFFECT_THUD: return "THUD"; case EFFECT_TEXTURE_TICK: return "TEXTURE_TICK"; default: return Integer.toString(effectId); } } /** @hide */ @TestApi public static class OneShot extends VibrationEffect implements Parcelable { Loading Loading @@ -1201,10 +1223,8 @@ public abstract class VibrationEffect implements Parcelable { return "PRIMITIVE_QUICK_FALL"; case PRIMITIVE_TICK: return "PRIMITIVE_TICK"; default: return Integer.toString(id); } } Loading core/java/android/os/VibratorInfo.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.os; parcelable VibratorInfo; Loading
core/java/android/os/IVibratorManagerService.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -18,10 +18,12 @@ package android.os; import android.os.CombinedVibrationEffect; import android.os.VibrationAttributes; import android.os.VibratorInfo; /** {@hide} */ interface IVibratorManagerService { int[] getVibratorIds(); VibratorInfo getVibratorInfo(int vibratorId); boolean setAlwaysOnEffect(int uid, String opPkg, int alwaysOnId, in CombinedVibrationEffect effect, in VibrationAttributes attributes); void vibrate(int uid, String opPkg, in CombinedVibrationEffect effect, Loading
core/java/android/os/IVibratorService.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.os; import android.os.VibrationEffect; import android.os.VibrationAttributes; import android.os.VibratorInfo; import android.os.IVibratorStateListener; /** {@hide} */ Loading @@ -25,11 +26,10 @@ interface IVibratorService { boolean hasVibrator(); boolean isVibrating(); VibratorInfo getVibratorInfo(); boolean registerVibratorStateListener(in IVibratorStateListener listener); boolean unregisterVibratorStateListener(in IVibratorStateListener listener); boolean hasAmplitudeControl(); int[] areEffectsSupported(in int[] effectIds); boolean[] arePrimitivesSupported(in int[] primitiveIds); void vibrate(int uid, String opPkg, in VibrationEffect effect, in VibrationAttributes attributes, String reason, IBinder token); void cancelVibrate(IBinder token); Loading
core/java/android/os/SystemVibrator.java +35 −10 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.os; import android.annotation.CallbackExecutor; import android.annotation.NonNull; import android.annotation.Nullable; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; import android.media.AudioAttributes; Loading @@ -39,8 +40,11 @@ public class SystemVibrator extends Vibrator { private final IVibratorService mService; private final IVibratorManagerService mManagerService; private final Object mLock = new Object(); private final Binder mToken = new Binder(); private final Context mContext; @GuardedBy("mLock") private VibratorInfo mVibratorInfo; @GuardedBy("mDelegates") private final ArrayMap<OnVibratorStateChangedListener, Loading Loading @@ -242,23 +246,26 @@ public class SystemVibrator extends Vibrator { @Override public int[] areEffectsSupported(@VibrationEffect.EffectType int... effectIds) { try { return mService.areEffectsSupported(effectIds); } catch (RemoteException e) { Log.w(TAG, "Failed to query effect support"); throw e.rethrowAsRuntimeException(); VibratorInfo vibratorInfo = getVibratorInfo(); int[] supported = new int[effectIds.length]; for (int i = 0; i < effectIds.length; i++) { supported[i] = vibratorInfo == null ? Vibrator.VIBRATION_EFFECT_SUPPORT_UNKNOWN : vibratorInfo.isEffectSupported(effectIds[i]); } return supported; } @Override public boolean[] arePrimitivesSupported( @NonNull @VibrationEffect.Composition.Primitive int... primitiveIds) { try { return mService.arePrimitivesSupported(primitiveIds); } catch (RemoteException e) { Log.w(TAG, "Failed to query effect support"); throw e.rethrowAsRuntimeException(); VibratorInfo vibratorInfo = getVibratorInfo(); boolean[] supported = new boolean[primitiveIds.length]; for (int i = 0; i < primitiveIds.length; i++) { supported[i] = vibratorInfo == null ? false : vibratorInfo.isPrimitiveSupported(primitiveIds[i]); } return supported; } @Override Loading @@ -272,4 +279,22 @@ public class SystemVibrator extends Vibrator { Log.w(TAG, "Failed to cancel vibration.", e); } } @Nullable private VibratorInfo getVibratorInfo() { try { synchronized (mLock) { if (mVibratorInfo != null) { return mVibratorInfo; } if (mService == null) { return null; } return mVibratorInfo = mService.getVibratorInfo(); } } catch (RemoteException e) { Log.w(TAG, "Failed to query vibrator info"); throw e.rethrowFromSystemServer(); } } }
core/java/android/os/VibrationEffect.java +22 −2 Original line number Diff line number Diff line Loading @@ -476,6 +476,28 @@ public abstract class VibrationEffect implements Parcelable { return a * fx; } /** @hide */ public static String effectIdToString(int effectId) { switch (effectId) { case EFFECT_CLICK: return "CLICK"; case EFFECT_TICK: return "TICK"; case EFFECT_HEAVY_CLICK: return "HEAVY_CLICK"; case EFFECT_DOUBLE_CLICK: return "DOUBLE_CLICK"; case EFFECT_POP: return "POP"; case EFFECT_THUD: return "THUD"; case EFFECT_TEXTURE_TICK: return "TEXTURE_TICK"; default: return Integer.toString(effectId); } } /** @hide */ @TestApi public static class OneShot extends VibrationEffect implements Parcelable { Loading Loading @@ -1201,10 +1223,8 @@ public abstract class VibrationEffect implements Parcelable { return "PRIMITIVE_QUICK_FALL"; case PRIMITIVE_TICK: return "PRIMITIVE_TICK"; default: return Integer.toString(id); } } Loading
core/java/android/os/VibratorInfo.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.os; parcelable VibratorInfo;