diff options
| author | Etienne Ruffieux <eruffieux@google.com> | 2021-06-28 19:45:39 +0000 |
|---|---|---|
| committer | Etienne Ruffieux <eruffieux@google.com> | 2021-07-15 16:40:57 +0000 |
| commit | 29cb9a7c901287c6ad854155e0d62d6cd9472eaa (patch) | |
| tree | db38854a2ca3deb9296014b7c8cf2eed1cbe0a3f /core/java/android | |
| parent | 2f3d6bc5932027ec425d1cf0fbdac06aac85455b (diff) | |
Added Ble scan APIs to BatteryStatsManager
Added missing service functions to manager to prevent directly
calling BatteryStatsService from Bluetooth package. Updated
system-current.txt accordingly.
Tag: #feature
Bug: 190442794
Test: Manual
Merged-In: Ie6c6d3688d2da45956d57ea1dbc2cc4430f27783
Change-Id: Ie6c6d3688d2da45956d57ea1dbc2cc4430f27783
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/os/BatteryStatsManager.java | 69 |
1 files changed, 63 insertions, 6 deletions
diff --git a/core/java/android/os/BatteryStatsManager.java b/core/java/android/os/BatteryStatsManager.java index f5172cf0fb69..16034df942db 100644 --- a/core/java/android/os/BatteryStatsManager.java +++ b/core/java/android/os/BatteryStatsManager.java @@ -219,7 +219,7 @@ public final class BatteryStatsManager { /** * Indicates that a new wifi scan has started. * - * @param ws Worksource (to be used for battery blaming). + * @param ws worksource (to be used for battery blaming). */ @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportWifiScanStartedFromSource(@NonNull WorkSource ws) { @@ -233,7 +233,7 @@ public final class BatteryStatsManager { /** * Indicates that an ongoing wifi scan has stopped. * - * @param ws Worksource (to be used for battery blaming). + * @param ws worksource (to be used for battery blaming). */ @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportWifiScanStoppedFromSource(@NonNull WorkSource ws) { @@ -247,7 +247,7 @@ public final class BatteryStatsManager { /** * Indicates that a new wifi batched scan has started. * - * @param ws Worksource (to be used for battery blaming). + * @param ws worksource (to be used for battery blaming). * @param csph Channels scanned per hour. */ @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) @@ -263,7 +263,7 @@ public final class BatteryStatsManager { /** * Indicates that an ongoing wifi batched scan has stopped. * - * @param ws Worksource (to be used for battery blaming). + * @param ws worksource (to be used for battery blaming). */ @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportWifiBatchedScanStoppedFromSource(@NonNull WorkSource ws) { @@ -307,7 +307,7 @@ public final class BatteryStatsManager { /** * Indicates an app acquiring full wifi lock. * - * @param ws Worksource (to be used for battery blaming). + * @param ws worksource (to be used for battery blaming). */ @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportFullWifiLockAcquiredFromSource(@NonNull WorkSource ws) { @@ -321,7 +321,7 @@ public final class BatteryStatsManager { /** * Indicates an app releasing full wifi lock. * - * @param ws Worksource (to be used for battery blaming). + * @param ws worksource (to be used for battery blaming). */ @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportFullWifiLockReleasedFromSource(@NonNull WorkSource ws) { @@ -436,6 +436,63 @@ public final class BatteryStatsManager { } } + /** + * Indicates that a new Bluetooth LE scan has started. + * + * @param ws worksource (to be used for battery blaming). + * @param isUnoptimized whether or not the scan has a filter. + */ + @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) + public void reportBleScanStarted(@NonNull WorkSource ws, boolean isUnoptimized) { + try { + mBatteryStats.noteBleScanStarted(ws, isUnoptimized); + } catch (RemoteException e) { + e.rethrowFromSystemServer(); + } + } + + /** + * Indicates that an ongoing Bluetooth LE scan has stopped. + * + * @param ws worksource (to be used for battery blaming). + * @param isUnoptimized whether or not the scan has a filter. + */ + @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) + public void reportBleScanStopped(@NonNull WorkSource ws, boolean isUnoptimized) { + try { + mBatteryStats.noteBleScanStopped(ws, isUnoptimized); + } catch (RemoteException e) { + e.rethrowFromSystemServer(); + } + } + + /** + * Indicates that Bluetooth LE has been reset. + */ + @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) + public void reportBleScanReset() { + try { + mBatteryStats.noteBleScanReset(); + } catch (RemoteException e) { + e.rethrowFromSystemServer(); + } + } + + /** + * Indicates that Bluetooth LE scan has received new results. + * + * @param ws worksource (to be used for battery blaming). + * @param numNewResults number of results received since last update. + */ + @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) + public void reportBleScanResults(@NonNull WorkSource ws, int numNewResults) { + try { + mBatteryStats.noteBleScanResults(ws, numNewResults); + } catch (RemoteException e) { + e.rethrowFromSystemServer(); + } + } + private static int getDataConnectionPowerState(boolean isActive) { // TODO: DataConnectionRealTimeInfo is under telephony package but the constants are used // for both Wifi and mobile. It would make more sense to separate the constants to a |
