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

Commit 158dcb1d authored by maxwen's avatar maxwen Committed by Luca Stefani
Browse files

Telephony: dont scare AOSP people



* On AOSP it's ok to not have QtiTelephonyComponentFactory
  so don't scare them with a stack trace but a nice message only

Change-Id: I6644c4df91f1fbb775c368c62ef1ad90e1874cf7

telephony: Construct TelephonyComponentFactory correctly wo qti jar.

* In the absence of the file "/system/frameworks/qti-telephony-common.jar",
  the default TelephonyComponentFactory shall be instantiated.
  This fails in the current version, since the ClassLoader already
  produces an exception in the absence of the jar. Hence, place
  the ClassLoader construction in the try statement such that
  a TelephonyComponentFactory is constructed for the singleton.
* No stack trace is shown when the jar is abscent, but an
  informative message as intended before.

Change-Id: I3b7970ac3f58483d9a044a4252775bf7d32ac217
Signed-off-by: default avatarAlexander Diewald <Diewi@diewald-net.com>
parent 53d2dcbb
Loading
Loading
Loading
Loading
+7 −21
Original line number Diff line number Diff line
@@ -31,15 +31,11 @@ import com.android.internal.telephony.dataconnection.DcTracker;
import com.android.internal.telephony.imsphone.ImsExternalCallTracker;
import com.android.internal.telephony.imsphone.ImsPhone;
import com.android.internal.telephony.imsphone.ImsPhoneCallTracker;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.SubscriptionController;
import com.android.internal.telephony.uicc.IccCardProxy;

import dalvik.system.PathClassLoader;

import java.lang.reflect.Method;
import java.lang.reflect.Constructor;
import java.io.File;

/**
 * This class has one-line methods to instantiate objects only. The purpose is to make code
@@ -56,28 +52,18 @@ public class TelephonyComponentFactory {
            String fullClsName = "com.qualcomm.qti.internal.telephony.QtiTelephonyComponentFactory";
            String libPath = "/system/framework/qti-telephony-common.jar";

            try {
                PathClassLoader classLoader = new PathClassLoader(libPath,
                        ClassLoader.getSystemClassLoader());
            Rlog.d(LOG_TAG, "classLoader = " + classLoader);

            if (fullClsName == null || fullClsName.length() == 0) {
                Rlog.d(LOG_TAG, "no customized TelephonyPlugin available, fallback to default");
                fullClsName = "com.android.internal.telephony.TelephonyComponentFactory";
            }
            Class<?> cls = null;
            try {
                cls = Class.forName(fullClsName, false, classLoader);
                Rlog.d(LOG_TAG, "cls = " + cls);
                Class<?> cls = Class.forName(fullClsName, false, classLoader);
                Constructor custMethod = cls.getConstructor();
                Rlog.d(LOG_TAG, "constructor method = " + custMethod);
                sInstance = (TelephonyComponentFactory) custMethod.newInstance();
            } catch (NoClassDefFoundError e) {
                e.printStackTrace();
                Rlog.e(LOG_TAG, "error loading TelephonyComponentFactory");
                Rlog.i(LOG_TAG, "Using QtiTelephonyComponentFactory");
            } catch (NoClassDefFoundError | ClassNotFoundException e) {
                Rlog.e(LOG_TAG, "QtiTelephonyComponentFactory not used - fallback to default");
                sInstance = new TelephonyComponentFactory();
            } catch (Exception  e) {
                e.printStackTrace();
                Rlog.e(LOG_TAG, "Error loading TelephonyComponentFactory");
                Rlog.e(LOG_TAG, "Error loading QtiTelephonyComponentFactory - fallback to default");
                sInstance = new TelephonyComponentFactory();
            }
        }