diff options
author | Sunny Shao <sunnyshao@google.com> | 2020-03-09 10:26:04 +0800 |
---|---|---|
committer | Sunny Shao <sunnyshao@google.com> | 2020-03-09 02:30:34 +0000 |
commit | 276c0bf1407d7db7fe63c7373307cb6b4440c95b (patch) | |
tree | 7cc3c2c43138fb9d39efa703bdefea69a4e5aa11 | |
parent | 91ec756306014ea0aeccc850a1796c3b796f6b24 (diff) | |
download | platform_external_robolectric-shadows-276c0bf1407d7db7fe63c7373307cb6b4440c95b.tar.gz platform_external_robolectric-shadows-276c0bf1407d7db7fe63c7373307cb6b4440c95b.tar.bz2 platform_external_robolectric-shadows-276c0bf1407d7db7fe63c7373307cb6b4440c95b.zip |
Create the context.getSystemService(Context.POWER_SERVICE)
failed in the Roboletric test case
root cause : ServiceManager.getServiceOrThrow(Context.THERMAL_SERVICE)
created failed when creates power service.
solution: Add the thermal service in the ShadowServiceManager.
Fixes: 151047301
Bug: 150907639
Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.DisplaySettingsTest
Change-Id: I611b7b2eceedcf5785c015ba71c5f9b02615d7e3
-rw-r--r-- | shadows/framework/src/main/java/org/robolectric/shadows/ShadowServiceManager.java | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowServiceManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowServiceManager.java index 1916e34cc..41b3f9cb0 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowServiceManager.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowServiceManager.java @@ -47,6 +47,7 @@ import android.os.IBatteryPropertiesRegistrar; import android.os.IBinder; import android.os.IInterface; import android.os.IPowerManager; +import android.os.IThermalService; import android.os.IUserManager; import android.os.RemoteException; import android.os.ServiceManager; @@ -204,6 +205,8 @@ public class ShadowServiceManager { if (RuntimeEnvironment.getApiLevel() >= R) { map.put(Context.TETHERING_SERVICE, createBinder(ITetheringConnector.class, "android.net.ITetheringConnector")); + map.put(Context.THERMAL_SERVICE, + createBinder(IThermalService.class, "android.os.IThermalService")); } // END-INTERNAL SERVICES = Collections.unmodifiableMap(map); |