use of dalvik.system.PathClassLoader in project android_frameworks_base by crdroidandroid.
the class NetPluginDelegate method loadTetherExtJar.
private static synchronized boolean loadTetherExtJar() {
final String realProvider = "com.qualcomm.qti.tetherstatsextension.TetherStatsReporting";
final String realProviderPath = Environment.getRootDirectory().getAbsolutePath() + "/framework/ConnectivityExt.jar";
if (tetherExtensionClass != null && tetherExtensionObj != null) {
return true;
}
boolean pathExists = new File(realProviderPath).exists();
if (!pathExists) {
Log.w(TAG, "ConnectivityExt jar file not present");
return false;
}
if (tetherExtensionClass == null && tetherExtensionObj == null) {
if (LOGV)
Slog.v(TAG, "loading ConnectivityExt jar");
try {
PathClassLoader classLoader = new PathClassLoader(realProviderPath, ClassLoader.getSystemClassLoader());
tetherExtensionClass = classLoader.loadClass(realProvider);
tetherExtensionObj = tetherExtensionClass.newInstance();
if (LOGV)
Slog.v(TAG, "ConnectivityExt jar loaded");
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
e.printStackTrace();
Log.w(TAG, "Failed to find, instantiate or access ConnectivityExt jar ");
return false;
} catch (Exception e) {
e.printStackTrace();
Log.w(TAG, "unable to load ConnectivityExt jar");
return false;
}
}
return true;
}
use of dalvik.system.PathClassLoader in project weex-example by KalicyZhou.
the class WXSoInstallMgrSdk method checkSoIsValid.
/**
*
* @param libName lib name
* @param size the right size of lib
* @return true for valid ; false for InValid
*/
static boolean checkSoIsValid(String libName, int size) {
Context context = mContext;
if (null == context) {
return false;
}
try {
long start = System.currentTimeMillis();
if (WXSoInstallMgrSdk.class.getClassLoader() instanceof PathClassLoader) {
String path = ((PathClassLoader) (WXSoInstallMgrSdk.class.getClassLoader())).findLibrary(libName);
File file = new File(path);
if (!file.exists() || size == file.length()) {
WXLogUtils.w("weex so size check path :" + path + " " + (System.currentTimeMillis() - start));
return true;
} else {
return false;
}
}
} catch (Throwable e) {
WXLogUtils.e("weex so size check fail exception :" + e.getMessage());
}
return true;
}
use of dalvik.system.PathClassLoader in project android_frameworks_base by DirtyUnicorns.
the class PathClassLoaderFactory method createClassLoader.
/**
* Create a PathClassLoader and initialize a linker-namespace for it.
*
* @hide
*/
public static PathClassLoader createClassLoader(String dexPath, String librarySearchPath, String libraryPermittedPath, ClassLoader parent, int targetSdkVersion, boolean isNamespaceShared) {
PathClassLoader pathClassloader = new PathClassLoader(dexPath, librarySearchPath, parent);
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "createClassloaderNamespace");
String errorMessage = createClassloaderNamespace(pathClassloader, targetSdkVersion, librarySearchPath, libraryPermittedPath, isNamespaceShared);
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
if (errorMessage != null) {
throw new UnsatisfiedLinkError("Unable to create namespace for the classloader " + pathClassloader + ": " + errorMessage);
}
return pathClassloader;
}
use of dalvik.system.PathClassLoader in project incubator-weex by apache.
the class WXSoInstallMgrSdk method checkSoIsValid.
/**
* @param libName lib name
* @param size the right size of lib
* @return true for valid ; false for InValid
*/
static boolean checkSoIsValid(String libName, long size) {
Context context = mContext;
if (null == context) {
return false;
}
try {
long start = System.currentTimeMillis();
if (WXSoInstallMgrSdk.class.getClassLoader() instanceof PathClassLoader) {
String path = ((PathClassLoader) (WXSoInstallMgrSdk.class.getClassLoader())).findLibrary(libName);
if (TextUtils.isEmpty(path)) {
return false;
}
File file = new File(path);
if (!file.exists() || size == file.length()) {
WXLogUtils.w("weex so size check path :" + path + " " + (System.currentTimeMillis() - start));
return true;
} else {
return false;
}
}
} catch (Throwable e) {
WXExceptionUtils.commitCriticalExceptionRT(null, WXErrorCode.WX_KEY_EXCEPTION_SDK_INIT, "checkSoIsValid", "[WX_KEY_EXCEPTION_SDK_INIT_CPU_NOT_SUPPORT] for " + "weex so size check fail exception :" + e.getMessage(), null);
WXLogUtils.e("weex so size check fail exception :" + e.getMessage());
}
return true;
}
use of dalvik.system.PathClassLoader in project blog_resource by Guolei1130.
the class MainActivity method loadExtApk.
private void loadExtApk() {
String apkPath = new File("/sdcard/plugin_1.apk").getPath();
File dexOptOutDir = new File(getFilesDir(), "dexopt");
if (!dexOptOutDir.exists()) {
boolean result = dexOptOutDir.mkdir();
if (!result) {
Log.e(TAG, "loadExtJar: create out dir error");
}
}
String dexOptOutDr = dexOptOutDir.getPath();
ClassLoader classLoader = null;
if (Constants.isDalvik()) {
classLoader = new DexClassLoader(apkPath, dexOptOutDr, null, ClassLoader.getSystemClassLoader());
} else {
classLoader = new PathClassLoader(apkPath, ClassLoader.getSystemClassLoader());
}
try {
Class userClz = classLoader.loadClass("com.guolei.plugin_1.People");
Object user = userClz.getConstructor(String.class, int.class).newInstance("guolei", 24);
Method method = userClz.getDeclaredMethod("toString");
method.setAccessible(true);
String msg = (String) method.invoke(user);
Log.e(TAG, "loadExtApk: " + msg);
Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations