Loading core/java/android/os/health/SystemHealthManager.java +22 −8 Original line number Diff line number Diff line Loading @@ -473,6 +473,8 @@ public class SystemHealthManager { } } switch (result.resultCode) { case IBatteryStats.RESULT_OK: { final HealthStats[] results = new HealthStats[uids.length]; if (result.bundle != null) { HealthStatsParceler[] parcelers = result.bundle.getParcelableArray( Loading @@ -485,6 +487,18 @@ public class SystemHealthManager { } return results; } case IBatteryStats.RESULT_SECURITY_EXCEPTION: { throw new SecurityException(result.bundle != null ? result.bundle.getString(IBatteryStats.KEY_EXCEPTION_MESSAGE) : null); } case IBatteryStats.RESULT_RUNTIME_EXCEPTION: { throw new RuntimeException(result.bundle != null ? result.bundle.getString(IBatteryStats.KEY_EXCEPTION_MESSAGE) : null); } default: throw new RuntimeException("Error code: " + result.resultCode); } } /** * Asynchronously retrieves a list of supported {@link PowerMonitor}'s, which include raw ODPM Loading core/java/com/android/internal/app/IBatteryStats.aidl +12 −0 Original line number Diff line number Diff line Loading @@ -34,9 +34,21 @@ import android.telephony.ModemActivityInfo; import android.telephony.SignalStrength; interface IBatteryStats { /** @hide */ const int RESULT_OK = 0; /** @hide */ const int RESULT_RUNTIME_EXCEPTION = 1; /** @hide */ const int RESULT_SECURITY_EXCEPTION = 2; /** @hide */ const String KEY_UID_SNAPSHOTS = "uid_snapshots"; /** @hide */ const String KEY_EXCEPTION_MESSAGE = "exception"; // These first methods are also called by native code, so must // be kept in sync with frameworks/native/libs/binder/include_batterystats/batterystats/IBatteryStats.h @EnforcePermission("UPDATE_DEVICE_STATS") Loading services/core/java/com/android/server/am/BatteryStatsService.java +11 −4 Original line number Diff line number Diff line Loading @@ -3705,8 +3705,14 @@ public final class BatteryStatsService extends IBatteryStats.Stub @Override public void takeUidSnapshotsAsync(int[] requestUids, ResultReceiver resultReceiver) { if (!onlyCaller(requestUids)) { try { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.BATTERY_STATS, null); } catch (SecurityException ex) { resultReceiver.send(IBatteryStats.RESULT_SECURITY_EXCEPTION, Bundle.forPair(IBatteryStats.KEY_EXCEPTION_MESSAGE, ex.getMessage())); return; } } if (shouldCollectExternalStats()) { Loading @@ -3727,13 +3733,14 @@ public final class BatteryStatsService extends IBatteryStats.Stub } Bundle resultData = new Bundle(1); resultData.putParcelableArray(IBatteryStats.KEY_UID_SNAPSHOTS, results); resultReceiver.send(0, resultData); resultReceiver.send(IBatteryStats.RESULT_OK, resultData); } catch (Exception ex) { if (DBG) { Slog.d(TAG, "Crashed while returning results for takeUidSnapshots(" + Arrays.toString(requestUids) + ") i=" + i, ex); } throw ex; resultReceiver.send(IBatteryStats.RESULT_RUNTIME_EXCEPTION, Bundle.forPair(IBatteryStats.KEY_EXCEPTION_MESSAGE, ex.getMessage())); } finally { Binder.restoreCallingIdentity(ident); } Loading Loading
core/java/android/os/health/SystemHealthManager.java +22 −8 Original line number Diff line number Diff line Loading @@ -473,6 +473,8 @@ public class SystemHealthManager { } } switch (result.resultCode) { case IBatteryStats.RESULT_OK: { final HealthStats[] results = new HealthStats[uids.length]; if (result.bundle != null) { HealthStatsParceler[] parcelers = result.bundle.getParcelableArray( Loading @@ -485,6 +487,18 @@ public class SystemHealthManager { } return results; } case IBatteryStats.RESULT_SECURITY_EXCEPTION: { throw new SecurityException(result.bundle != null ? result.bundle.getString(IBatteryStats.KEY_EXCEPTION_MESSAGE) : null); } case IBatteryStats.RESULT_RUNTIME_EXCEPTION: { throw new RuntimeException(result.bundle != null ? result.bundle.getString(IBatteryStats.KEY_EXCEPTION_MESSAGE) : null); } default: throw new RuntimeException("Error code: " + result.resultCode); } } /** * Asynchronously retrieves a list of supported {@link PowerMonitor}'s, which include raw ODPM Loading
core/java/com/android/internal/app/IBatteryStats.aidl +12 −0 Original line number Diff line number Diff line Loading @@ -34,9 +34,21 @@ import android.telephony.ModemActivityInfo; import android.telephony.SignalStrength; interface IBatteryStats { /** @hide */ const int RESULT_OK = 0; /** @hide */ const int RESULT_RUNTIME_EXCEPTION = 1; /** @hide */ const int RESULT_SECURITY_EXCEPTION = 2; /** @hide */ const String KEY_UID_SNAPSHOTS = "uid_snapshots"; /** @hide */ const String KEY_EXCEPTION_MESSAGE = "exception"; // These first methods are also called by native code, so must // be kept in sync with frameworks/native/libs/binder/include_batterystats/batterystats/IBatteryStats.h @EnforcePermission("UPDATE_DEVICE_STATS") Loading
services/core/java/com/android/server/am/BatteryStatsService.java +11 −4 Original line number Diff line number Diff line Loading @@ -3705,8 +3705,14 @@ public final class BatteryStatsService extends IBatteryStats.Stub @Override public void takeUidSnapshotsAsync(int[] requestUids, ResultReceiver resultReceiver) { if (!onlyCaller(requestUids)) { try { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.BATTERY_STATS, null); } catch (SecurityException ex) { resultReceiver.send(IBatteryStats.RESULT_SECURITY_EXCEPTION, Bundle.forPair(IBatteryStats.KEY_EXCEPTION_MESSAGE, ex.getMessage())); return; } } if (shouldCollectExternalStats()) { Loading @@ -3727,13 +3733,14 @@ public final class BatteryStatsService extends IBatteryStats.Stub } Bundle resultData = new Bundle(1); resultData.putParcelableArray(IBatteryStats.KEY_UID_SNAPSHOTS, results); resultReceiver.send(0, resultData); resultReceiver.send(IBatteryStats.RESULT_OK, resultData); } catch (Exception ex) { if (DBG) { Slog.d(TAG, "Crashed while returning results for takeUidSnapshots(" + Arrays.toString(requestUids) + ") i=" + i, ex); } throw ex; resultReceiver.send(IBatteryStats.RESULT_RUNTIME_EXCEPTION, Bundle.forPair(IBatteryStats.KEY_EXCEPTION_MESSAGE, ex.getMessage())); } finally { Binder.restoreCallingIdentity(ident); } Loading