Merge "Added Ble scan APIs to BatteryStatsManager" am: 54c9ff981e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1750141 Change-Id: I9fc31acd57e674d4fa8abfc2c038bf2cb744178d
This commit is contained in:
@@ -6823,6 +6823,10 @@ package android.os {
|
|||||||
public final class BatteryStatsManager {
|
public final class BatteryStatsManager {
|
||||||
method @NonNull @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public android.os.connectivity.CellularBatteryStats getCellularBatteryStats();
|
method @NonNull @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public android.os.connectivity.CellularBatteryStats getCellularBatteryStats();
|
||||||
method @NonNull @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public android.os.connectivity.WifiBatteryStats getWifiBatteryStats();
|
method @NonNull @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public android.os.connectivity.WifiBatteryStats getWifiBatteryStats();
|
||||||
|
method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportBleScanReset();
|
||||||
|
method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportBleScanResults(@NonNull android.os.WorkSource, int);
|
||||||
|
method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportBleScanStarted(@NonNull android.os.WorkSource, boolean);
|
||||||
|
method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportBleScanStopped(@NonNull android.os.WorkSource, boolean);
|
||||||
method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportFullWifiLockAcquiredFromSource(@NonNull android.os.WorkSource);
|
method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportFullWifiLockAcquiredFromSource(@NonNull android.os.WorkSource);
|
||||||
method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportFullWifiLockReleasedFromSource(@NonNull android.os.WorkSource);
|
method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportFullWifiLockReleasedFromSource(@NonNull android.os.WorkSource);
|
||||||
method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportMobileRadioPowerState(boolean, int);
|
method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportMobileRadioPowerState(boolean, int);
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ public final class BatteryStatsManager {
|
|||||||
/**
|
/**
|
||||||
* Indicates that a new wifi scan has started.
|
* 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)
|
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
|
||||||
public void reportWifiScanStartedFromSource(@NonNull WorkSource ws) {
|
public void reportWifiScanStartedFromSource(@NonNull WorkSource ws) {
|
||||||
@@ -233,7 +233,7 @@ public final class BatteryStatsManager {
|
|||||||
/**
|
/**
|
||||||
* Indicates that an ongoing wifi scan has stopped.
|
* 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)
|
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
|
||||||
public void reportWifiScanStoppedFromSource(@NonNull WorkSource ws) {
|
public void reportWifiScanStoppedFromSource(@NonNull WorkSource ws) {
|
||||||
@@ -247,7 +247,7 @@ public final class BatteryStatsManager {
|
|||||||
/**
|
/**
|
||||||
* Indicates that a new wifi batched scan has started.
|
* 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.
|
* @param csph Channels scanned per hour.
|
||||||
*/
|
*/
|
||||||
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
|
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
|
||||||
@@ -263,7 +263,7 @@ public final class BatteryStatsManager {
|
|||||||
/**
|
/**
|
||||||
* Indicates that an ongoing wifi batched scan has stopped.
|
* 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)
|
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
|
||||||
public void reportWifiBatchedScanStoppedFromSource(@NonNull WorkSource ws) {
|
public void reportWifiBatchedScanStoppedFromSource(@NonNull WorkSource ws) {
|
||||||
@@ -307,7 +307,7 @@ public final class BatteryStatsManager {
|
|||||||
/**
|
/**
|
||||||
* Indicates an app acquiring full wifi lock.
|
* 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)
|
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
|
||||||
public void reportFullWifiLockAcquiredFromSource(@NonNull WorkSource ws) {
|
public void reportFullWifiLockAcquiredFromSource(@NonNull WorkSource ws) {
|
||||||
@@ -321,7 +321,7 @@ public final class BatteryStatsManager {
|
|||||||
/**
|
/**
|
||||||
* Indicates an app releasing full wifi lock.
|
* 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)
|
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
|
||||||
public void reportFullWifiLockReleasedFromSource(@NonNull WorkSource ws) {
|
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) {
|
private static int getDataConnectionPowerState(boolean isActive) {
|
||||||
// TODO: DataConnectionRealTimeInfo is under telephony package but the constants are used
|
// 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
|
// for both Wifi and mobile. It would make more sense to separate the constants to a
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ interface IBatteryStats {
|
|||||||
|
|
||||||
void noteBleScanStarted(in WorkSource ws, boolean isUnoptimized);
|
void noteBleScanStarted(in WorkSource ws, boolean isUnoptimized);
|
||||||
void noteBleScanStopped(in WorkSource ws, boolean isUnoptimized);
|
void noteBleScanStopped(in WorkSource ws, boolean isUnoptimized);
|
||||||
void noteResetBleScan();
|
void noteBleScanReset();
|
||||||
void noteBleScanResults(in WorkSource ws, int numNewResults);
|
void noteBleScanResults(in WorkSource ws, int numNewResults);
|
||||||
|
|
||||||
/** {@hide} */
|
/** {@hide} */
|
||||||
|
|||||||
@@ -1164,7 +1164,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void noteResetBleScan() {
|
public void noteBleScanReset() {
|
||||||
enforceCallingPermission();
|
enforceCallingPermission();
|
||||||
synchronized (mStats) {
|
synchronized (mStats) {
|
||||||
mStats.noteResetBluetoothScanLocked();
|
mStats.noteResetBluetoothScanLocked();
|
||||||
|
|||||||
Reference in New Issue
Block a user