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

Commit 5630b097 authored by Prerepa Viswanadham's avatar Prerepa Viswanadham
Browse files

Use overlay values for computing the energy used.

Change-Id: Ifddeccbb555e5db19434b13b69f9a7b0c139332e
parent 7bc1b357
Loading
Loading
Loading
Loading
+23 −2
Original line number Diff line number Diff line
@@ -1838,14 +1838,19 @@ public class AdapterService extends Service {
    private void energyInfoCallback (int status, int ctrl_state,
        long tx_time, long rx_time, long idle_time, long energy_used)
        throws RemoteException {
        // ToDo: Update only status is valid
        if (ctrl_state >= BluetoothActivityEnergyInfo.BT_STACK_STATE_INVALID &&
                ctrl_state <= BluetoothActivityEnergyInfo.BT_STACK_STATE_STATE_IDLE) {
            mStackReportedState = ctrl_state;
            mTxTimeTotalMs += tx_time;
            mRxTimeTotalMs += rx_time;
            mIdleTimeTotalMs += idle_time;
            // Energy is product of mA, V and ms
            // Energy is product of mA, V and ms. If the chipset doesn't
            // report it, we have to compute it from time
            if (energy_used == 0) {
                energy_used = ((mTxTimeTotalMs * getTxCurrentMa()
                    + mRxTimeTotalMs * getRxCurrentMa()
                    + mIdleTimeTotalMs * getIdleCurrentMa()) * getOperatingMilliVolt())/1000;
            }
            mEnergyUsedTotalVoltAmpSecMicro += energy_used;
        }

@@ -1857,6 +1862,22 @@ public class AdapterService extends Service {
        }
    }

    private int getIdleCurrentMa() {
        return getResources().getInteger(R.integer.config_bluetooth_idle_cur_ma);
    }

    private int getTxCurrentMa() {
        return getResources().getInteger(R.integer.config_bluetooth_tx_cur_ma);
    }

    private int getRxCurrentMa() {
        return getResources().getInteger(R.integer.config_bluetooth_rx_cur_ma);
    }

    private int getOperatingMilliVolt() {
        return getResources().getInteger(R.integer.config_bluetooth_operating_voltage_mv);
    }

    private void debugLog(String msg) {
        if (DBG) Log.d(TAG +"(" +hashCode()+")", msg);
    }