summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerController2Test.java21
-rw-r--r--services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerControllerTest.java21
-rw-r--r--tests/testables/src/android/testing/TestableSettingsProvider.java6
3 files changed, 25 insertions, 23 deletions
diff --git a/services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerController2Test.java b/services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerController2Test.java
index a6872ba63157..ca857f121624 100644
--- a/services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerController2Test.java
+++ b/services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerController2Test.java
@@ -49,7 +49,6 @@ import android.os.Handler;
import android.os.Looper;
import android.os.PowerManager;
import android.os.SystemProperties;
-import android.os.UserHandle;
import android.os.test.TestLooper;
import android.provider.Settings;
import android.testing.TestableContext;
@@ -140,9 +139,9 @@ public final class DisplayPowerController2Test {
// Put the system into manual brightness by default, just to minimize unexpected events and
// have a consistent starting state
- Settings.System.putIntForUser(mContext.getContentResolver(),
+ Settings.System.putInt(mContext.getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS_MODE,
- Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, UserHandle.USER_CURRENT);
+ Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
addLocalServiceMock(WindowManagerPolicy.class, mWindowManagerPolicyMock);
addLocalServiceMock(ColorDisplayService.ColorDisplayServiceInternal.class,
@@ -422,9 +421,9 @@ public final class DisplayPowerController2Test {
@Test
public void testDisplayBrightnessFollowers_AutomaticBrightness() {
- Settings.System.putIntForUser(mContext.getContentResolver(),
+ Settings.System.putInt(mContext.getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS_MODE,
- Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC, UserHandle.USER_CURRENT);
+ Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
final float brightness = 0.4f;
final float nits = 300;
final float ambientLux = 3000;
@@ -541,9 +540,9 @@ public final class DisplayPowerController2Test {
@Test
public void testSetScreenOffBrightnessSensorEnabled_DisplayIsOff() {
- Settings.System.putIntForUser(mContext.getContentResolver(),
+ Settings.System.putInt(mContext.getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS_MODE,
- Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC, UserHandle.USER_CURRENT);
+ Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
DisplayPowerRequest dpr = new DisplayPowerRequest();
dpr.policy = DisplayPowerRequest.POLICY_OFF;
@@ -574,9 +573,9 @@ public final class DisplayPowerController2Test {
@Test
public void testSetScreenOffBrightnessSensorEnabled_DisplayIsInDoze() {
- Settings.System.putIntForUser(mContext.getContentResolver(),
+ Settings.System.putInt(mContext.getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS_MODE,
- Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC, UserHandle.USER_CURRENT);
+ Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
DisplayPowerRequest dpr = new DisplayPowerRequest();
dpr.policy = DisplayPowerRequest.POLICY_DOZE;
@@ -621,9 +620,9 @@ public final class DisplayPowerController2Test {
@Test
public void testSetScreenOffBrightnessSensorDisabled_DisplayIsDisabled() {
- Settings.System.putIntForUser(mContext.getContentResolver(),
+ Settings.System.putInt(mContext.getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS_MODE,
- Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC, UserHandle.USER_CURRENT);
+ Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
mHolder = createDisplayPowerController(DISPLAY_ID, UNIQUE_ID, /* isEnabled= */ false);
DisplayPowerRequest dpr = new DisplayPowerRequest();
diff --git a/services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerControllerTest.java b/services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerControllerTest.java
index 6f4be334400a..0b97c5cb6ca1 100644
--- a/services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerControllerTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerControllerTest.java
@@ -49,7 +49,6 @@ import android.os.Handler;
import android.os.Looper;
import android.os.PowerManager;
import android.os.SystemProperties;
-import android.os.UserHandle;
import android.os.test.TestLooper;
import android.provider.Settings;
import android.testing.TestableContext;
@@ -141,9 +140,9 @@ public final class DisplayPowerControllerTest {
// Put the system into manual brightness by default, just to minimize unexpected events and
// have a consistent starting state
- Settings.System.putIntForUser(mContext.getContentResolver(),
+ Settings.System.putInt(mContext.getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS_MODE,
- Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, UserHandle.USER_CURRENT);
+ Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
addLocalServiceMock(WindowManagerPolicy.class, mWindowManagerPolicyMock);
@@ -426,9 +425,9 @@ public final class DisplayPowerControllerTest {
@Test
public void testDisplayBrightnessFollowers_AutomaticBrightness() {
- Settings.System.putIntForUser(mContext.getContentResolver(),
+ Settings.System.putInt(mContext.getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS_MODE,
- Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC, UserHandle.USER_CURRENT);
+ Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
final float brightness = 0.4f;
final float nits = 300;
final float ambientLux = 3000;
@@ -546,9 +545,9 @@ public final class DisplayPowerControllerTest {
@Test
public void testSetScreenOffBrightnessSensorEnabled_DisplayIsOff() {
- Settings.System.putIntForUser(mContext.getContentResolver(),
+ Settings.System.putInt(mContext.getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS_MODE,
- Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC, UserHandle.USER_CURRENT);
+ Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
DisplayPowerRequest dpr = new DisplayPowerRequest();
dpr.policy = DisplayPowerRequest.POLICY_OFF;
@@ -579,9 +578,9 @@ public final class DisplayPowerControllerTest {
@Test
public void testSetScreenOffBrightnessSensorEnabled_DisplayIsInDoze() {
- Settings.System.putIntForUser(mContext.getContentResolver(),
+ Settings.System.putInt(mContext.getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS_MODE,
- Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC, UserHandle.USER_CURRENT);
+ Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
DisplayPowerRequest dpr = new DisplayPowerRequest();
dpr.policy = DisplayPowerRequest.POLICY_DOZE;
@@ -626,9 +625,9 @@ public final class DisplayPowerControllerTest {
@Test
public void testSetScreenOffBrightnessSensorDisabled_DisplayIsDisabled() {
- Settings.System.putIntForUser(mContext.getContentResolver(),
+ Settings.System.putInt(mContext.getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS_MODE,
- Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC, UserHandle.USER_CURRENT);
+ Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
mHolder = createDisplayPowerController(DISPLAY_ID, UNIQUE_ID, /* isEnabled= */ false);
diff --git a/tests/testables/src/android/testing/TestableSettingsProvider.java b/tests/testables/src/android/testing/TestableSettingsProvider.java
index c6f18fd453c5..b850cb8e6dfd 100644
--- a/tests/testables/src/android/testing/TestableSettingsProvider.java
+++ b/tests/testables/src/android/testing/TestableSettingsProvider.java
@@ -72,7 +72,11 @@ public class TestableSettingsProvider extends MockContentProvider {
public Bundle call(String method, String arg, Bundle extras) {
// Methods are "GET_system", "GET_global", "PUT_secure", etc.
- final int userId = extras.getInt(Settings.CALL_METHOD_USER_KEY, UserHandle.myUserId());
+ int userId = extras.getInt(Settings.CALL_METHOD_USER_KEY, UserHandle.USER_CURRENT);
+ if (userId == UserHandle.USER_CURRENT || userId == UserHandle.USER_CURRENT_OR_SELF) {
+ userId = UserHandle.myUserId();
+ }
+
final String[] commands = method.split("_", 2);
final String op = commands[0];
final String table = commands[1];