summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoey Hewitt <joey@joeyhewitt.com>2017-08-31 18:28:27 -0700
committerJoey Hewitt <joey@joeyhewitt.com>2017-09-01 20:33:16 -0700
commite67ecb23324622550fb24c38ba8a68eaa191eee6 (patch)
tree99694078a9f592594047f37d1a822aae9fcb6142
parent32e50f36641e74bd19aab167ea2cb29137aadfaa (diff)
downloadframeworks_opt_telephony_ril_ofono-e67ecb23324622550fb24c38ba8a68eaa191eee6.tar.gz
frameworks_opt_telephony_ril_ofono-e67ecb23324622550fb24c38ba8a68eaa191eee6.tar.bz2
frameworks_opt_telephony_ril_ofono-e67ecb23324622550fb24c38ba8a68eaa191eee6.zip
switch oFono to Gobi driver!
Basic network info, and SMS seem to be working. No calls or USSD, as they are not supported by the oFono mainline. * update init.rc patches * fix some assumptions I made (ConnManager was sometimes not available in the QMI version, causing crash; and incoming SMSs seem to have no SMSC) * change hardcoded (in one place) dbus path to the modem
-rw-r--r--patches/system_core.patch33
-rwxr-xr-xpush2
-rw-r--r--src/java/net/scintill/ril_ofono/DataConnModule.java9
-rw-r--r--src/java/net/scintill/ril_ofono/RilOfono.java2
-rw-r--r--src/java/net/scintill/ril_ofono/SmsModule.java24
-rw-r--r--src/java/net/scintill/ril_ofono/Tests.java4
-rwxr-xr-xstart4
-rwxr-xr-xstop6
8 files changed, 59 insertions, 25 deletions
diff --git a/patches/system_core.patch b/patches/system_core.patch
index 5de2cae..cea648d 100644
--- a/patches/system_core.patch
+++ b/patches/system_core.patch
@@ -1,34 +1,31 @@
diff --git a/rootdir/init.rc b/rootdir/init.rc
-index 001ab13..6029d3c 100644
+index 001ab13..659b9a4 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
-@@ -561,6 +561,30 @@ service ril-daemon /system/bin/rild
+@@ -561,6 +561,27 @@ service ril-daemon /system/bin/rild
user root
group radio cache inet misc audio sdcard_rw qcom_diag log
+service dbus /system/bin/dbus-daemon --system --nofork
++ disabled
+ class main
+ socket dbus stream 0660 root radio
+ user radio
+ group radio
+
-+service ofonod /system/bin/ofonod --nodetach
-+ disabled
-+ class main
-+ user radio
-+ group radio
-+ setenv OFONO_RIL_DEVICE ril
-+ setenv OFONO_RIL_RAT_LTE 1
++service qmiserial2qmuxd /system/bin/qmiserial2qmuxd
++ disabled
++ class main
++ user radio
++ group radio
+
-+service ofonod-debug /system/bin/ofonod --nodetach --debug
-+ disabled
-+ class main
-+ user radio
-+ group radio
-+ setenv OFONO_RIL_DEVICE ril
-+ setenv OFONO_RIL_RAT_LTE 1
-+ setenv OFONO_RIL_TRACE 1
-+ setenv OFONO_RIL_HEX_TRACE 1
++service ofonod /system/bin/ofonod --nodetach --debug
++ disabled
++ class main
++ user radio
++ group radio
++ setenv OFONO_GOBI_DEVICE /data/misc/radio/qmiserial
++ setenv OFONO_QMI_DEBUG 1
+
service surfaceflinger /system/bin/surfaceflinger
class core
diff --git a/push b/push
index 9691949..b9a4166 100755
--- a/push
+++ b/push
@@ -1,2 +1,2 @@
#!/bin/bash
-adb push {$ANDROID_PRODUCT_OUT,}/system/app/RilOfono
+adb push {$ANDROID_PRODUCT_OUT,}/system/app/RilOfono/RilOfono.apk
diff --git a/src/java/net/scintill/ril_ofono/DataConnModule.java b/src/java/net/scintill/ril_ofono/DataConnModule.java
index 956710b..d9a5885 100644
--- a/src/java/net/scintill/ril_ofono/DataConnModule.java
+++ b/src/java/net/scintill/ril_ofono/DataConnModule.java
@@ -211,8 +211,13 @@ import static net.scintill.ril_ofono.RilOfono.runOnMainThreadDebounced;
* this value to off detaches the modem from the
* Packet Domain network.
*/
- mConnMan.SetProperty("Powered", new Variant<>(allowed));
- respondOk("setDataAllowed", result, null);
+ try {
+ mConnMan.SetProperty("Powered", new Variant<>(allowed));
+ respondOk("setDataAllowed", result, null);
+ } catch (Throwable t) {
+ Rlog.e(TAG, "Exception setting ConnMan.Powered to "+allowed, t);
+ respondExc("setDataAllowed", result, GENERIC_FAILURE, null);
+ }
}
@RilMethod
diff --git a/src/java/net/scintill/ril_ofono/RilOfono.java b/src/java/net/scintill/ril_ofono/RilOfono.java
index dfcb131..fa33276 100644
--- a/src/java/net/scintill/ril_ofono/RilOfono.java
+++ b/src/java/net/scintill/ril_ofono/RilOfono.java
@@ -978,7 +978,7 @@ public class RilOfono extends BaseCommands implements CommandsInterface {
// iccTransmitApduBasicChannel(), getAtr(), setLocalCallHold()
private static final String OFONO_BUS_NAME = "org.ofono";
- private static final String MODEM_PATH = "/ril_0";
+ private static final String MODEM_PATH = "/gobi_0"; // TODO make this dynamically use the "first" modem we see (because we only expect one)
/*package*/ <T extends DBusInterface> T getOfonoInterface(Class<T> tClass) {
return getOfonoInterface(tClass, MODEM_PATH);
diff --git a/src/java/net/scintill/ril_ofono/SmsModule.java b/src/java/net/scintill/ril_ofono/SmsModule.java
index ebb881d..6992de4 100644
--- a/src/java/net/scintill/ril_ofono/SmsModule.java
+++ b/src/java/net/scintill/ril_ofono/SmsModule.java
@@ -114,14 +114,34 @@ import static net.scintill.ril_ofono.RilOfono.runOnMainThread;
@Override
public void run() {
try {
- mSmsRegistrants.notifyResult(SmsMessage.createFromPdu(s.pdu, SmsConstants.FORMAT_3GPP));
+ SmsMessage msg = SmsMessage.createFromPdu(normalizePdu(s.pdu, s.tpdu_len), SmsConstants.FORMAT_3GPP);
+ try {
+ // someone decided to swallow exceptions and return null as the wrapped object, so check it
+ if (msg != null) msg.getTimestampMillis();
+ } catch (NullPointerException e) {
+ // SmsMessage probably logged more information about the cause, but I want to know what the PDU was
+ Rlog.e(TAG, "Null returned from parsing incoming PDU "+privStr(IccUtils.bytesToHexString(s.pdu)+" tpdu_len="+s.tpdu_len));
+ }
+ mSmsRegistrants.notifyResult(msg);
} catch (Throwable t) {
- Rlog.e(TAG, "Error parsing incoming PDU "+privStr(IccUtils.bytesToHexString(s.pdu)), t);
+ Rlog.e(TAG, "Error handling incoming PDU "+privStr(IccUtils.bytesToHexString(s.pdu)+" tpdu_len="+s.tpdu_len));
}
}
});
}
+ private static byte[] normalizePdu(byte[] pdu, int tpdu_len) {
+ // pdu might have smsc prefixed. Android PDU parser assumes it's always there
+ if (tpdu_len == pdu.length) {
+ byte[] npdu = new byte[pdu.length + 1];
+ npdu[0] = 0;
+ System.arraycopy(pdu, 0, npdu, 1, pdu.length);
+ return npdu;
+ } else {
+ return pdu;
+ }
+ }
+
public void handle(org.ofono.Message.PropertyChanged s) {
if (s.name.equals("State")) {
String value = (String) s.value.getValue();
diff --git a/src/java/net/scintill/ril_ofono/Tests.java b/src/java/net/scintill/ril_ofono/Tests.java
index 682a713..f7758dd 100644
--- a/src/java/net/scintill/ril_ofono/Tests.java
+++ b/src/java/net/scintill/ril_ofono/Tests.java
@@ -57,6 +57,10 @@ public class Tests implements Runnable {
private void injectReceivedMessage(String sender, String text, Date date, boolean immediate) throws Throwable {
byte[] pdu = createReceivedMessage(sender, text, date, immediate);
+ injectReceivedMessage(pdu);
+ }
+
+ private void injectReceivedMessage(byte[] pdu) throws Throwable {
MessageManager.IncomingPdu s = new MessageManager.IncomingPdu("/", pdu, (byte)((pdu.length-1) & 0xff));
mSmsModule.handle(s);
}
diff --git a/start b/start
index 2045337..cd22817 100755
--- a/start
+++ b/start
@@ -1,3 +1,7 @@
#!/bin/bash
./push
+adb shell su root stop ril-daemon
+adb shell su root start dbus
+adb shell su root start qmiserial2qmuxd
+adb shell su root start ofonod
adb shell setprop debug.scintill.ril_class net.scintill.ril_ofono/.RilOfono \; killall com.android.phone
diff --git a/stop b/stop
index c83597e..727242f 100755
--- a/stop
+++ b/stop
@@ -1,2 +1,6 @@
#!/bin/bash
-adb shell setprop debug.scintill.ril_class '' \; killall com.android.phone
+adb shell su root stop ofonod
+adb shell su root stop qmiserial2qmuxd
+adb shell su root stop dbus
+adb shell su root start ril-daemon
+adb shell setprop debug.scintill.ril_class '""' \; killall com.android.phone