summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2015-12-01 12:51:24 -0600
committerDenis Kenzior <denkenz@gmail.com>2015-12-01 12:51:24 -0600
commit0f86f7b15c240f6d8df09e5039cf28ef1a02eda7 (patch)
treef0144d519609889696886d4fe52180f353da7bd7
parentf98d2aa2823d318cb4a26a8cd8010e5bd0381695 (diff)
downloadofono-0f86f7b15c240f6d8df09e5039cf28ef1a02eda7.tar.bz2
rilmodem: Add ril_util_registration_state_to_status
-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; \