Modem activity info

Change-Id: Iab8fbdeae0867c6e9cb9027b08317b1b5a2c9dfc
diff --git a/include/telephony/ril.h b/include/telephony/ril.h
index 1772025..8cde697 100644
--- a/include/telephony/ril.h
+++ b/include/telephony/ril.h
@@ -1412,14 +1412,7 @@
 } RIL_DataProfileInfo;
 
 /* Tx Power Levels */
-typedef enum {
-   RIL_TX_POWER_LEVEL_ONE =  0,
-   RIL_TX_POWER_LEVEL_TWO = 1,
-   RIL_TX_POWER_LEVEL_THREE = 2,
-   RIL_TX_POWER_LEVEL_FOUR = 3,
-   RIL_TX_POWER_LEVEL_FIVE = 4,
-   RIL_TX_POWER_LEVEL_MAX = 5
-} RIL_TxPowerLevel;
+#define RIL_NUM_TX_POWER_LEVELS     5
 
 typedef struct {
 
@@ -1430,7 +1423,7 @@
   uint32_t idle_mode_time_ms;
 
   /* period (in ms) for which Tx is active */
-  uint32_t tx_mode_time_ms[RIL_TX_POWER_LEVEL_MAX];
+  uint32_t tx_mode_time_ms[RIL_NUM_TX_POWER_LEVELS];
 
   /* period (in ms) for which Rx is active */
   uint32_t rx_mode_time_ms;
diff --git a/libril/ril.cpp b/libril/ril.cpp
index aa82e7f..32c4376 100644
--- a/libril/ril.cpp
+++ b/libril/ril.cpp
@@ -299,6 +299,7 @@
 static int responseSSData(Parcel &p, void *response, size_t responselen);
 static int responseLceStatus(Parcel &p, void *response, size_t responselen);
 static int responseLceData(Parcel &p, void *response, size_t responselen);
+static int responseActivityData(Parcel &p, void *response, size_t responselen);
 
 static int decodeVoiceRadioTechnology (RIL_RadioState radioState);
 static int decodeCdmaSubscriptionSource (RIL_RadioState radioState);
@@ -3637,6 +3638,37 @@
   return 0;
 }
 
+static int responseActivityData(Parcel &p, void *response, size_t responselen) {
+  if (response == NULL || responselen != sizeof(RIL_ActivityStatsInfo)) {
+    if (response == NULL) {
+      RLOGE("invalid response: NULL");
+    }
+    else {
+      RLOGE("responseActivityData: invalid response length %d expecting len: d%",
+            sizeof(RIL_ActivityStatsInfo), responselen);
+    }
+    return RIL_ERRNO_INVALID_RESPONSE;
+  }
+
+  RIL_ActivityStatsInfo *p_cur = (RIL_ActivityStatsInfo *)response;
+  p.writeInt32(p_cur->sleep_mode_time_ms);
+  p.writeInt32(p_cur->idle_mode_time_ms);
+  for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
+    p.writeInt32(p_cur->tx_mode_time_ms[i]);
+  }
+  p.writeInt32(p_cur->rx_mode_time_ms);
+
+  startResponse;
+  appendPrintBuf("Modem activity info received: sleep_mode_time_ms %d idle_mode_time_ms %d
+                  tx_mode_time_ms %d %d %d %d %d and rx_mode_time_ms %d",
+                  p_cur->sleep_mode_time_ms, p_cur->idle_mode_time_ms, p_cur->tx_mode_time_ms[0],
+                  p_cur->tx_mode_time_ms[1], p_cur->tx_mode_time_ms[2], p_cur->tx_mode_time_ms[3],
+                  p_cur->tx_mode_time_ms[4], p_cur->rx_mode_time_ms);
+   closeResponse;
+
+  return 0;
+}
+
 /**
  * A write on the wakeup fd is done just to pop us out of select()
  * We empty the buffer here and then ril_event will reset the timers on the
diff --git a/libril/ril_commands.h b/libril/ril_commands.h
index d0a327b..eb90426 100644
--- a/libril/ril_commands.h
+++ b/libril/ril_commands.h
@@ -149,3 +149,4 @@
     {RIL_REQUEST_START_LCE, dispatchInts, responseLceStatus},
     {RIL_REQUEST_STOP_LCE, dispatchVoid, responseLceStatus},
     {RIL_REQUEST_PULL_LCEDATA, dispatchVoid, responseLceData},
+    {RIL_REQUEST_GET_ACTIVITY_INFO, dispatchVoid, responseActivityData},