Loading services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerController2Test.java +10 −11 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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, Loading Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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(); Loading services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerControllerTest.java +10 −11 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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); Loading tests/testables/src/android/testing/TestableSettingsProvider.java +5 −1 Original line number Diff line number Diff line Loading @@ -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]; Loading Loading
services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerController2Test.java +10 −11 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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, Loading Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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(); Loading
services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerControllerTest.java +10 −11 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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); Loading
tests/testables/src/android/testing/TestableSettingsProvider.java +5 −1 Original line number Diff line number Diff line Loading @@ -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]; Loading