summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/rilmodem/rilutil.c24
-rw-r--r--drivers/rilmodem/rilutil.h2
2 files changed, 26 insertions, 0 deletions
diff --git a/drivers/rilmodem/rilutil.c b/drivers/rilmodem/rilutil.c
index f59f2541..dc9c3ccd 100644
--- a/drivers/rilmodem/rilutil.c
+++ b/drivers/rilmodem/rilutil.c
@@ -119,3 +119,27 @@ const char *ril_util_gprs_proto_to_ril_string(enum ofono_gprs_proto proto)
return "IP";
}
}
+
+int ril_util_registration_state_to_status(int reg_state)
+{
+ switch (reg_state) {
+ case RIL_REG_STATE_NOT_REGISTERED:
+ case RIL_REG_STATE_REGISTERED:
+ case RIL_REG_STATE_SEARCHING:
+ case RIL_REG_STATE_DENIED:
+ case RIL_REG_STATE_UNKNOWN:
+ case RIL_REG_STATE_ROAMING:
+ break;
+
+ case RIL_REG_STATE_EMERGENCY_NOT_REGISTERED:
+ case RIL_REG_STATE_EMERGENCY_SEARCHING:
+ case RIL_REG_STATE_EMERGENCY_DENIED:
+ case RIL_REG_STATE_EMERGENCY_UNKNOWN:
+ reg_state -= RIL_REG_STATE_EMERGENCY_NOT_REGISTERED;
+ break;
+ default:
+ reg_state = NETWORK_REGISTRATION_STATUS_UNKNOWN;
+ }
+
+ return reg_state;
+}
diff --git a/drivers/rilmodem/rilutil.h b/drivers/rilmodem/rilutil.h
index 91996da5..bd5a5b11 100644
--- a/drivers/rilmodem/rilutil.h
+++ b/drivers/rilmodem/rilutil.h
@@ -124,6 +124,8 @@ static inline int ril_util_convert_signal_strength(int strength)
const char *ril_util_gprs_proto_to_ril_string(enum ofono_gprs_proto);
+int ril_util_registration_state_to_status(int reg_state);
+
#define DECLARE_FAILURE(e) \
struct ofono_error e; \
e.type = OFONO_ERROR_TYPE_FAILURE; \