[Replicant] [libsamsung-ril] [PATCH 2/2] Convert to use separate SIM status

Denis 'GNUtoo' Carikli GNUtoo at cyberdimension.org
Fri Oct 16 23:22:33 UTC 2020


In 2001, in the RIL repository[1], the SIM states were separated from
the radio states by the following commit:
    2bc78d614e349574426d198c37e51ccb7455b5bb
    2bc78d61 Separate SIM states from Radio States

Then in 2016 the SIM states were removed from the RADIO_STATES by the
following commit:
    2baf72329c43d9e3f7850973f087176f535e31e8
    2baf7232 Remove deprecated RADIO_STATES

So to be compatible with recent rild, we need to convert the code to
use separate SIM states.

TODO:
- Test this code with Replicant 4.2!!!!

[1]https://android.googlesource.com/platform/hardware/ril

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
---
 call.c           | 14 ++++++-------
 data.c           | 10 +++++-----
 misc.c           | 10 +++++-----
 network.c        | 32 ++++++++++++++---------------
 power.c          |  2 +-
 samsung-ril.c    | 47 +++++++++++++++++++++++++++++++++++++------
 samsung-ril.h    | 14 ++++++++++++-
 sim.c            | 52 ++++++++++++++++++++++++------------------------
 sms.c            |  6 +++---
 ss.c             |  4 ++--
 tools/srs-test.c |  5 +----
 11 files changed, 120 insertions(+), 76 deletions(-)

