Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 379e40fc authored by Steve Kondik's avatar Steve Kondik Committed by Gerrit Code Review
Browse files

Merge "telephony: Use reflection to create command interface (RIL class)" into ics

parents 6176eb74 92768571
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ import com.android.internal.telephony.gsm.GSMPhone;
import com.android.internal.telephony.sip.SipPhone;
import com.android.internal.telephony.sip.SipPhoneFactory;

import java.lang.reflect.Constructor;

/**
 * {@hide}
 */
@@ -133,7 +135,20 @@ public class PhoneFactory {
                Log.i(LOG_TAG, "Cdma Subscription set to " + cdmaSubscription);

                //reads the system properties and makes commandsinterface
                sCommandsInterface = new RIL(context, networkMode, cdmaSubscription);
                String sRILClassname = SystemProperties.get("ro.telephony.ril_class", "RIL");
                Log.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});
                } 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.
                    Log.wtf(LOG_TAG, "Unable to construct command interface", e);
                    throw new RuntimeException(e);
                }

                int phoneType = getPhoneType(networkMode);
                if (phoneType == Phone.PHONE_TYPE_GSM) {