summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaulK <contact@paulk.fr>2012-02-21 00:21:31 +0100
committerPaulK <contact@paulk.fr>2012-02-21 00:21:31 +0100
commitd7f131710d21ebc0f20ef2f424f20594658cdecb (patch)
tree0196a3accfb7db77b57972da3279e886f990c744
parent1141eccadafb85d9268a1908ba87bae4f722a507 (diff)
downloadhardware_ril_samsung-ril-d7f131710d21ebc0f20ef2f424f20594658cdecb.zip
hardware_ril_samsung-ril-d7f131710d21ebc0f20ef2f424f20594658cdecb.tar.gz
hardware_ril_samsung-ril-d7f131710d21ebc0f20ef2f424f20594658cdecb.tar.bz2
Using the global Operators list on QUERY_AVAILABLE_NETWORKS and added the table gen script
-rwxr-xr-xinclude/plmn_list.sh81
-rw-r--r--net.c25
2 files changed, 87 insertions, 19 deletions
diff --git a/include/plmn_list.sh b/include/plmn_list.sh
new file mode 100755
index 0000000..2c6e532
--- /dev/null
+++ b/include/plmn_list.sh
@@ -0,0 +1,81 @@
+#!/bin/sh
+#
+# Copyright 2012 Paul Kocialkowski, GPLv3+
+#
+# This script is a dirty hack, keep in mind that is was written in a hurry
+# and doesn't reflect our code cleanness standards.
+# Any (working) replacement written in a cleaner way, such as a perl script
+# would be greatly appreciated.
+
+echo "/**"
+echo " * This list was generated from http://en.wikipedia.org/wiki/Mobile_Network_Code"
+echo " * "
+echo " * Date: "$( date "+%x %X" )
+echo " * Copyright: Wikipedia Contributors, Creative Commons Attribution-ShareAlike License"
+echo " */"
+echo ""
+echo "#ifndef _PLMN_LIST_H_"
+echo "#define _PLMN_LIST_H_"
+echo ""
+echo "struct plmn_list_entry {"
+echo " unsigned int mcc;"
+echo " unsigned int mnc;"
+echo " char *operator_long;"
+echo " char *operator_short;"
+echo "};"
+echo ""
+echo "struct plmn_list_entry plmn_list[] = {"
+
+wget "http://en.wikipedia.org/w/index.php?title=Special:Export&pages=Mobile_Network_Code&action=submit" --quiet -O - | tr -d '\n' | sed -e "s|.*<text[^>]*>\(.*\)</text>.*|\1|g" -e "s/|-/\n|-\n/g" | sed -e "s/\(}===.*\)/\n\1/g" -e "s/===={.*/===={\n/g" -e "s/\&amp;/\&/g" -e "s/\&lt;[^\&]*\&gt;//g" -e "s/&quot;//g" -e "s#\[http[^]]*\]##g" -e "s#\[\[\([^]|]*\)|\([^]]*\)\]\]#\2#g" -e "s#\[\[\([^]]*\)\]\]#\1#g" -e "s#\[\([^] ]*\) \([^]]*\)\]#\2#g" | tail -n +2 | sed "s|.*=== \(.*\) ===.*|// \1|g" | grep -v "|-" | while read line
+do
+ if [ "$line" = "" ]
+ then
+ continue
+ fi
+
+ test=$( echo "$line" | grep -P "^//" )
+
+ if [ ! "$test" = "" ]
+ then
+ echo "\n\t$line\n" | sed -e "s#[^|]*|\(.*\)#// \1#g" -e "s/^ //g" -e "s/ $//g"
+ continue
+ fi
+
+ test=$( echo "$line" | grep "||" )
+
+ if [ "$test" = "" ]
+ then
+ continue
+ fi
+
+ mcc=$( echo "$line" | sed -e "s#[^|]*|[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\).*#\1#g" -e "s/^ //g" -e "s/ $//g" -e "s/[^1-9]*\([0-9]*\).*/\1/g")
+ mnc=$( echo "$line" | sed -e "s#[^|]*|[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\).*#\2#g" -e "s/^ //g" -e "s/ $//g" -e "s/[^1-9]*\([0-9]*\).*/\1/g")
+ brand=$( echo "$line" | sed -e "s#[^|]*|[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\).*#\3#g" -e "s/^ //g" -e "s/ $//g" )
+ operator=$( echo "$line" | sed -e "s#[^|]*|[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\).*#\4#g" -e "s/^ //g" -e "s/ $//g" )
+
+ if [ "$mcc" = "" ] || [ "$mcc" = "?" ]
+ then
+ continue
+ fi
+
+ if [ "$mnc" = "" ] || [ "$mnc" = "?" ]
+ then
+ continue
+ fi
+
+ if [ "$brand" = "" ]
+ then
+ if [ "$operator" = "" ]
+ then
+ continue
+ fi
+
+ echo "\t{ $mcc, $mnc, \"$operator\", \"$operator\" },"
+ else
+ echo "\t{ $mcc, $mnc, \"$brand\", \"$brand\" },"
+ fi
+done
+
+echo "};"
+echo ""
+echo "#endif"
diff --git a/net.c b/net.c
index eb217c2..4fd1f61 100644
--- a/net.c
+++ b/net.c
@@ -191,7 +191,7 @@ void ril_tokens_net_state_dump(void)
}
-void ril_plmn_string(struct ipc_net_current_plmn *plmndata, char *response[3])
+void ril_plmn_string(char *plmn_data, char *response[3])
{
unsigned int mcc, mnc;
char plmn[7];
@@ -200,7 +200,7 @@ void ril_plmn_string(struct ipc_net_current_plmn *plmndata, char *response[3])
int i;
memset(plmn, 0, sizeof(plmn));
- memcpy(plmn, plmndata->plmn, 6);
+ memcpy(plmn, plmn_data, 6);
if(plmn[5] == '#')
plmn[5] = '\0';
@@ -292,7 +292,7 @@ void ril_request_operator(RIL_Token t)
LOGD("Got RILJ request for UNSOL data");
/* Send back the data we got UNSOL */
- ril_plmn_string(&(ril_state.plmndata), response);
+ ril_plmn_string(ril_state.plmndata.plmn, response);
RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response));
@@ -312,7 +312,7 @@ void ril_request_operator(RIL_Token t)
LOGE("Another request is going on, returning UNSOL data");
/* Send back the data we got UNSOL */
- ril_plmn_string(&(ril_state.plmndata), response);
+ ril_plmn_string(ril_state.plmndata.plmn, response);
RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response));
@@ -393,7 +393,7 @@ void ipc_net_current_plmn(struct ipc_message_info *message)
/* Better keeping it up to date */
memcpy(&(ril_state.plmndata), plmndata, sizeof(struct ipc_net_current_plmn));
- ril_plmn_string(plmndata, response);
+ ril_plmn_string(plmndata->plmn, response);
RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response));
@@ -684,20 +684,7 @@ void ipc_net_plmn_list(struct ipc_message_info *info)
if(entries[i].type == 0x01)
continue;
- char *plmn = plmn_string(entries[i].plmn);
-
- LOGD("PLMN #%d: %s (%s)\n", i, plmn_lookup(plmn), plmn);
-
- /* Long (E)ONS */
- asprintf(&resp_ptr[0], "%s", plmn_lookup(plmn));
-
- /* Short (E)ONS - FIXME: real short EONS */
- asprintf(&resp_ptr[1], "%s", plmn_lookup(plmn));
-
- /* PLMN */
- asprintf(&resp_ptr[2], "%s", plmn);
-
- free(plmn);
+ ril_plmn_string(entries[i].plmn, resp_ptr);
/* PLMN status */
switch(entries[i].status) {