am d5e5151f: Merge "Bluetooth energy: fix overflow in calculation" into mnc-dev
* commit 'd5e5151f6ceab498e3a35928c1f6f7a177c1544e': Bluetooth energy: fix overflow in calculation
This commit is contained in:
@@ -28,10 +28,10 @@ import android.os.Parcelable;
|
||||
public final class BluetoothActivityEnergyInfo implements Parcelable {
|
||||
private final long mTimestamp;
|
||||
private final int mBluetoothStackState;
|
||||
private final int mControllerTxTimeMs;
|
||||
private final int mControllerRxTimeMs;
|
||||
private final int mControllerIdleTimeMs;
|
||||
private final int mControllerEnergyUsed;
|
||||
private final long mControllerTxTimeMs;
|
||||
private final long mControllerRxTimeMs;
|
||||
private final long mControllerIdleTimeMs;
|
||||
private final long mControllerEnergyUsed;
|
||||
|
||||
public static final int BT_STACK_STATE_INVALID = 0;
|
||||
public static final int BT_STACK_STATE_STATE_ACTIVE = 1;
|
||||
@@ -39,7 +39,7 @@ public final class BluetoothActivityEnergyInfo implements Parcelable {
|
||||
public static final int BT_STACK_STATE_STATE_IDLE = 3;
|
||||
|
||||
public BluetoothActivityEnergyInfo(long timestamp, int stackState,
|
||||
int txTime, int rxTime, int idleTime, int energyUsed) {
|
||||
long txTime, long rxTime, long idleTime, long energyUsed) {
|
||||
mTimestamp = timestamp;
|
||||
mBluetoothStackState = stackState;
|
||||
mControllerTxTimeMs = txTime;
|
||||
@@ -65,10 +65,10 @@ public final class BluetoothActivityEnergyInfo implements Parcelable {
|
||||
public BluetoothActivityEnergyInfo createFromParcel(Parcel in) {
|
||||
long timestamp = in.readLong();
|
||||
int stackState = in.readInt();
|
||||
int txTime = in.readInt();
|
||||
int rxTime = in.readInt();
|
||||
int idleTime = in.readInt();
|
||||
int energyUsed = in.readInt();
|
||||
long txTime = in.readLong();
|
||||
long rxTime = in.readLong();
|
||||
long idleTime = in.readLong();
|
||||
long energyUsed = in.readLong();
|
||||
return new BluetoothActivityEnergyInfo(timestamp, stackState,
|
||||
txTime, rxTime, idleTime, energyUsed);
|
||||
}
|
||||
@@ -80,10 +80,10 @@ public final class BluetoothActivityEnergyInfo implements Parcelable {
|
||||
public void writeToParcel(Parcel out, int flags) {
|
||||
out.writeLong(mTimestamp);
|
||||
out.writeInt(mBluetoothStackState);
|
||||
out.writeInt(mControllerTxTimeMs);
|
||||
out.writeInt(mControllerRxTimeMs);
|
||||
out.writeInt(mControllerIdleTimeMs);
|
||||
out.writeInt(mControllerEnergyUsed);
|
||||
out.writeLong(mControllerTxTimeMs);
|
||||
out.writeLong(mControllerRxTimeMs);
|
||||
out.writeLong(mControllerIdleTimeMs);
|
||||
out.writeLong(mControllerEnergyUsed);
|
||||
}
|
||||
|
||||
public int describeContents() {
|
||||
@@ -100,21 +100,21 @@ public final class BluetoothActivityEnergyInfo implements Parcelable {
|
||||
/**
|
||||
* @return tx time in ms
|
||||
*/
|
||||
public int getControllerTxTimeMillis() {
|
||||
public long getControllerTxTimeMillis() {
|
||||
return mControllerTxTimeMs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return rx time in ms
|
||||
*/
|
||||
public int getControllerRxTimeMillis() {
|
||||
public long getControllerRxTimeMillis() {
|
||||
return mControllerRxTimeMs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return idle time in ms
|
||||
*/
|
||||
public int getControllerIdleTimeMillis() {
|
||||
public long getControllerIdleTimeMillis() {
|
||||
return mControllerIdleTimeMs;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ public final class BluetoothActivityEnergyInfo implements Parcelable {
|
||||
* product of current(mA), voltage(V) and time(ms)
|
||||
* @return energy used
|
||||
*/
|
||||
public int getControllerEnergyUsed() {
|
||||
public long getControllerEnergyUsed() {
|
||||
return mControllerEnergyUsed;
|
||||
}
|
||||
|
||||
@@ -137,8 +137,8 @@ public final class BluetoothActivityEnergyInfo implements Parcelable {
|
||||
* @return if the record is valid
|
||||
*/
|
||||
public boolean isValid() {
|
||||
return ((getControllerTxTimeMillis() !=0) ||
|
||||
(getControllerRxTimeMillis() !=0) ||
|
||||
(getControllerIdleTimeMillis() !=0));
|
||||
return ((mControllerTxTimeMs !=0) ||
|
||||
(mControllerRxTimeMs !=0) ||
|
||||
(mControllerIdleTimeMs !=0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1167,6 +1167,10 @@ public final class BatteryStatsService extends IBatteryStats.Stub
|
||||
BluetoothActivityEnergyInfo info = adapter.getControllerActivityEnergyInfo(
|
||||
BluetoothAdapter.ACTIVITY_ENERGY_INFO_REFRESHED);
|
||||
if (info != null && info.isValid()) {
|
||||
if (info.getControllerEnergyUsed() < 0 || info.getControllerIdleTimeMillis() < 0 ||
|
||||
info.getControllerRxTimeMillis() < 0 || info.getControllerTxTimeMillis() < 0) {
|
||||
Slog.wtf(TAG, "Bluetooth energy data is invalid: " + info);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,22 +39,22 @@ public final class WifiActivityEnergyInfo implements Parcelable {
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public int mControllerTxTimeMs;
|
||||
public long mControllerTxTimeMs;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public int mControllerRxTimeMs;
|
||||
public long mControllerRxTimeMs;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public int mControllerIdleTimeMs;
|
||||
public long mControllerIdleTimeMs;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public int mControllerEnergyUsed;
|
||||
public long mControllerEnergyUsed;
|
||||
|
||||
public static final int STACK_STATE_INVALID = 0;
|
||||
public static final int STACK_STATE_STATE_ACTIVE = 1;
|
||||
@@ -62,7 +62,7 @@ public final class WifiActivityEnergyInfo implements Parcelable {
|
||||
public static final int STACK_STATE_STATE_IDLE = 3;
|
||||
|
||||
public WifiActivityEnergyInfo(long timestamp, int stackState,
|
||||
int txTime, int rxTime, int idleTime, int energyUsed) {
|
||||
long txTime, long rxTime, long idleTime, long energyUsed) {
|
||||
mTimestamp = timestamp;
|
||||
mStackState = stackState;
|
||||
mControllerTxTimeMs = txTime;
|
||||
@@ -88,10 +88,10 @@ public final class WifiActivityEnergyInfo implements Parcelable {
|
||||
public WifiActivityEnergyInfo createFromParcel(Parcel in) {
|
||||
long timestamp = in.readLong();
|
||||
int stackState = in.readInt();
|
||||
int txTime = in.readInt();
|
||||
int rxTime = in.readInt();
|
||||
int idleTime = in.readInt();
|
||||
int energyUsed = in.readInt();
|
||||
long txTime = in.readLong();
|
||||
long rxTime = in.readLong();
|
||||
long idleTime = in.readLong();
|
||||
long energyUsed = in.readLong();
|
||||
return new WifiActivityEnergyInfo(timestamp, stackState,
|
||||
txTime, rxTime, idleTime, energyUsed);
|
||||
}
|
||||
@@ -103,10 +103,10 @@ public final class WifiActivityEnergyInfo implements Parcelable {
|
||||
public void writeToParcel(Parcel out, int flags) {
|
||||
out.writeLong(mTimestamp);
|
||||
out.writeInt(mStackState);
|
||||
out.writeInt(mControllerTxTimeMs);
|
||||
out.writeInt(mControllerRxTimeMs);
|
||||
out.writeInt(mControllerIdleTimeMs);
|
||||
out.writeInt(mControllerEnergyUsed);
|
||||
out.writeLong(mControllerTxTimeMs);
|
||||
out.writeLong(mControllerRxTimeMs);
|
||||
out.writeLong(mControllerIdleTimeMs);
|
||||
out.writeLong(mControllerEnergyUsed);
|
||||
}
|
||||
|
||||
public int describeContents() {
|
||||
@@ -123,30 +123,29 @@ public final class WifiActivityEnergyInfo implements Parcelable {
|
||||
/**
|
||||
* @return tx time in ms
|
||||
*/
|
||||
public int getControllerTxTimeMillis() {
|
||||
return (int)mControllerTxTimeMs;
|
||||
public long getControllerTxTimeMillis() {
|
||||
return mControllerTxTimeMs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return rx time in ms
|
||||
*/
|
||||
public int getControllerRxTimeMillis() {
|
||||
return (int)mControllerRxTimeMs;
|
||||
public long getControllerRxTimeMillis() {
|
||||
return mControllerRxTimeMs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return idle time in ms
|
||||
*/
|
||||
public int getControllerIdleTimeMillis() {
|
||||
return (int)mControllerIdleTimeMs;
|
||||
public long getControllerIdleTimeMillis() {
|
||||
return mControllerIdleTimeMs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* product of current(mA), voltage(V) and time(ms)
|
||||
* @return energy used
|
||||
*/
|
||||
public int getControllerEnergyUsed() {
|
||||
public long getControllerEnergyUsed() {
|
||||
return mControllerEnergyUsed;
|
||||
}
|
||||
/**
|
||||
@@ -160,8 +159,8 @@ public final class WifiActivityEnergyInfo implements Parcelable {
|
||||
* @return if the record is valid
|
||||
*/
|
||||
public boolean isValid() {
|
||||
return ((getControllerTxTimeMillis() !=0) ||
|
||||
(getControllerRxTimeMillis() !=0) ||
|
||||
(getControllerIdleTimeMillis() !=0));
|
||||
return ((mControllerTxTimeMs !=0) ||
|
||||
(mControllerRxTimeMs !=0) ||
|
||||
(mControllerIdleTimeMs !=0));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user