diff options
author | Ricardo Cerqueira <cyanogenmod@cerqueira.org> | 2014-01-14 00:27:07 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2014-01-14 00:27:07 +0000 |
commit | 6ae6e0da285dfa698161e88d68504d7b4f000a77 (patch) | |
tree | f62330bd8a85e324c88ea6e4256bdebf21b5b16c /src | |
parent | d6d8fe5a33e6d8db4a94218ab8304bba52a8748e (diff) | |
parent | ad87d6244fe628feee77931258c75585b10527b2 (diff) | |
download | android_frameworks_opt_telephony-6ae6e0da285dfa698161e88d68504d7b4f000a77.tar.gz android_frameworks_opt_telephony-6ae6e0da285dfa698161e88d68504d7b4f000a77.tar.bz2 android_frameworks_opt_telephony-6ae6e0da285dfa698161e88d68504d7b4f000a77.zip |
Merge "PhoneFactory: fall back to default RIL if custom RIL Class fails" into cm-11.0
Diffstat (limited to 'src')
-rw-r--r-- | src/java/com/android/internal/telephony/PhoneFactory.java | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/java/com/android/internal/telephony/PhoneFactory.java b/src/java/com/android/internal/telephony/PhoneFactory.java index b3d5235c1..ab28ff2a4 100644 --- a/src/java/com/android/internal/telephony/PhoneFactory.java +++ b/src/java/com/android/internal/telephony/PhoneFactory.java @@ -117,19 +117,18 @@ public class PhoneFactory { Rlog.i(LOG_TAG, "Cdma Subscription set to " + cdmaSubscription); //reads the system properties and makes commandsinterface - String sRILClassname = SystemProperties.get("ro.telephony.ril_class", "RIL"); + String sRILClassname = SystemProperties.get("ro.telephony.ril_class", "RIL").trim(); Rlog.i(LOG_TAG, "RILClassname is " + sRILClassname); // Use reflection to construct the RIL class (defaults to RIL) try { - Class<?> classDefinition = Class.forName("com.android.internal.telephony." + sRILClassname); - Constructor<?> constructor = classDefinition.getConstructor(new Class[] {Context.class, int.class, int.class}); - sCommandsInterface = (RIL) constructor.newInstance(new Object[] {context, networkMode, cdmaSubscription}); + sCommandsInterface = instantiateCustomRIL( + sRILClassname, context, networkMode, cdmaSubscription); } catch (Exception e) { // 6 different types of exceptions are thrown here that it's // easier to just catch Exception as our "error handling" is the same. - Rlog.i(LOG_TAG, "Unable to construct command interface", e); - throw new RuntimeException(e); + Rlog.e(LOG_TAG, "Unable to construct custom RIL class", e); + sCommandsInterface = new RIL(context, networkMode, cdmaSubscription); } // Instantiate UiccController so that all other classes can just call getInstance() @@ -174,6 +173,14 @@ public class PhoneFactory { } } + private static <T> T instantiateCustomRIL( + String sRILClassname, Context context, int networkMode, int cdmaSubscription) + throws Exception { + Class<?> clazz = Class.forName("com.android.internal.telephony." + sRILClassname); + Constructor<?> constructor = clazz.getConstructor(Context.class, int.class, int.class); + return (T) clazz.cast(constructor.newInstance(context, networkMode, cdmaSubscription)); + } + public static Phone getDefaultPhone() { if (sLooper != Looper.myLooper()) { throw new RuntimeException( |