diff options
author | Jeff Brown <jeffbrown@google.com> | 2015-02-24 18:53:21 -0800 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2015-02-25 17:04:13 -0800 |
commit | 6e53931f49f49245deef8622eb8e7dc6ccf04536 (patch) | |
tree | 0b7101049fca594901d09a089ba1f9588053cd1e /core/java/android/os | |
parent | ddd30928a7d8f410d7d13d5706da44ba20bac440 (diff) | |
download | frameworks_base-6e53931f49f49245deef8622eb8e7dc6ccf04536.zip frameworks_base-6e53931f49f49245deef8622eb8e7dc6ccf04536.tar.gz frameworks_base-6e53931f49f49245deef8622eb8e7dc6ccf04536.tar.bz2 |
Add Context.getSystemService(Class<?>).
Added an overload of getSystemService() that takes a class instead of a
service name to eliminate the extra cast and provide more type safety.
Cleaned up docs.
Removed the default constructor of BatteryManager which should not have
existed.
Change-Id: I9da46b20641fc83ecd3342560e5b94cb721f289c
Diffstat (limited to 'core/java/android/os')
-rw-r--r-- | core/java/android/os/BatteryManager.java | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/core/java/android/os/BatteryManager.java b/core/java/android/os/BatteryManager.java index 537e993..bd5a392 100644 --- a/core/java/android/os/BatteryManager.java +++ b/core/java/android/os/BatteryManager.java @@ -162,7 +162,15 @@ public class BatteryManager { */ public static final int BATTERY_PROPERTY_ENERGY_COUNTER = 5; - private IBatteryPropertiesRegistrar mBatteryPropertiesRegistrar; + private final IBatteryPropertiesRegistrar mBatteryPropertiesRegistrar; + + /** + * @removed Was previously made visible by accident. + */ + public BatteryManager() { + mBatteryPropertiesRegistrar = IBatteryPropertiesRegistrar.Stub.asInterface( + ServiceManager.getService("batteryproperties")); + } /** * Query a battery property from the batteryproperties service. @@ -174,12 +182,7 @@ public class BatteryManager { long ret; if (mBatteryPropertiesRegistrar == null) { - IBinder b = ServiceManager.getService("batteryproperties"); - mBatteryPropertiesRegistrar = - IBatteryPropertiesRegistrar.Stub.asInterface(b); - - if (mBatteryPropertiesRegistrar == null) - return Long.MIN_VALUE; + return Long.MIN_VALUE; } try { |