am 30348b0d
: Merge change I086d681f into eclair-mr2
Merge commit '30348b0de11b6c6cba43dfc7960e4d2084af6d8b' into eclair-mr2-plus-aosp * commit '30348b0de11b6c6cba43dfc7960e4d2084af6d8b': Remove HardwareService and move vibrator support to VibratorService.
This commit is contained in:
@ -19,7 +19,7 @@ package com.android.framework.permission.tests;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import android.os.Binder;
|
||||
import android.os.IHardwareService;
|
||||
import android.os.IVibratorService;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
@ -28,25 +28,25 @@ import android.test.suitebuilder.annotation.SmallTest;
|
||||
* Verify that Hardware apis cannot be called without required permissions.
|
||||
*/
|
||||
@SmallTest
|
||||
public class HardwareServicePermissionTest extends TestCase {
|
||||
public class VibratorServicePermissionTest extends TestCase {
|
||||
|
||||
private IHardwareService mHardwareService;
|
||||
private IVibratorService mVibratorService;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
mHardwareService = IHardwareService.Stub.asInterface(
|
||||
ServiceManager.getService("hardware"));
|
||||
mVibratorService = IVibratorService.Stub.asInterface(
|
||||
ServiceManager.getService("vibrator"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that calling {@link android.os.IHardwareService#vibrate(long)} requires permissions.
|
||||
* Test that calling {@link android.os.IVibratorService#vibrate(long)} requires permissions.
|
||||
* <p>Tests permission:
|
||||
* {@link android.Manifest.permission#VIBRATE}
|
||||
* @throws RemoteException
|
||||
*/
|
||||
public void testVibrate() throws RemoteException {
|
||||
try {
|
||||
mHardwareService.vibrate(2000, new Binder());
|
||||
mVibratorService.vibrate(2000, new Binder());
|
||||
fail("vibrate did not throw SecurityException as expected");
|
||||
} catch (SecurityException e) {
|
||||
// expected
|
||||
@ -54,7 +54,7 @@ public class HardwareServicePermissionTest extends TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that calling {@link android.os.IHardwareService#vibratePattern(long[],
|
||||
* Test that calling {@link android.os.IVibratorService#vibratePattern(long[],
|
||||
* int, android.os.IBinder)} requires permissions.
|
||||
* <p>Tests permission:
|
||||
* {@link android.Manifest.permission#VIBRATE}
|
||||
@ -62,7 +62,7 @@ public class HardwareServicePermissionTest extends TestCase {
|
||||
*/
|
||||
public void testVibratePattern() throws RemoteException {
|
||||
try {
|
||||
mHardwareService.vibratePattern(new long[] {0}, 0, new Binder());
|
||||
mVibratorService.vibratePattern(new long[] {0}, 0, new Binder());
|
||||
fail("vibratePattern did not throw SecurityException as expected");
|
||||
} catch (SecurityException e) {
|
||||
// expected
|
||||
@ -70,51 +70,17 @@ public class HardwareServicePermissionTest extends TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that calling {@link android.os.IHardwareService#cancelVibrate()} requires permissions.
|
||||
* Test that calling {@link android.os.IVibratorService#cancelVibrate()} requires permissions.
|
||||
* <p>Tests permission:
|
||||
* {@link android.Manifest.permission#VIBRATE}
|
||||
* @throws RemoteException
|
||||
*/
|
||||
public void testCancelVibrate() throws RemoteException {
|
||||
try {
|
||||
mHardwareService.cancelVibrate(new Binder());
|
||||
mVibratorService.cancelVibrate(new Binder());
|
||||
fail("cancelVibrate did not throw SecurityException as expected");
|
||||
} catch (SecurityException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that calling {@link android.os.IHardwareService#setFlashlightEnabled(boolean)}
|
||||
* requires permissions.
|
||||
* <p>Tests permissions:
|
||||
* {@link android.Manifest.permission#HARDWARE_TEST}
|
||||
* {@link android.Manifest.permission#FLASHLIGHT}
|
||||
* @throws RemoteException
|
||||
*/
|
||||
public void testSetFlashlightEnabled() throws RemoteException {
|
||||
try {
|
||||
mHardwareService.setFlashlightEnabled(true);
|
||||
fail("setFlashlightEnabled did not throw SecurityException as expected");
|
||||
} catch (SecurityException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that calling {@link android.os.IHardwareService#enableCameraFlash(int)} requires
|
||||
* permissions.
|
||||
* <p>Tests permission:
|
||||
* {@link android.Manifest.permission#HARDWARE_TEST}
|
||||
* {@link android.Manifest.permission#CAMERA}
|
||||
* @throws RemoteException
|
||||
*/
|
||||
public void testEnableCameraFlash() throws RemoteException {
|
||||
try {
|
||||
mHardwareService.enableCameraFlash(100);
|
||||
fail("enableCameraFlash did not throw SecurityException as expected");
|
||||
} catch (SecurityException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user