Search in sources :

Example 56 with PathClassLoader

use of dalvik.system.PathClassLoader in project android_frameworks_opt_telephony by LineageOS.

the class TelephonyComponentFactory method getInstance.

public static TelephonyComponentFactory getInstance() {
    if (sInstance == null) {
        String fullClsName = "com.qualcomm.qti.internal.telephony.QtiTelephonyComponentFactory";
        String libPath = "/system/framework/qti-telephony-common.jar";
        try {
            PathClassLoader classLoader = new PathClassLoader(libPath, ClassLoader.getSystemClassLoader());
            Class<?> cls = Class.forName(fullClsName, false, classLoader);
            Constructor custMethod = cls.getConstructor();
            sInstance = (TelephonyComponentFactory) custMethod.newInstance();
            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) {
            Rlog.e(LOG_TAG, "Error loading QtiTelephonyComponentFactory - fallback to default");
            sInstance = new TelephonyComponentFactory();
        }
    }
    return sInstance;
}
Also used : PathClassLoader(dalvik.system.PathClassLoader) Constructor(java.lang.reflect.Constructor)

Example 57 with PathClassLoader

use of dalvik.system.PathClassLoader in project tinker by Tencent.

the class TinkerArkHotLoader method loadTinkerArkHot.

/**
 * Load tinker JARs and add them to
 * the Application ClassLoader.
 *
 * @param application The application.
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public static boolean loadTinkerArkHot(final TinkerApplication application, String directory, Intent intentResult) {
    if (arkHotApkInfo.isEmpty()) {
        ShareTinkerLog.w(TAG, "there is no apk to load");
        return true;
    }
    PathClassLoader classLoader = (PathClassLoader) TinkerArkHotLoader.class.getClassLoader();
    if (classLoader != null) {
        ShareTinkerLog.i(TAG, "classloader: " + classLoader.toString());
    } else {
        ShareTinkerLog.e(TAG, "classloader is null");
        ShareIntentUtil.setIntentReturnCode(intentResult, ShareConstants.ERROR_LOAD_PATCH_VERSION_DEX_CLASSLOADER_NULL);
        return false;
    }
    String apkPath = directory + "/" + ARKHOT_PATH + "/";
    ArrayList<File> legalFiles = new ArrayList<>();
    // verify merge classN.apk
    if (isArkHotRuning && !arkHotApkInfo.isEmpty()) {
        File classNFile = null;
        classNFile = new File(apkPath + ShareConstants.ARKHOT_PATCH_NAME);
        legalFiles.add(classNFile);
    }
    try {
        // 加载Apk
        SystemClassLoaderAdder.installApk(classLoader, legalFiles);
    } catch (Throwable e) {
        ShareTinkerLog.e(TAG, "install dexes failed");
        intentResult.putExtra(ShareIntentUtil.INTENT_PATCH_EXCEPTION, e);
        ShareIntentUtil.setIntentReturnCode(intentResult, ShareConstants.ERROR_LOAD_PATCH_VERSION_DEX_LOAD_EXCEPTION);
        return false;
    }
    return true;
}
Also used : PathClassLoader(dalvik.system.PathClassLoader) ArrayList(java.util.ArrayList) File(java.io.File) TargetApi(android.annotation.TargetApi)

Aggregations

PathClassLoader (dalvik.system.PathClassLoader)57 File (java.io.File)14 DexClassLoader (dalvik.system.DexClassLoader)8 IOException (java.io.IOException)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 TargetApi (android.annotation.TargetApi)4 Context (android.content.Context)4 RemoteException (android.os.RemoteException)4 Method (java.lang.reflect.Method)3 ZipFile (java.util.zip.ZipFile)3 ActivityManagerInternal (android.app.ActivityManagerInternal)2 INotificationManager (android.app.INotificationManager)2 ActivityNotFoundException (android.content.ActivityNotFoundException)2 Intent (android.content.Intent)2 IntentFilter (android.content.IntentFilter)2 Configuration (android.content.res.Configuration)2 Resources (android.content.res.Resources)2 Theme (android.content.res.Resources.Theme)2 CameraAccessException (android.hardware.camera2.CameraAccessException)2 InputManagerInternal (android.hardware.input.InputManagerInternal)2