diff options
Diffstat (limited to 'tests')
3 files changed, 23 insertions, 22 deletions
diff --git a/tests/AndroidTests/src/com/android/unit_tests/os/PowerManagerTest.java b/tests/AndroidTests/src/com/android/unit_tests/os/PowerManagerTest.java index bd5c955..2f1a738 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/os/PowerManagerTest.java +++ b/tests/AndroidTests/src/com/android/unit_tests/os/PowerManagerTest.java @@ -63,6 +63,8 @@ public class PowerManagerTest extends AndroidTestCase { wl = mPm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "PARTIAL_WAKE_LOCK"); doTestWakeLock(wl); + doTestSetBacklightBrightness(); + // TODO: Some sort of functional test (maybe not in the unit test here?) // that confirms that things are really happening e.g. screen power, keyboard power. } @@ -121,5 +123,20 @@ public class PowerManagerTest extends AndroidTestCase { // TODO: Threaded test (needs handler) to make sure timed wakelocks work too } - + + /** + * Test that calling {@link android.os.IHardwareService#setBacklights(int)} requires + * permissions. + * <p>Tests permission: + * {@link android.Manifest.permission#DEVICE_POWER} + */ + private void doTestSetBacklightBrightness() { + try { + mPm.setBacklightBrightness(0); + fail("setBacklights did not throw SecurityException as expected"); + } catch (SecurityException e) { + // expected + } + } + } diff --git a/tests/FrameworkTest/src/com/android/frameworktest/settings/BrightnessLimit.java b/tests/FrameworkTest/src/com/android/frameworktest/settings/BrightnessLimit.java index 5644044..6d5996c 100644 --- a/tests/FrameworkTest/src/com/android/frameworktest/settings/BrightnessLimit.java +++ b/tests/FrameworkTest/src/com/android/frameworktest/settings/BrightnessLimit.java @@ -16,7 +16,7 @@ package com.android.frameworktest.settings; -import android.os.IHardwareService; +import android.os.IPowerManager; import android.app.Activity; import android.os.Bundle; @@ -45,11 +45,11 @@ public class BrightnessLimit extends Activity implements OnClickListener { } public void onClick(View v) { - IHardwareService hardware = IHardwareService.Stub.asInterface( - ServiceManager.getService("hardware")); - if (hardware != null) { + IPowerManager power = IPowerManager.Stub.asInterface( + ServiceManager.getService("power")); + if (power != null) { try { - hardware.setBacklights(0); + power.setBacklightBrightness(0); } catch (RemoteException darn) { } diff --git a/tests/permission/src/com/android/framework/permission/tests/HardwareServicePermissionTest.java b/tests/permission/src/com/android/framework/permission/tests/HardwareServicePermissionTest.java index aebd68c..2290c1d 100644 --- a/tests/permission/src/com/android/framework/permission/tests/HardwareServicePermissionTest.java +++ b/tests/permission/src/com/android/framework/permission/tests/HardwareServicePermissionTest.java @@ -117,20 +117,4 @@ public class HardwareServicePermissionTest extends TestCase { // expected } } - - /** - * Test that calling {@link android.os.IHardwareService#setBacklights(int)} requires - * permissions. - * <p>Tests permission: - * {@link android.Manifest.permission#HARDWARE_TEST} - * @throws RemoteException - */ - public void testSetBacklights() throws RemoteException { - try { - mHardwareService.setBacklights(0); - fail("setBacklights did not throw SecurityException as expected"); - } catch (SecurityException e) { - // expected - } - } } |