diff options
author | Roman Kiryanov <rkir@google.com> | 2018-06-21 18:17:50 -0700 |
---|---|---|
committer | Roman Kiryanov <rkir@google.com> | 2018-06-22 09:51:42 -0700 |
commit | 9cd132b0458e0615d100cf0e1316870567155125 (patch) | |
tree | 366833c00b045b3cd03b253035139b22881fe677 /ril | |
parent | 2e9722c6c4007cd3b9b1616a00f16d6aa1ed4ec5 (diff) | |
download | android_device_generic_goldfish-9cd132b0458e0615d100cf0e1316870567155125.tar.gz android_device_generic_goldfish-9cd132b0458e0615d100cf0e1316870567155125.tar.bz2 android_device_generic_goldfish-9cd132b0458e0615d100cf0e1316870567155125.zip |
Add support to query modem activity info in ril
Implement RIL_REQUEST_GET_ACTIVITY_INFO to pass testModemActivityInfo.
Bug: 78235709
Test: ./android-cts/tools/cts-tradefed run cts -m CtsStatsdHostTestCases \
-t android.cts.statsd.atom.HostAtomTests#testModemActivityInfo
Signed-off-by: Roman Kiryanov <rkir@google.com>
Change-Id: I4df288f270d896027a19a495874e125ac5def359
Diffstat (limited to 'ril')
-rw-r--r-- | ril/reference-ril.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/ril/reference-ril.c b/ril/reference-ril.c index 4503e1b..0f56a19 100644 --- a/ril/reference-ril.c +++ b/ril/reference-ril.c @@ -2414,6 +2414,44 @@ static void requestGetSimAuthentication(void *data, size_t datalen __unused, RIL free(p_response); } +static void requestModemActivityInfo(RIL_Token t) +{ + int err; + char *line; + ATResponse *p_response = NULL; + RIL_ActivityStatsInfo info; + + err = at_send_command_singleline("AT+MAI", "+MAI:", &p_response); + if (err < 0 || p_response == NULL || p_response->success == 0) { + ALOGE("Error transmitting AT+MAI, err=%d, success=%d", + err, (p_response ? p_response->success : 0)); + goto error; + } + + memset(&info, 0, sizeof(info)); + if (sscanf(p_response->p_intermediates->line, + "+MAI: sleep=%u idle=%u rx=%u tx0=%u tx1=%u tx2=%u tx3=%u tx4=%u", + &info.sleep_mode_time_ms, + &info.idle_mode_time_ms, + &info.rx_mode_time_ms, + &info.tx_mode_time_ms[0], + &info.tx_mode_time_ms[1], + &info.tx_mode_time_ms[2], + &info.tx_mode_time_ms[3], + &info.tx_mode_time_ms[4]) == 8) { + RIL_onRequestComplete(t, RIL_E_SUCCESS, &info, sizeof(info)); + at_response_free(p_response); + return; + } else { + ALOGE("Unexpected response for AT+MAI: '%s'", + p_response->p_intermediates->line); + } + +error: + at_response_free(p_response); + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); +} + /*** Callback methods from the RIL library to us ***/ /** @@ -2874,6 +2912,10 @@ onRequest (int request, void *data, size_t datalen, RIL_Token t) } break; + case RIL_REQUEST_GET_ACTIVITY_INFO: + requestModemActivityInfo(t); + break; + default: RLOGD("Request not supported. Tech: %d",TECH(sMdmInfo)); RIL_onRequestComplete(t, RIL_E_REQUEST_NOT_SUPPORTED, NULL, 0); |