summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
author Lais Andrade <lsandrade@google.com> 2024-10-24 16:03:34 +0100
committer Lais Andrade <lsandrade@google.com> 2024-11-05 09:06:23 +0000
commit8c98628524b27f26b51ce8df09b6471b1978b43c (patch)
tree3443952224d9aef8faba82dfc7d1bb33249bea09 /tests
parent0b497fae7f4813e1e830f9199cad0e828a19052a (diff)
Introduce VendorVibrationSession
Introduce Vibrator APIs to start vendor vibration sessions. Vendor sessions will play vibration requests without resetting the vibrator hardware state, allowing the vendor to customize the behaviour between vibrations. Vibration sessions can be ended by the client app or by the vibrator service, allowing higher priority vibrations (e.g. ringtone, alarms) to take control of the vibrator and play as usual. Bug: 345414356 Test: FrameworksVibratorServicesTests Flag: android.os.vibrator.vendor_vibration_effects Change-Id: Id749cc240201bf398526c2416d5767a364b86cbf
Diffstat (limited to 'tests')
-rw-r--r--tests/permission/src/com/android/framework/permission/tests/VibratorManagerServicePermissionTest.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/permission/src/com/android/framework/permission/tests/VibratorManagerServicePermissionTest.java b/tests/permission/src/com/android/framework/permission/tests/VibratorManagerServicePermissionTest.java
index 07b733830bd3..0da4521fca71 100644
--- a/tests/permission/src/com/android/framework/permission/tests/VibratorManagerServicePermissionTest.java
+++ b/tests/permission/src/com/android/framework/permission/tests/VibratorManagerServicePermissionTest.java
@@ -143,6 +143,38 @@ public class VibratorManagerServicePermissionTest {
}
@Test
+ public void testStartVendorVibrationSessionWithoutVibratePermissionFails() throws Exception {
+ getInstrumentation().getUiAutomation().adoptShellPermissionIdentity(
+ Manifest.permission.VIBRATE_VENDOR_EFFECTS,
+ Manifest.permission.START_VIBRATION_SESSIONS);
+ expectSecurityException("VIBRATE");
+ mVibratorService.startVendorVibrationSession(Process.myUid(), DEVICE_ID, PACKAGE_NAME,
+ new int[] { 1 }, ATTRS, "testVibrate", null);
+ }
+
+ @Test
+ public void testStartVendorVibrationSessionWithoutVibrateVendorEffectsPermissionFails()
+ throws Exception {
+ getInstrumentation().getUiAutomation().adoptShellPermissionIdentity(
+ Manifest.permission.VIBRATE,
+ Manifest.permission.START_VIBRATION_SESSIONS);
+ expectSecurityException("VIBRATE");
+ mVibratorService.startVendorVibrationSession(Process.myUid(), DEVICE_ID, PACKAGE_NAME,
+ new int[] { 1 }, ATTRS, "testVibrate", null);
+ }
+
+ @Test
+ public void testStartVendorVibrationSessionWithoutStartSessionPermissionFails()
+ throws Exception {
+ getInstrumentation().getUiAutomation().adoptShellPermissionIdentity(
+ Manifest.permission.VIBRATE,
+ Manifest.permission.VIBRATE_VENDOR_EFFECTS);
+ expectSecurityException("VIBRATE");
+ mVibratorService.startVendorVibrationSession(Process.myUid(), DEVICE_ID, PACKAGE_NAME,
+ new int[] { 1 }, ATTRS, "testVibrate", null);
+ }
+
+ @Test
public void testCancelVibrateFails() throws RemoteException {
expectSecurityException("VIBRATE");
mVibratorService.cancelVibrate(/* usageFilter= */ -1, new Binder());