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

Commit cb3cff31 authored by Gary Jian's avatar Gary Jian
Browse files

ModemActivityInfo with rat information

- Add technology specific activity stats info for each rats
- backward compatible with legacy api (UNKNOWN rat)

Bug: 202413770
Test: atest ModemActivityInfoTest
Test: atest TelephonyManagerTest#testRequestModemActivityInfo
Change-Id: Iaa29d0e62d8f57349450a101233e78be4d55f222
parent 1ddc9ee4
Loading
Loading
Loading
Loading
+21 −7
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.hardware.radio.RadioError;
import android.hardware.radio.RadioResponseInfo;
import android.hardware.radio.modem.IRadioModemResponse;
import android.os.SystemClock;
import android.telephony.ActivityStatsTechSpecificInfo;
import android.telephony.AnomalyReporter;
import android.telephony.ModemActivityInfo;

@@ -101,20 +102,33 @@ public class ModemResponse extends IRadioModemResponse.Stub {

        if (rr != null) {
            ModemActivityInfo ret = null;
            ActivityStatsTechSpecificInfo[] astsi = null;
            if (responseInfo.error == RadioError.NONE) {
                final int sleepModeTimeMs = activityInfo.sleepModeTimeMs;
                final int idleModeTimeMs = activityInfo.idleModeTimeMs;
                int size = activityInfo.techSpecificInfo.length;
                astsi = new ActivityStatsTechSpecificInfo[size];
                for (int s = 0; s < size; s++) {
                    int rat = activityInfo.techSpecificInfo[s].rat;
                    int frequencyRange = activityInfo.techSpecificInfo[s].frequencyRange;
                    int [] txModeTimeMs = new int[ModemActivityInfo.getNumTxPowerLevels()];
                // TODO: update the function as per the new API introduced in Android T
                    int rxModeTimeMs = activityInfo.techSpecificInfo[s].rxModeTimeMs;
                    for (int i = 0; i < ModemActivityInfo.getNumTxPowerLevels(); i++) {
                    txModeTimeMs[i] = activityInfo.techSpecificInfo[0].txmModetimeMs[i];
                        txModeTimeMs[i] = activityInfo.techSpecificInfo[s].txmModetimeMs[i];
                    }
                    astsi[s] = new ActivityStatsTechSpecificInfo(
                                    rat,
                                    frequencyRange,
                                    txModeTimeMs,
                                    rxModeTimeMs);
                }
                final int rxModeTimeMs = activityInfo.techSpecificInfo[0].rxModeTimeMs;
                ret = new ModemActivityInfo(SystemClock.elapsedRealtime(), sleepModeTimeMs,
                        idleModeTimeMs, txModeTimeMs, rxModeTimeMs);
                        idleModeTimeMs, astsi);
            } else {
                ret = new ModemActivityInfo(0, 0, 0,
                astsi = new ActivityStatsTechSpecificInfo[1];
                astsi[0] = new ActivityStatsTechSpecificInfo(0, 0,
                        new int[ModemActivityInfo.getNumTxPowerLevels()], 0);
                ret = new ModemActivityInfo(SystemClock.elapsedRealtime(), 0, 0, astsi);
                responseInfo.error = RadioError.NONE;
            }
            RadioResponse.sendMessageResponse(rr.mResult, ret);