summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoey Hewitt <joey@joeyhewitt.com>2017-08-24 21:25:24 -0700
committerJoey Hewitt <joey@joeyhewitt.com>2017-08-30 21:50:53 -0700
commitb591bc3bce5d5b2cb26fd76cd6169ea17fc9f222 (patch)
treebbfc4a359b1d994723758fb96cf6e9c5e9d879dc
parent05d2a30bfa31d2477427e7db627e62502da67bea (diff)
downloadframeworks_opt_telephony_ril_ofono-b591bc3bce5d5b2cb26fd76cd6169ea17fc9f222.tar.gz
frameworks_opt_telephony_ril_ofono-b591bc3bce5d5b2cb26fd76cd6169ea17fc9f222.tar.bz2
frameworks_opt_telephony_ril_ofono-b591bc3bce5d5b2cb26fd76cd6169ea17fc9f222.zip
fixes to work with new StrictMode enforcement
-rwxr-xr-xmount1
-rw-r--r--src/java/net/scintill/ril_ofono/RilOfono.java52
2 files changed, 38 insertions, 15 deletions
diff --git a/mount b/mount
index e9fda8a..057ca93 100755
--- a/mount
+++ b/mount
@@ -10,6 +10,7 @@ $CMBASE/frameworks/base/telephony/java:\
$CMBASE/frameworks/base/telecomm/java:\
$CMBASE/frameworks/opt/telephony/src/java:\
$CMBASE/libcore/luni/src/main/java:\
+$CMBASE/libcore/dalvik/src/main/java:\
$CMBASE/packages/services/Telephony/src\
\
$BASE/lib/java/android/
diff --git a/src/java/net/scintill/ril_ofono/RilOfono.java b/src/java/net/scintill/ril_ofono/RilOfono.java
index edbab3c..dfcb131 100644
--- a/src/java/net/scintill/ril_ofono/RilOfono.java
+++ b/src/java/net/scintill/ril_ofono/RilOfono.java
@@ -26,6 +26,7 @@ import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.os.Registrant;
+import android.os.StrictMode;
import android.telephony.Rlog;
import android.text.TextUtils;
@@ -92,25 +93,33 @@ public class RilOfono extends BaseCommands implements CommandsInterface {
mPhoneType = RILConstants.NO_PHONE;
- HandlerThread dbusThread = new HandlerThread("dbus");
+ HandlerThread dbusThread = new HandlerThread("RilOfonoDbusThread");
dbusThread.start();
mMainHandler = new Handler(new EmptyHandlerCallback());
mDbusHandler = new Handler(dbusThread.getLooper(), new EmptyHandlerCallback());
- try {
- mDbus = DBusConnection.getConnection(DBUS_ADDRESS);
- } catch (DBusException e) {
- logException("RilOfono", e);
- System.exit(-1); // XXX how to better react to this?
- }
- mModemModule = new ModemModule(mVoiceNetworkStateRegistrants, mVoiceRadioTechChangedRegistrants);
- mSmsModule = new SmsModule(new DynamicRegistrantListFromField("mGsmSmsRegistrant")); // TODO gsm-specific
- mSimModule = new SimModule(mIccStatusChangedRegistrants);
- mCallModule = new CallModule(mCallStateRegistrants);
- mDataConnModule = new DataConnModule(mDataNetworkStateRegistrants);
- mSupplSvcsModule = new SupplementaryServicesModule(new DynamicRegistrantListFromField("mUSSDRegistrant"));
- mModemModule.onModemChange(false); // initialize starting state
-
+ // We can't really return until the objects below are created
+ // (otherwise calls start coming in while we have null pointers), and the objects need dbus,
+ // so this is one time we'll allow network on main.
+ runWithNetworkPermittedOnMainThread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ mDbus = DBusConnection.getConnection(DBUS_ADDRESS);
+
+ mModemModule = new ModemModule(mVoiceNetworkStateRegistrants, mVoiceRadioTechChangedRegistrants);
+ mSmsModule = new SmsModule(new DynamicRegistrantListFromField("mGsmSmsRegistrant")); // TODO gsm-specific
+ mSimModule = new SimModule(mIccStatusChangedRegistrants);
+ mCallModule = new CallModule(mCallStateRegistrants);
+ mDataConnModule = new DataConnModule(mDataNetworkStateRegistrants);
+ mSupplSvcsModule = new SupplementaryServicesModule(new DynamicRegistrantListFromField("mUSSDRegistrant"));
+ mModemModule.onModemChange(false); // initialize starting state
+ } catch (DBusException e) {
+ logException("RilOfono", e);
+ System.exit(-1); // XXX how to better react to this?
+ }
+ }
+ });
// TODO register with TelephonyDevController ?
//mMainHandler.postDelayed(new Tests(mSmsModule), 10000);
@@ -1163,6 +1172,19 @@ public class RilOfono extends BaseCommands implements CommandsInterface {
}
}
+ private static void runWithNetworkPermittedOnMainThread(Runnable r) {
+ StrictMode.ThreadPolicy standardPolicy = StrictMode.getThreadPolicy();
+ StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder(standardPolicy)
+ .permitNetwork()
+ .build());
+
+ try {
+ r.run();
+ } finally {
+ StrictMode.setThreadPolicy(standardPolicy);
+ }
+ }
+
}
// mostly a tag type to remind me use this correctly (only construct one for each purpose)