Loading core/java/android/os/IVibratorManagerService.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -41,5 +41,5 @@ interface IVibratorManagerService { // There is no order guarantee with respect to the two-way APIs above like // vibrate/isVibrating/cancel. oneway void performHapticFeedback(int uid, int deviceId, String opPkg, int constant, boolean always, String reason, IBinder token); boolean always, String reason); } core/java/android/os/SystemVibratorManager.java +3 −2 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ public class SystemVibratorManager extends VibratorManager { private final IVibratorManagerService mService; private final Context mContext; private final int mUid; private final Binder mToken = new Binder(); private final Object mLock = new Object(); @GuardedBy("mLock") Loading @@ -56,6 +57,7 @@ public class SystemVibratorManager extends VibratorManager { public SystemVibratorManager(Context context) { super(context); mContext = context; mUid = Process.myUid(); mService = IVibratorManagerService.Stub.asInterface( ServiceManager.getService(Context.VIBRATOR_MANAGER_SERVICE)); } Loading Loading @@ -152,8 +154,7 @@ public class SystemVibratorManager extends VibratorManager { } try { mService.performHapticFeedback( Process.myUid(), mContext.getDeviceId(), mPackageName, constant, always, reason, mToken); mUid, mContext.getDeviceId(), mPackageName, constant, always, reason); } catch (RemoteException e) { Log.w(TAG, "Failed to perform haptic feedback.", e); } Loading services/core/java/com/android/server/vibrator/VibratorManagerService.java +7 −3 Original line number Diff line number Diff line Loading @@ -403,9 +403,13 @@ public class VibratorManagerService extends IVibratorManagerService.Stub { @Override // Binder call public void performHapticFeedback( int uid, int deviceId, String opPkg, int constant, boolean always, String reason, IBinder token) { performHapticFeedbackInternal(uid, deviceId, opPkg, constant, always, reason, token); int uid, int deviceId, String opPkg, int constant, boolean always, String reason) { // Note that the `performHapticFeedback` method does not take a token argument from the // caller, and instead, uses this service as the token. This is to mitigate performance // impact that would otherwise be caused due to marshal latency. Haptic feedback effects are // short-lived, so we don't need to cancel when the process dies. performHapticFeedbackInternal( uid, deviceId, opPkg, constant, always, reason, /* token= */ this); } /** Loading services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java +11 −0 Original line number Diff line number Diff line Loading @@ -1397,6 +1397,17 @@ public class VibratorManagerServiceTest { assertTrue(mVibratorProviders.get(1).getAllEffectSegments().isEmpty()); } @Test public void performHapticFeedback_usesServiceAsToken() throws Exception { VibratorManagerService service = createSystemReadyService(); HalVibration vibration = performHapticFeedbackAndWaitUntilFinished( service, HapticFeedbackConstants.SCROLL_TICK, /* always= */ true); assertTrue(vibration.callerToken == service); } @Test public void vibrate_withIntensitySettings_appliesSettingsToScaleVibrations() throws Exception { int defaultNotificationIntensity = Loading Loading
core/java/android/os/IVibratorManagerService.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -41,5 +41,5 @@ interface IVibratorManagerService { // There is no order guarantee with respect to the two-way APIs above like // vibrate/isVibrating/cancel. oneway void performHapticFeedback(int uid, int deviceId, String opPkg, int constant, boolean always, String reason, IBinder token); boolean always, String reason); }
core/java/android/os/SystemVibratorManager.java +3 −2 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ public class SystemVibratorManager extends VibratorManager { private final IVibratorManagerService mService; private final Context mContext; private final int mUid; private final Binder mToken = new Binder(); private final Object mLock = new Object(); @GuardedBy("mLock") Loading @@ -56,6 +57,7 @@ public class SystemVibratorManager extends VibratorManager { public SystemVibratorManager(Context context) { super(context); mContext = context; mUid = Process.myUid(); mService = IVibratorManagerService.Stub.asInterface( ServiceManager.getService(Context.VIBRATOR_MANAGER_SERVICE)); } Loading Loading @@ -152,8 +154,7 @@ public class SystemVibratorManager extends VibratorManager { } try { mService.performHapticFeedback( Process.myUid(), mContext.getDeviceId(), mPackageName, constant, always, reason, mToken); mUid, mContext.getDeviceId(), mPackageName, constant, always, reason); } catch (RemoteException e) { Log.w(TAG, "Failed to perform haptic feedback.", e); } Loading
services/core/java/com/android/server/vibrator/VibratorManagerService.java +7 −3 Original line number Diff line number Diff line Loading @@ -403,9 +403,13 @@ public class VibratorManagerService extends IVibratorManagerService.Stub { @Override // Binder call public void performHapticFeedback( int uid, int deviceId, String opPkg, int constant, boolean always, String reason, IBinder token) { performHapticFeedbackInternal(uid, deviceId, opPkg, constant, always, reason, token); int uid, int deviceId, String opPkg, int constant, boolean always, String reason) { // Note that the `performHapticFeedback` method does not take a token argument from the // caller, and instead, uses this service as the token. This is to mitigate performance // impact that would otherwise be caused due to marshal latency. Haptic feedback effects are // short-lived, so we don't need to cancel when the process dies. performHapticFeedbackInternal( uid, deviceId, opPkg, constant, always, reason, /* token= */ this); } /** Loading
services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java +11 −0 Original line number Diff line number Diff line Loading @@ -1397,6 +1397,17 @@ public class VibratorManagerServiceTest { assertTrue(mVibratorProviders.get(1).getAllEffectSegments().isEmpty()); } @Test public void performHapticFeedback_usesServiceAsToken() throws Exception { VibratorManagerService service = createSystemReadyService(); HalVibration vibration = performHapticFeedbackAndWaitUntilFinished( service, HapticFeedbackConstants.SCROLL_TICK, /* always= */ true); assertTrue(vibration.callerToken == service); } @Test public void vibrate_withIntensitySettings_appliesSettingsToScaleVibrations() throws Exception { int defaultNotificationIntensity = Loading