Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 80126aba authored by Adam Lesinski's avatar Adam Lesinski
Browse files

Change WiFi and Bluetooth ActivityEnergyInfo classes

Have them take an elapsed time millis timestamp instead
of having the constructor call System.currentTimeMillis.

Change-Id: Ic9ca8f92347c336beee8ebcc3407de2c1e5b4073
parent b39ffb2c
Loading
Loading
Loading
Loading
+12 −9
Original line number Diff line number Diff line
@@ -26,32 +26,32 @@ import android.os.Parcelable;
 * @hide
 */
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 timestamp;

    public static final int BT_STACK_STATE_INVALID = 0;
    public static final int BT_STACK_STATE_STATE_ACTIVE = 1;
    public static final int BT_STACK_STATE_STATE_SCANNING = 2;
    public static final int BT_STACK_STATE_STATE_IDLE = 3;

    public BluetoothActivityEnergyInfo(int stackState, int txTime, int rxTime,
            int idleTime, int energyUsed) {
    public BluetoothActivityEnergyInfo(long timestamp, int stackState,
                                       int txTime, int rxTime, int idleTime, int energyUsed) {
        mTimestamp = timestamp;
        mBluetoothStackState = stackState;
        mControllerTxTimeMs = txTime;
        mControllerRxTimeMs = rxTime;
        mControllerIdleTimeMs = idleTime;
        mControllerEnergyUsed = energyUsed;
        timestamp = System.currentTimeMillis();
    }

    @Override
    public String toString() {
        return "BluetoothActivityEnergyInfo{"
            + " timestamp=" + timestamp
            + " mTimestamp=" + mTimestamp
            + " mBluetoothStackState=" + mBluetoothStackState
            + " mControllerTxTimeMs=" + mControllerTxTimeMs
            + " mControllerRxTimeMs=" + mControllerRxTimeMs
@@ -63,13 +63,14 @@ public final class BluetoothActivityEnergyInfo implements Parcelable {
    public static final Parcelable.Creator<BluetoothActivityEnergyInfo> CREATOR =
            new Parcelable.Creator<BluetoothActivityEnergyInfo>() {
        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();
            return new BluetoothActivityEnergyInfo(stackState, txTime, rxTime,
                    idleTime, energyUsed);
            return new BluetoothActivityEnergyInfo(timestamp, stackState,
                    txTime, rxTime, idleTime, energyUsed);
        }
        public BluetoothActivityEnergyInfo[] newArray(int size) {
            return new BluetoothActivityEnergyInfo[size];
@@ -77,6 +78,7 @@ 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);
@@ -123,11 +125,12 @@ public final class BluetoothActivityEnergyInfo implements Parcelable {
    public int getControllerEnergyUsed() {
        return mControllerEnergyUsed;
    }

    /**
     * @return timestamp(wall clock) of record creation
     * @return timestamp(real time elapsed in milliseconds since boot) of record creation.
     */
    public long getTimeStamp() {
        return timestamp;
        return mTimestamp;
    }

    /**