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

Commit dba8c390 authored by Pawit Pornkitprasan's avatar Pawit Pornkitprasan Committed by codeworkx
Browse files

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

Change-Id: Icdc02eaa74b89dbde4ddfb989cc62481d6423312
parent c8c9af02
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@ import com.android.internal.telephony.sip.SipPhone;
import com.android.internal.telephony.sip.SipPhoneFactory;
import com.android.internal.telephony.uicc.UiccController;

import java.lang.reflect.Constructor;

/**
 * {@hide}
 */
@@ -137,7 +139,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);
                }

                // Instantiate UiccController so that all other classes can just call getInstance()
                UiccController.make(context, sCommandsInterface);