summaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authorAlexander Tarasikov <alexander.tarasikov@gmail.com>2012-07-13 16:30:35 +0400
committerAlexander Tarasikov <alexander.tarasikov@gmail.com>2012-07-13 16:30:35 +0400
commit697e533e23e237cfba07b7054f5e4ab29e4227e2 (patch)
tree53e1ccc7d7fae2f3e1cd72f1d6771eb6af44d637 /util.c
parent98a8d340281ed71aaa0130accd0061d818d46199 (diff)
downloadhardware_ril_samsung-ril-697e533e23e237cfba07b7054f5e4ab29e4227e2.zip
hardware_ril_samsung-ril-697e533e23e237cfba07b7054f5e4ab29e4227e2.tar.gz
hardware_ril_samsung-ril-697e533e23e237cfba07b7054f5e4ab29e4227e2.tar.bz2
Move SmsCodingScheme to utils.c for future reuse
Diffstat (limited to 'util.c')
-rw-r--r--util.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/util.c b/util.c
index 798808d..47cb2c0 100644
--- a/util.c
+++ b/util.c
@@ -23,6 +23,7 @@
#define LOG_TAG "RIL-UTIL"
#include <utils/Log.h>
+#include "util.h"
/**
* Converts a hexidecimal string to binary
@@ -260,3 +261,36 @@ int utf8_write(char *utf8, int offset, int v)
}
return result;
}
+
+SmsCodingScheme sms_get_coding_scheme(int dataCoding)
+{
+ switch (dataCoding >> 4) {
+ case 0x00:
+ case 0x02:
+ case 0x03:
+ return SMS_CODING_SCHEME_GSM7;
+ case 0x01:
+ if (dataCoding == 0x10)
+ return SMS_CODING_SCHEME_GSM7;
+ if (dataCoding == 0x11)
+ return SMS_CODING_SCHEME_UCS2;
+ break;
+ case 0x04:
+ case 0x05:
+ case 0x06:
+ case 0x07:
+ if (dataCoding & 0x20)
+ return SMS_CODING_SCHEME_UNKNOWN;
+ if (((dataCoding >> 2) & 3) == 0)
+ return SMS_CODING_SCHEME_GSM7;
+ if (((dataCoding >> 2) & 3) == 2)
+ return SMS_CODING_SCHEME_UCS2;
+ break;
+ case 0xF:
+ if (!(dataCoding & 4))
+ return SMS_CODING_SCHEME_GSM7;
+ break;
+ }
+ return SMS_CODING_SCHEME_UNKNOWN;
+}
+