OSDN Git Service

Add RIL_REQUEST_SHUTDOWN to notify RIL that device is shutting down
authorNaveen Kalla <nkalla@codeaurora.org>
Thu, 31 Jul 2014 23:48:31 +0000 (16:48 -0700)
committerWink Saville <wink@google.com>
Tue, 19 Aug 2014 15:19:47 +0000 (08:19 -0700)
When device is in airplane mode, SIM card and modem may be powered on.
RIL can use RIL_REQUEST_SHUTDOWN to shutdown the modem and SIM card
gracefully.

Bug: 9773278
Change-Id: I6afa9e810cefc7855f7ae42e51f39cc51fa2aa6e

include/telephony/ril.h
libril/ril.cpp
libril/ril_commands.h
reference-ril/reference-ril.c

index 1518d81..9f6163f 100644 (file)
@@ -4069,6 +4069,24 @@ typedef struct {
  *  SUBSCRIPTION_NOT_AVAILABLE
  */
 #define RIL_REQUEST_SET_DATA_PROFILE 128
+
+/**
+ * RIL_REQUEST_SHUTDOWN
+ *
+ * Device is shutting down. All further commands are ignored
+ * and RADIO_NOT_AVAILABLE must be returned.
+ *
+ * "data" is null
+ * "response" is NULL
+ *
+ * Valid errors:
+ *  SUCCESS
+ *  RADIO_NOT_AVAILABLE
+ *  GENERIC_FAILURE
+ */
+#define RIL_REQUEST_SHUTDOWN 129
+
+
 /***********************************************************************/
 
 
index 4b3e1b8..feaf60f 100644 (file)
@@ -4710,6 +4710,7 @@ requestToString(int request) {
         case RIL_UNSOL_SRVCC_STATE_NOTIFY: return "UNSOL_SRVCC_STATE_NOTIFY";
         case RIL_UNSOL_HARDWARE_CONFIG_CHANGED: return "HARDWARE_CONFIG_CHANGED";
         case RIL_UNSOL_DC_RT_INFO_CHANGED: return "UNSOL_DC_RT_INFO_CHANGED";
+        case RIL_REQUEST_SHUTDOWN: return "SHUTDOWN";
         default: return "<unknown request>";
     }
 }
index 1d96abb..7c3af55 100644 (file)
     {RIL_REQUEST_GET_DC_RT_INFO, dispatchVoid, responseDcRtInfo},
     {RIL_REQUEST_SET_DC_RT_INFO_RATE, dispatchInts, responseVoid},
     {RIL_REQUEST_SET_DATA_PROFILE, dispatchDataProfile, responseVoid},
+    {RIL_REQUEST_SHUTDOWN, dispatchVoid, responseVoid},
index 5d45cde..02e5d50 100644 (file)
@@ -398,6 +398,23 @@ error:
     RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
 }
 
+static void requestShutdown(RIL_Token t)
+{
+    int onOff;
+
+    int err;
+    ATResponse *p_response = NULL;
+
+    if (sState != RADIO_STATE_OFF) {
+        err = at_send_command("AT+CFUN=0", &p_response);
+        setRadioState(RADIO_STATE_UNAVAILABLE);
+    }
+
+    at_response_free(p_response);
+    RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
+    return;
+}
+
 static void requestOrSendDataCallList(RIL_Token *t);
 
 static void onDataCallListChanged(void *param __unused)
@@ -2308,6 +2325,10 @@ onRequest (int request, void *data, size_t datalen, RIL_Token t)
             requestGetHardwareConfig(data, datalen, t);
             break;
 
+        case RIL_REQUEST_SHUTDOWN:
+            requestShutdown(t);
+            break;
+
         /* CDMA Specific Requests */
         case RIL_REQUEST_BASEBAND_VERSION:
             if (TECH_BIT(sMdmInfo) == MDM_CDMA) {