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;
}
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;
}
Aggregations