use of dalvik.system.DexClassLoader in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DimmableIZatIconPreference method load.
private static void load(Context context) {
if (mLoader == null) {
try {
if (mXtProxyClz == null || mNotifierClz == null) {
mLoader = new DexClassLoader("/system/framework/izat.xt.srv.jar", context.getFilesDir().getAbsolutePath(), null, ClassLoader.getSystemClassLoader());
mXtProxyClz = Class.forName("com.qti.izat.XTProxy", true, mLoader);
mNotifierClz = Class.forName("com.qti.izat.XTProxy$Notifier", true, mLoader);
mIzatPackage = (String) mXtProxyClz.getField("IZAT_XT_PACKAGE").get(null);
mGetXtProxyMethod = mXtProxyClz.getMethod("getXTProxy", Context.class, mNotifierClz);
mGetConsentMethod = mXtProxyClz.getMethod("getUserConsent");
mShowIzatMethod = mXtProxyClz.getMethod("showIzat", Context.class, String.class);
}
} catch (NoSuchMethodException | NullPointerException | SecurityException | NoSuchFieldException | LinkageError | IllegalAccessException | ClassNotFoundException e) {
mXtProxyClz = null;
mNotifierClz = null;
mIzatPackage = null;
mGetXtProxyMethod = null;
mGetConsentMethod = null;
mShowIzatMethod = null;
e.printStackTrace();
}
}
}
use of dalvik.system.DexClassLoader in project dynamic-load-apk by singwhatiwanna.
the class DLPluginManager method preparePluginEnv.
/**
* prepare plugin runtime env, has DexClassLoader, Resources, and so on.
*
* @param packageInfo
* @param dexPath
* @return
*/
private DLPluginPackage preparePluginEnv(PackageInfo packageInfo, String dexPath) {
DLPluginPackage pluginPackage = mPackagesHolder.get(packageInfo.packageName);
if (pluginPackage != null) {
return pluginPackage;
}
DexClassLoader dexClassLoader = createDexClassLoader(dexPath);
AssetManager assetManager = createAssetManager(dexPath);
Resources resources = createResources(assetManager);
// create pluginPackage
pluginPackage = new DLPluginPackage(dexClassLoader, resources, packageInfo);
mPackagesHolder.put(packageInfo.packageName, pluginPackage);
return pluginPackage;
}
use of dalvik.system.DexClassLoader in project AndroidLife by CaMnter.
the class HotFix method injectAboveEqualApiLevel14.
/**
* 大于 API 14 的插桩策略
*
* @param context context
* @param str dex 的路径
* @param str2 插件 dex 中要修复的类 name
* @throws ClassNotFoundException
* @throws NoSuchFieldException
* @throws IllegalAccessException
*/
private static void injectAboveEqualApiLevel14(Context context, String str, String str2) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
PathClassLoader pathClassLoader = (PathClassLoader) context.getClassLoader();
Object a = combineArray(getDexElements(getPathList(pathClassLoader)), getDexElements(getPathList(new DexClassLoader(str, context.getDir("dex", 0).getAbsolutePath(), str, context.getClassLoader()))));
Object a2 = getPathList(pathClassLoader);
setField(a2, a2.getClass(), "dexElements", a);
pathClassLoader.loadClass(str2);
}
use of dalvik.system.DexClassLoader in project AndroidLife by CaMnter.
the class HotFix method injectBelowApiLevel14.
/**
* 小于 API 14 的插桩策略
*
* @param context context
* @param str 插件 dex 的路径
* @param str2 插件 dex 中要修复的类 name
* @throws ClassNotFoundException
* @throws NoSuchFieldException
* @throws IllegalAccessException
*/
@TargetApi(14)
private static void injectBelowApiLevel14(Context context, String str, String str2) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
PathClassLoader obj = (PathClassLoader) context.getClassLoader();
DexClassLoader dexClassLoader = new DexClassLoader(str, context.getDir("dex", 0).getAbsolutePath(), str, context.getClassLoader());
dexClassLoader.loadClass(str2);
setField(obj, PathClassLoader.class, "mPaths", appendArray(getField(obj, PathClassLoader.class, "mPaths"), getField(dexClassLoader, DexClassLoader.class, "mRawDexPath")));
setField(obj, PathClassLoader.class, "mFiles", combineArray(getField(obj, PathClassLoader.class, "mFiles"), getField(dexClassLoader, DexClassLoader.class, "mFiles")));
setField(obj, PathClassLoader.class, "mZips", combineArray(getField(obj, PathClassLoader.class, "mZips"), getField(dexClassLoader, DexClassLoader.class, "mZips")));
setField(obj, PathClassLoader.class, "mDexs", combineArray(getField(obj, PathClassLoader.class, "mDexs"), getField(dexClassLoader, DexClassLoader.class, "mDexs")));
obj.loadClass(str2);
}
use of dalvik.system.DexClassLoader in project My-MVP by REBOOTERS.
the class FixDexUtils method doDexInject.
private static void doDexInject(Context appContext, HashSet<File> loadedDex) {
// data/data/包名/files/optimize_dex(这个必须是自己程序下的目录)
String optimizeDir = appContext.getFilesDir().getAbsolutePath() + File.separator + OPTIMIZE_DEX_DIR;
File fopt = new File(optimizeDir);
if (!fopt.exists()) {
fopt.mkdirs();
}
try {
// 1.加载应用程序的dex
PathClassLoader pathLoader = (PathClassLoader) appContext.getClassLoader();
for (File dex : loadedDex) {
// 2.加载指定的修复的dex文件
DexClassLoader dexLoader = new DexClassLoader(// 修复好的dex(补丁)所在目录
dex.getAbsolutePath(), // 存放dex的解压目录(用于jar、zip、apk格式的补丁)
fopt.getAbsolutePath(), // 加载dex时需要的库
null, // 父类加载器
pathLoader);
// 3.合并
Object dexPathList = getPathList(dexLoader);
Object pathPathList = getPathList(pathLoader);
Object leftDexElements = getDexElements(dexPathList);
Object rightDexElements = getDexElements(pathPathList);
// 合并完成
Object dexElements = combineArray(leftDexElements, rightDexElements);
// 重写给PathList里面的Element[] dexElements;赋值
Object pathList = getPathList(pathLoader);
setField(pathList, pathList.getClass(), "dexElements", dexElements);
}
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations