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

Commit 86350b4e authored by Pawit Pornkitprasan's avatar Pawit Pornkitprasan Committed by Ricardo Cerqueira
Browse files

telephony: Use reflection to create command interface (RIL class)

This has the advantage over the method used in CM7 in that the
RIL class for each device does not have to be specified in this
file in an if statement. ro.telephony.ril_class needs to be upated
to contain the name of the class instead of an identifier as used
in CM7

Change-Id: I0aafdfc78d47f493a2e35819dbe873ea98787934
parent 8bdec2fb
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -30,6 +30,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}
 */
@@ -135,7 +137,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) {