diff options
author | 2020-12-11 19:45:42 +0000 | |
---|---|---|
committer | 2021-02-11 09:26:21 +0000 | |
commit | 55a0aebe7f1426a08dbe234ee65657b07846b430 (patch) | |
tree | 23ae7ee630c2f6a779da23efdffebd43a04acfa4 /tests/permission/src | |
parent | c4f27f30200470e705a9eecc838e31b120a65fee (diff) |
Introduce SystemVibratorManager
Add default system implementation of vibrator manager service that uses
IVibratorManagerService to access the device vibrators.
Change implementation of SystemVibrator to use VibratorManagerService
and delete local service VibratorService.
Introduce missing public APIs for VibratorManager and Vibrator.getId.
Bug: 167946816
Test: VibratorManagerServiceTest, VibratorTest, VibrationEffectTest
Change-Id: I55cdeb72c7ca39ccf0c7b2fda60b16de1031801e
Diffstat (limited to 'tests/permission/src')
-rw-r--r-- | tests/permission/src/com/android/framework/permission/tests/VibratorManagerServicePermissionTest.java (renamed from tests/permission/src/com/android/framework/permission/tests/VibratorServicePermissionTest.java) | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/tests/permission/src/com/android/framework/permission/tests/VibratorServicePermissionTest.java b/tests/permission/src/com/android/framework/permission/tests/VibratorManagerServicePermissionTest.java index d1d6a26790fd..0f920b36cffd 100644 --- a/tests/permission/src/com/android/framework/permission/tests/VibratorServicePermissionTest.java +++ b/tests/permission/src/com/android/framework/permission/tests/VibratorManagerServicePermissionTest.java @@ -16,8 +16,11 @@ package com.android.framework.permission.tests; +import android.content.Context; import android.os.Binder; -import android.os.IVibratorService; +import android.os.CombinedVibrationEffect; +import android.os.IBinder; +import android.os.IVibratorManagerService; import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; @@ -32,27 +35,28 @@ import junit.framework.TestCase; * Verify that Hardware apis cannot be called without required permissions. */ @SmallTest -public class VibratorServicePermissionTest extends TestCase { +public class VibratorManagerServicePermissionTest extends TestCase { - private IVibratorService mVibratorService; + private IVibratorManagerService mVibratorService; @Override protected void setUp() throws Exception { - mVibratorService = IVibratorService.Stub.asInterface( - ServiceManager.getService("vibrator")); + mVibratorService = IVibratorManagerService.Stub.asInterface( + ServiceManager.getService(Context.VIBRATOR_MANAGER_SERVICE)); } /** - * Test that calling {@link android.os.IVibratorService#vibrate(long)} requires permissions. + * Test that calling {@link android.os.IVibratorManagerService#vibrate(int, String, + * CombinedVibrationEffect, VibrationAttributes, String, IBinder)} requires permissions. * <p>Tests permission: - * {@link android.Manifest.permission#VIBRATE} - * @throws RemoteException + * {@link android.Manifest.permission#VIBRATE} */ public void testVibrate() throws RemoteException { try { - final VibrationEffect effect = - VibrationEffect.createOneShot(100, VibrationEffect.DEFAULT_AMPLITUDE); - final VibrationAttributes attrs = new VibrationAttributes.Builder() + CombinedVibrationEffect effect = + CombinedVibrationEffect.createSynced( + VibrationEffect.createOneShot(100, VibrationEffect.DEFAULT_AMPLITUDE)); + VibrationAttributes attrs = new VibrationAttributes.Builder() .setUsage(VibrationAttributes.USAGE_ALARM) .build(); mVibratorService.vibrate(Process.myUid(), null, effect, attrs, @@ -64,10 +68,10 @@ public class VibratorServicePermissionTest extends TestCase { } /** - * Test that calling {@link android.os.IVibratorService#cancelVibrate()} requires permissions. + * Test that calling {@link android.os.IVibratorManagerService#cancelVibrate(IBinder)} requires + * permissions. * <p>Tests permission: - * {@link android.Manifest.permission#VIBRATE} - * @throws RemoteException + * {@link android.Manifest.permission#VIBRATE} */ public void testCancelVibrate() throws RemoteException { try { |