diff --git a/call.c b/call.c
index 7daed67..ef4814f 100644
--- a/call.c
+++ b/call.c
@@ -82,7 +82,7 @@ int ril_request_dial(void *data, size_t size, RIL_Token token)
 	if (data == NULL || size < sizeof(RIL_Dial))
 		goto error;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -139,7 +139,7 @@ int ril_request_hangup(__attribute__((unused)) void *data,
 	int hangup;
 	int rc;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -176,7 +176,7 @@ int ril_request_answer(__attribute__((unused)) void *data,
 {
 	int rc;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -240,7 +240,7 @@ int ril_request_last_call_fail_cause(__attribute__((unused)) void *data,
 	int fail_cause;
 	int rc;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -350,7 +350,7 @@ int ril_request_get_current_calls(__attribute__((unused)) void *data,
 {
 	int rc;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0) {
 		ril_request_complete(token, RIL_E_SUCCESS, NULL, 0);
 		return RIL_REQUEST_COMPLETED;
@@ -486,7 +486,7 @@ int ril_request_dtmf(void *data, size_t size, RIL_Token token)
 	if (data == NULL || size < sizeof(char))
 		goto error;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -571,7 +571,7 @@ int ril_request_dtmf_start(void *data, size_t size, RIL_Token token)
 	if (data == NULL || size < sizeof(char))
 		goto error;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
diff --git a/data.c b/data.c
index 93fda8c..ff6df5e 100644
--- a/data.c
+++ b/data.c
@@ -467,7 +467,7 @@ int ril_request_setup_data_call(void *data, size_t size, RIL_Token token)
 	if (data == NULL || size < 6 * sizeof(char *))
 		goto error;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_READY);
+	rc = ril_sim_has_reached_state(SIM_STATE_READY);
 	if (rc < 0) {
 		ril_request_complete(token, RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW, NULL, 0);
 		return RIL_REQUEST_COMPLETED;
@@ -663,7 +663,7 @@ int ril_request_data_call_list(__attribute__((unused)) void *data,
 {
 	int rc;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0) {
 		ril_request_complete(token, RIL_E_SUCCESS, NULL, 0);
 		return RIL_REQUEST_COMPLETED;
@@ -729,7 +729,7 @@ int ril_request_deactivate_data_call(void *data, size_t size, RIL_Token token)
 	if (data == NULL || size < 2 * sizeof(char *))
 		goto error;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_READY);
+	rc = ril_sim_has_reached_state(SIM_STATE_READY);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -876,7 +876,7 @@ int ipc_gprs_call_status(struct ipc_message *message)
 	if (message == NULL || message->data == NULL || message->size < sizeof(struct ipc_gprs_call_status_data))
 		return -1;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_READY);
+	rc = ril_sim_has_reached_state(SIM_STATE_READY);
 	if (rc < 0)
 		return 0;
 
@@ -1021,7 +1021,7 @@ int ril_request_last_data_call_fail_cause(__attribute__((unused)) void *data,
 	int fail_cause;
 	int rc;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
diff --git a/misc.c b/misc.c
index 3628e96..08eab50 100644
--- a/misc.c
+++ b/misc.c
@@ -57,7 +57,7 @@ int ril_request_baseband_version(__attribute__((unused)) void *data,
 	struct ril_request *request;
 	int rc;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -115,7 +115,7 @@ int ril_request_get_imsi(__attribute__((unused)) void *data,
 	struct ril_request *request;
 	int rc;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_READY);
+	rc = ril_sim_has_reached_state(SIM_STATE_READY);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -191,7 +191,7 @@ int ril_request_get_imei(__attribute__((unused)) void *data,
 	struct ril_request *request;
 	int rc;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -223,7 +223,7 @@ int ril_request_get_imeisv(__attribute__((unused)) void *data,
 	struct ril_request *request;
 	int rc;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -277,7 +277,7 @@ int ril_request_screen_state(void *data, size_t size, RIL_Token token)
 		return RIL_REQUEST_COMPLETED;
 	}
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
diff --git a/network.c b/network.c
index e4dd035..6f2e168 100644
--- a/network.c
+++ b/network.c
@@ -399,7 +399,7 @@ int ipc_disp_icon_info(struct ipc_message *message)
 	if (message == NULL || message->data == NULL || message->size < sizeof(struct ipc_disp_icon_info_response_data))
 		return -1;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return 0;
 
@@ -428,7 +428,7 @@ int ril_request_signal_strength(__attribute__((unused)) void *data,
 	struct ipc_disp_icon_info_request_data request_data;
 	int rc;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -453,7 +453,7 @@ int ipc_disp_rssi_info(struct ipc_message *message)
 	if (message == NULL || message->data == NULL || message->size < sizeof(struct ipc_disp_rssi_info_data))
 		return -1;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return 0;
 
@@ -477,7 +477,7 @@ int ipc_net_plmn_sel(struct ipc_message *message)
 	if (message == NULL || message->data == NULL || message->size < sizeof(struct ipc_net_plmn_sel_response_data))
 		return -1;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return 0;
 
@@ -499,7 +499,7 @@ int ril_request_query_network_selection_mode(__attribute__((unused)) void *data,
 {
 	int rc;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -545,7 +545,7 @@ int ril_request_set_network_selection_automatic(__attribute__((unused)) void *da
 	struct ipc_net_plmn_sel_request_data request_data;
 	int rc;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -584,7 +584,7 @@ int ril_request_set_network_selection_manual(void *data, size_t size,
 		return RIL_REQUEST_COMPLETED;
 	}
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -623,7 +623,7 @@ int ipc_net_serving_network(struct ipc_message *message)
 	if (message == NULL || message->data == NULL || message->size < sizeof(struct ipc_net_regist_response_data))
 		return -1;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return 0;
 
@@ -670,7 +670,7 @@ int ril_request_operator(__attribute__((unused)) void *data,
 	unsigned int i;
 	int rc;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -720,7 +720,7 @@ int ipc_net_plmn_list(struct ipc_message *message)
 	if (message == NULL || message->data == NULL || message->size < sizeof(struct ipc_net_plmn_list_header))
 		return -1;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return 0;
 
@@ -796,7 +796,7 @@ int ril_request_query_available_networks(__attribute__((unused)) void *data,
 	struct ril_request *request;
 	int rc;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -835,7 +835,7 @@ int ipc_net_regist(struct ipc_message *message)
 	if (client == NULL || client->data == NULL)
 		return 0;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return 0;
 
@@ -936,7 +936,7 @@ int ril_request_registration_state(__attribute__((unused)) void *data,
 	unsigned int i;
 	int rc;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -1011,7 +1011,7 @@ int ril_request_gprs_registration_state(__attribute__((unused)) void *data,
 	unsigned int i;
 	int rc;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -1076,7 +1076,7 @@ int ipc_net_mode_sel(struct ipc_message *message)
 	if (message == NULL || message->data == NULL || message->size < sizeof(struct ipc_net_mode_sel_data))
 		return -1;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return 0;
 
@@ -1098,7 +1098,7 @@ int ril_request_get_preferred_network_type(__attribute__((unused)) void *data,
 {
 	int rc;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
diff --git a/power.c b/power.c
index 011570f..9b68c4d 100644
--- a/power.c
+++ b/power.c
@@ -63,7 +63,7 @@ int ipc_pwr_phone_state(struct ipc_message *message)
 			RIL_LOGD("Power state is normal");
 
 			ril_request_complete(ipc_fmt_request_token(message->aseq), RIL_E_SUCCESS, NULL, 0);
-			ril_radio_state_update(RADIO_STATE_SIM_NOT_READY);
+			ril_radio_state_update(RADIO_STATE_ON);
 			break;
 	}
 
diff --git a/samsung-ril.c b/samsung-ril.c
index 31d0244..6378c23 100644
--- a/samsung-ril.c
+++ b/samsung-ril.c
@@ -1196,6 +1196,27 @@ int ril_radio_state_update(RIL_RadioState radio_state)
 	return 0;
 }
 
+/*
+ * RIL SIM state
+ */
+
+int ril_sim_state_update(enum sim_state sim_state)
+{
+	if (ril_data == NULL)
+		return -1;
+
+	if (ril_data->sim_state == sim_state)
+		return 0;
+
+	RIL_LOGD("Updating RIL SIM state to %d", sim_state);
+
+	ril_data->sim_state = sim_state;
+
+	ril_request_unsolicited(RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, NULL, 0);
+
+	return 0;
+}
+
 /*
  * Returns 0 if the RIL has reached the given radio_state
  * Returns -1 otherwise
@@ -1203,14 +1224,9 @@ int ril_radio_state_update(RIL_RadioState radio_state)
 int ril_radio_has_reached_state(RIL_RadioState given_state)
 {
 	RIL_RadioState radio_states[] = {
-		RADIO_STATE_UNAVAILABLE,
 		RADIO_STATE_OFF,
+		RADIO_STATE_UNAVAILABLE,
 		RADIO_STATE_ON,
-		RADIO_STATE_NV_NOT_READY,
-		RADIO_STATE_NV_READY,
-		RADIO_STATE_SIM_NOT_READY,
-		RADIO_STATE_SIM_LOCKED_OR_ABSENT,
-		RADIO_STATE_SIM_READY,
 	};
 
 	RIL_RadioState curr_state;
@@ -1242,6 +1258,25 @@ int ril_radio_has_reached_state(RIL_RadioState given_state)
 	return 0;
 }
 
+/*
+ * Returns 0 if the RIL has reached the given sim_state
+ * Returns -1 otherwise
+ */
+int ril_sim_has_reached_state(enum sim_state given_state)
+{
+	enum sim_state curr_state;
+
+	if (ril_data == NULL)
+		return -1;
+
+	curr_state = ril_data->sim_state;
+
+	if (curr_state < given_state)
+		return -1;
+
+	return 0;
+}
+
 /*
  * RIL data
  */
diff --git a/samsung-ril.h b/samsung-ril.h
index 0f936e3..3d4d9fc 100644
--- a/samsung-ril.h
+++ b/samsung-ril.h
@@ -199,12 +199,23 @@ size_t ril_request_data_size_get(int request);
 void *ril_request_data_get(int request);
 
 /*
- * RIL radio state
+ * RIL state
  */
 
+enum sim_state {
+	SIM_STATE_ERROR,
+	SIM_STATE_NOT_READY,
+	SIM_STATE_LOCKED_OR_ABSENT,
+	SIM_STATE_READY,
+	SIM_STATE_MAX,
+};
+
 int ril_radio_state_update(RIL_RadioState radio_state);
 int ril_radio_has_reached_state(RIL_RadioState radio_state);
 
+int ril_sim_state_update(enum sim_state sim_state);
+int ril_sim_has_reached_state(enum sim_state sim_state);
+
 /*
  * RIL data
  */
@@ -213,6 +224,7 @@ struct ril_data {
 	const struct RIL_Env *env;
 
 	RIL_RadioState radio_state;
+	enum sim_state sim_state;
 	char *sim_pin;
 
 	struct list_head *requests;
diff --git a/sim.c b/sim.c
index e8c3373..6bb0f4c 100644
--- a/sim.c
+++ b/sim.c
@@ -28,8 +28,8 @@
 #include <utils.h>
 #include <sim.h>
 
-RIL_RadioState ipc2ril_sec_pin_status_response(struct ipc_sec_pin_status_response_data *data,
-	RIL_CardStatus_compat *card_status)
+enum sim_state ipc2ril_sec_pin_status_response(struct ipc_sec_pin_status_response_data *data,
+					       RIL_CardStatus_compat *card_status)
 {
 	RIL_AppStatus app_statuses[] = {
 		// Absent
@@ -53,12 +53,12 @@ RIL_RadioState ipc2ril_sec_pin_status_response(struct ipc_sec_pin_status_respons
 		// Perso service provider
 		{ RIL_APPTYPE_SIM, RIL_APPSTATE_SUBSCRIPTION_PERSO, RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER, NULL, NULL, 0, RIL_PINSTATE_ENABLED_NOT_VERIFIED, RIL_PINSTATE_UNKNOWN },
 	};
-	RIL_RadioState radio_state;
+	enum sim_state sim_state;
 	unsigned int index;
 	unsigned int count;
 
 	if (data == NULL || card_status == NULL)
-		return 0;
+		return SIM_STATE_ERROR;
 
 	count = sizeof(app_statuses) / sizeof(RIL_AppStatus);
 
@@ -113,14 +113,14 @@ RIL_RadioState ipc2ril_sec_pin_status_response(struct ipc_sec_pin_status_respons
 
 	switch (index) {
 		case 1:
-			radio_state = RADIO_STATE_SIM_NOT_READY;
+			sim_state = SIM_STATE_NOT_READY;
 			break;
 		case 2:
-			radio_state = RADIO_STATE_SIM_READY;
+			sim_state = SIM_STATE_READY;
 			break;
 		default:
-			radio_state = RADIO_STATE_SIM_LOCKED_OR_ABSENT;
-	}
+			sim_state = SIM_STATE_LOCKED_OR_ABSENT;
+       }
 
 	memset(card_status, 0, sizeof(RIL_CardStatus_compat));
 
@@ -143,7 +143,7 @@ RIL_RadioState ipc2ril_sec_pin_status_response(struct ipc_sec_pin_status_respons
 
 	RIL_LOGD("%s: Selecting status application %d on %d", __func__, index, count);
 
-	return radio_state;
+	return sim_state;
 }
 
 unsigned char ril2ipc_sec_facility_type(char *facility)
@@ -194,20 +194,20 @@ int ipc_sec_pin_status(struct ipc_message *message)
 	struct ipc_sec_pin_status_response_data *data;
 	struct ipc_sec_pin_status_request_data request_data;
 	RIL_CardStatus_compat card_status;
-	RIL_RadioState radio_state;
+	enum sim_state sim_state;
 	int rc;
 
 	if (message == NULL || message->data == NULL || message->size < sizeof(struct ipc_sec_pin_status_response_data))
 		return -1;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return 0;
 
 	data = (struct ipc_sec_pin_status_response_data *) message->data;
 
-	radio_state = ipc2ril_sec_pin_status_response(data, &card_status);
-	if (radio_state == 0)
+	sim_state = ipc2ril_sec_pin_status_response(data, &card_status);
+	if (sim_state == SIM_STATE_ERROR)
 		return 0;
 
 	if (card_status.applications[0].app_type == RIL_APPTYPE_SIM && card_status.applications[0].app_state == RIL_APPSTATE_PIN && ril_data->sim_pin != NULL) {
@@ -233,7 +233,7 @@ int ipc_sec_pin_status(struct ipc_message *message)
 
 	}
 
-	ril_radio_state_update(radio_state);
+	ril_sim_state_update(sim_state);
 
 	if (message->type == IPC_TYPE_RESP && ipc_seq_valid(message->aseq)) {
 		ril_request_complete(ipc_fmt_request_token(message->aseq), RIL_E_SUCCESS, (void *) &card_status, sizeof(card_status));
@@ -254,7 +254,7 @@ int ril_request_get_sim_status(__attribute__((unused)) void *data,
 	struct ril_request *request;
 	int rc;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -311,7 +311,7 @@ int ril_request_query_facility_lock(void *data, size_t size, RIL_Token token)
 	if (data == NULL || size < 4 * sizeof(char *))
 		goto error;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_READY);
+	rc = ril_sim_has_reached_state(SIM_STATE_READY);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -510,7 +510,7 @@ int ril_request_set_facility_lock(void *data, size_t size, RIL_Token token)
 	if (data == NULL || size < 4 * sizeof(char *))
 		goto error;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_READY);
+	rc = ril_sim_has_reached_state(SIM_STATE_READY);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -588,7 +588,7 @@ int ril_request_enter_sim_pin(void *data, size_t size, RIL_Token token)
 	if (data == NULL || size < 2 * sizeof(char *) || ril_data == NULL)
 		goto error;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -645,7 +645,7 @@ int ril_request_enter_sim_puk(void *data, size_t size, RIL_Token token)
 	if (data == NULL || size < 2 * sizeof(char *))
 		goto error;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -695,7 +695,7 @@ int ril_request_enter_sim_pin2(void *data, size_t size, RIL_Token token)
 	if (data == NULL || size < 2 * sizeof(char *))
 		goto error;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -745,7 +745,7 @@ int ril_request_enter_sim_puk2(void *data, size_t size, RIL_Token token)
 	if (data == NULL || size < 2 * sizeof(char *))
 		goto error;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -799,7 +799,7 @@ int ril_request_change_sim_pin(void *data, size_t size, RIL_Token token)
 	if (request != NULL)
 		return RIL_REQUEST_UNHANDLED;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_READY);
+	rc = ril_sim_has_reached_state(SIM_STATE_READY);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -849,7 +849,7 @@ int ril_request_change_sim_pin2(void *data, size_t size, RIL_Token token)
 	if (request != NULL)
 		return RIL_REQUEST_UNHANDLED;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_READY);
+	rc = ril_sim_has_reached_state(SIM_STATE_READY);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -965,9 +965,9 @@ int ril_request_sim_io(void *data, size_t size, RIL_Token token)
 	if (data == NULL || size < sizeof(RIL_SIM_IO_compat))
 		goto error;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_READY);
+	rc = ril_sim_has_reached_state(SIM_STATE_READY);
 	if (rc < 0) {
-		rc = ril_radio_has_reached_state(RADIO_STATE_SIM_LOCKED_OR_ABSENT);
+		rc = ril_sim_has_reached_state(SIM_STATE_LOCKED_OR_ABSENT);
 		if (rc < 0)
 			return RIL_REQUEST_UNHANDLED;
 		else
@@ -1128,7 +1128,7 @@ int ipc_sec_lock_infomation(struct ipc_message *message)
 	if (message == NULL || message->data == NULL || message->size < sizeof(struct ipc_sec_lock_information_response_data))
 		return -1;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return 0;
 
diff --git a/sms.c b/sms.c
index 777dd8e..373811d 100644
--- a/sms.c
+++ b/sms.c
@@ -205,7 +205,7 @@ int ril_request_send_sms(void *data, size_t size, RIL_Token token)
 	if (data == NULL || size < 2 * sizeof(char *))
 		goto error;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -345,7 +345,7 @@ int ril_request_write_sms_to_sim(void *data, size_t size, RIL_Token token)
 	if (data == NULL || size < sizeof(RIL_SMS_WriteArgs))
 		goto error;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_READY);
+	rc = ril_sim_has_reached_state(SIM_STATE_READY);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -528,7 +528,7 @@ int ril_request_sms_acknowledge(void *data, size_t size, RIL_Token token)
 	if (data == NULL || size < 2 * sizeof(int))
 		goto error;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_READY);
+	rc = ril_sim_has_reached_state(SIM_STATE_READY);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
diff --git a/ss.c b/ss.c
index 76dbe2a..4d89fde 100644
--- a/ss.c
+++ b/ss.c
@@ -124,7 +124,7 @@ int ril_request_send_ussd(void *data, size_t size, RIL_Token token)
 	if (data == NULL || size < sizeof(char *))
 		goto error;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
@@ -224,7 +224,7 @@ int ril_request_cancel_ussd(__attribute__((unused)) void *data,
 	struct ipc_ss_ussd_header ussd;
 	int rc;
 
-	rc = ril_radio_has_reached_state(RADIO_STATE_SIM_NOT_READY);
+	rc = ril_radio_has_reached_state(RADIO_STATE_ON);
 	if (rc < 0)
 		return RIL_REQUEST_UNHANDLED;
 
diff --git a/tools/srs-test.c b/tools/srs-test.c
index ac91f1a..e460c57 100644
--- a/tools/srs-test.c
+++ b/tools/srs-test.c
@@ -38,7 +38,7 @@ void display_help(void)
 	printf("Commands:\n");
 	printf("  radio-state [STATE] - set radio state\n");
 	printf("\n");
-	printf("States: off, unavailable, sim-not-ready, sim-locked-absent, sim-ready, on\n");
+	printf("States: off, unavailable, on\n");
 }
 
 int radio_state(struct srs_client *client, char *string)
@@ -46,9 +46,6 @@ int radio_state(struct srs_client *client, char *string)
 	struct radio_state_string radio_state_strings[] = {
 		{ "off",		RADIO_STATE_OFF },
 		{ "unavailable",	RADIO_STATE_UNAVAILABLE },
-		{ "sim-not-ready",	RADIO_STATE_SIM_NOT_READY },
-		{ "sim-locked-absent",	RADIO_STATE_SIM_LOCKED_OR_ABSENT },
-		{ "sim-ready",		RADIO_STATE_SIM_READY },
 		{ "on",			RADIO_STATE_ON },
 	};
 	struct srs_test_set_radio_state_data data;
-- 
2.28.0



More information about the Replicant mailing list