aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRicardo Cerqueira <cyanogenmod@cerqueira.org>2014-01-14 00:27:07 +0000
committerGerrit Code Review <gerrit@cyanogenmod.org>2014-01-14 00:27:07 +0000
commit6ae6e0da285dfa698161e88d68504d7b4f000a77 (patch)
treef62330bd8a85e324c88ea6e4256bdebf21b5b16c /src
parentd6d8fe5a33e6d8db4a94218ab8304bba52a8748e (diff)
parentad87d6244fe628feee77931258c75585b10527b2 (diff)
downloadandroid_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.java19
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(