Search in sources :

Example 1 with BaseDexClassLoader

use of dalvik.system.BaseDexClassLoader in project android_frameworks_base by ResurrectionRemix.

the class NativeActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    String libname = "main";
    String funcname = "ANativeActivity_onCreate";
    ActivityInfo ai;
    mIMM = getSystemService(InputMethodManager.class);
    getWindow().takeSurface(this);
    getWindow().takeInputQueue(this);
    getWindow().setFormat(PixelFormat.RGB_565);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    mNativeContentView = new NativeContentView(this);
    mNativeContentView.mActivity = this;
    setContentView(mNativeContentView);
    mNativeContentView.requestFocus();
    mNativeContentView.getViewTreeObserver().addOnGlobalLayoutListener(this);
    try {
        ai = getPackageManager().getActivityInfo(getIntent().getComponent(), PackageManager.GET_META_DATA);
        if (ai.metaData != null) {
            String ln = ai.metaData.getString(META_DATA_LIB_NAME);
            if (ln != null)
                libname = ln;
            ln = ai.metaData.getString(META_DATA_FUNC_NAME);
            if (ln != null)
                funcname = ln;
        }
    } catch (PackageManager.NameNotFoundException e) {
        throw new RuntimeException("Error getting activity info", e);
    }
    BaseDexClassLoader classLoader = (BaseDexClassLoader) getClassLoader();
    String path = classLoader.findLibrary(libname);
    if (path == null) {
        throw new IllegalArgumentException("Unable to find native library " + libname + " using classloader: " + classLoader.toString());
    }
    byte[] nativeSavedState = savedInstanceState != null ? savedInstanceState.getByteArray(KEY_NATIVE_SAVED_STATE) : null;
    mNativeHandle = loadNativeCode(path, funcname, Looper.myQueue(), getAbsolutePath(getFilesDir()), getAbsolutePath(getObbDir()), getAbsolutePath(getExternalFilesDir(null)), Build.VERSION.SDK_INT, getAssets(), nativeSavedState, classLoader, classLoader.getLdLibraryPath());
    if (mNativeHandle == 0) {
        throw new UnsatisfiedLinkError("Unable to load native library \"" + path + "\": " + getDlError());
    }
    super.onCreate(savedInstanceState);
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) BaseDexClassLoader(dalvik.system.BaseDexClassLoader) PackageManager(android.content.pm.PackageManager) InputMethodManager(android.view.inputmethod.InputMethodManager)

Example 2 with BaseDexClassLoader

use of dalvik.system.BaseDexClassLoader in project android_frameworks_base by crdroidandroid.

the class NativeActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    String libname = "main";
    String funcname = "ANativeActivity_onCreate";
    ActivityInfo ai;
    mIMM = getSystemService(InputMethodManager.class);
    getWindow().takeSurface(this);
    getWindow().takeInputQueue(this);
    getWindow().setFormat(PixelFormat.RGB_565);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    mNativeContentView = new NativeContentView(this);
    mNativeContentView.mActivity = this;
    setContentView(mNativeContentView);
    mNativeContentView.requestFocus();
    mNativeContentView.getViewTreeObserver().addOnGlobalLayoutListener(this);
    try {
        ai = getPackageManager().getActivityInfo(getIntent().getComponent(), PackageManager.GET_META_DATA);
        if (ai.metaData != null) {
            String ln = ai.metaData.getString(META_DATA_LIB_NAME);
            if (ln != null)
                libname = ln;
            ln = ai.metaData.getString(META_DATA_FUNC_NAME);
            if (ln != null)
                funcname = ln;
        }
    } catch (PackageManager.NameNotFoundException e) {
        throw new RuntimeException("Error getting activity info", e);
    }
    BaseDexClassLoader classLoader = (BaseDexClassLoader) getClassLoader();
    String path = classLoader.findLibrary(libname);
    if (path == null) {
        throw new IllegalArgumentException("Unable to find native library " + libname + " using classloader: " + classLoader.toString());
    }
    byte[] nativeSavedState = savedInstanceState != null ? savedInstanceState.getByteArray(KEY_NATIVE_SAVED_STATE) : null;
    mNativeHandle = loadNativeCode(path, funcname, Looper.myQueue(), getAbsolutePath(getFilesDir()), getAbsolutePath(getObbDir()), getAbsolutePath(getExternalFilesDir(null)), Build.VERSION.SDK_INT, getAssets(), nativeSavedState, classLoader, classLoader.getLdLibraryPath());
    if (mNativeHandle == 0) {
        throw new UnsatisfiedLinkError("Unable to load native library \"" + path + "\": " + getDlError());
    }
    super.onCreate(savedInstanceState);
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) BaseDexClassLoader(dalvik.system.BaseDexClassLoader) PackageManager(android.content.pm.PackageManager) InputMethodManager(android.view.inputmethod.InputMethodManager)

Example 3 with BaseDexClassLoader

use of dalvik.system.BaseDexClassLoader in project android_frameworks_base by DirtyUnicorns.

the class NativeActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    String libname = "main";
    String funcname = "ANativeActivity_onCreate";
    ActivityInfo ai;
    mIMM = getSystemService(InputMethodManager.class);
    getWindow().takeSurface(this);
    getWindow().takeInputQueue(this);
    getWindow().setFormat(PixelFormat.RGB_565);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    mNativeContentView = new NativeContentView(this);
    mNativeContentView.mActivity = this;
    setContentView(mNativeContentView);
    mNativeContentView.requestFocus();
    mNativeContentView.getViewTreeObserver().addOnGlobalLayoutListener(this);
    try {
        ai = getPackageManager().getActivityInfo(getIntent().getComponent(), PackageManager.GET_META_DATA);
        if (ai.metaData != null) {
            String ln = ai.metaData.getString(META_DATA_LIB_NAME);
            if (ln != null)
                libname = ln;
            ln = ai.metaData.getString(META_DATA_FUNC_NAME);
            if (ln != null)
                funcname = ln;
        }
    } catch (PackageManager.NameNotFoundException e) {
        throw new RuntimeException("Error getting activity info", e);
    }
    BaseDexClassLoader classLoader = (BaseDexClassLoader) getClassLoader();
    String path = classLoader.findLibrary(libname);
    if (path == null) {
        throw new IllegalArgumentException("Unable to find native library " + libname + " using classloader: " + classLoader.toString());
    }
    byte[] nativeSavedState = savedInstanceState != null ? savedInstanceState.getByteArray(KEY_NATIVE_SAVED_STATE) : null;
    mNativeHandle = loadNativeCode(path, funcname, Looper.myQueue(), getAbsolutePath(getFilesDir()), getAbsolutePath(getObbDir()), getAbsolutePath(getExternalFilesDir(null)), Build.VERSION.SDK_INT, getAssets(), nativeSavedState, classLoader, classLoader.getLdLibraryPath());
    if (mNativeHandle == 0) {
        throw new UnsatisfiedLinkError("Unable to load native library \"" + path + "\": " + getDlError());
    }
    super.onCreate(savedInstanceState);
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) BaseDexClassLoader(dalvik.system.BaseDexClassLoader) PackageManager(android.content.pm.PackageManager) InputMethodManager(android.view.inputmethod.InputMethodManager)

Example 4 with BaseDexClassLoader

use of dalvik.system.BaseDexClassLoader in project android_frameworks_base by AOSPA.

the class NativeActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    String libname = "main";
    String funcname = "ANativeActivity_onCreate";
    ActivityInfo ai;
    mIMM = getSystemService(InputMethodManager.class);
    getWindow().takeSurface(this);
    getWindow().takeInputQueue(this);
    getWindow().setFormat(PixelFormat.RGB_565);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    mNativeContentView = new NativeContentView(this);
    mNativeContentView.mActivity = this;
    setContentView(mNativeContentView);
    mNativeContentView.requestFocus();
    mNativeContentView.getViewTreeObserver().addOnGlobalLayoutListener(this);
    try {
        ai = getPackageManager().getActivityInfo(getIntent().getComponent(), PackageManager.GET_META_DATA);
        if (ai.metaData != null) {
            String ln = ai.metaData.getString(META_DATA_LIB_NAME);
            if (ln != null)
                libname = ln;
            ln = ai.metaData.getString(META_DATA_FUNC_NAME);
            if (ln != null)
                funcname = ln;
        }
    } catch (PackageManager.NameNotFoundException e) {
        throw new RuntimeException("Error getting activity info", e);
    }
    BaseDexClassLoader classLoader = (BaseDexClassLoader) getClassLoader();
    String path = classLoader.findLibrary(libname);
    if (path == null) {
        throw new IllegalArgumentException("Unable to find native library " + libname + " using classloader: " + classLoader.toString());
    }
    byte[] nativeSavedState = savedInstanceState != null ? savedInstanceState.getByteArray(KEY_NATIVE_SAVED_STATE) : null;
    mNativeHandle = loadNativeCode(path, funcname, Looper.myQueue(), getAbsolutePath(getFilesDir()), getAbsolutePath(getObbDir()), getAbsolutePath(getExternalFilesDir(null)), Build.VERSION.SDK_INT, getAssets(), nativeSavedState, classLoader, classLoader.getLdLibraryPath());
    if (mNativeHandle == 0) {
        throw new UnsatisfiedLinkError("Unable to load native library \"" + path + "\": " + getDlError());
    }
    super.onCreate(savedInstanceState);
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) BaseDexClassLoader(dalvik.system.BaseDexClassLoader) PackageManager(android.content.pm.PackageManager) InputMethodManager(android.view.inputmethod.InputMethodManager)

Example 5 with BaseDexClassLoader

use of dalvik.system.BaseDexClassLoader in project EssayJoke by qiyei2015.

the class FixDexManager method loadDex.

/**
 * 加载dex
 * @param fileDexFiles
 */
private void loadDex(List<File> fileDexFiles) throws Exception {
    // 获取已经运行的dexElement
    ClassLoader applicationClassLoader = mContext.getClassLoader();
    Object oldDexElements = getDexElements(applicationClassLoader);
    // dex解压目录
    File optimizedDir = new File(mDexFile, "opt");
    if (!optimizedDir.exists()) {
        optimizedDir.mkdir();
    }
    // 修复Dex
    for (File dexFile : fileDexFiles) {
        // dexPath  dex路径
        // optimizedDirectory  解压路径
        // libraryPath .so文件位置
        // parent 父ClassLoader
        ClassLoader fixDexClassLoader = new BaseDexClassLoader(dexFile.getAbsolutePath(), optimizedDir, null, applicationClassLoader);
        Object newDexElements = getDexElements(fixDexClassLoader);
        // 3. 把补丁的dexElement 插到 已经运行的 dexElement 的最前面  合并
        // oldDexElements 数组 合并 newDexElements 数组
        // 3.1 合并完成
        oldDexElements = combineArray(newDexElements, oldDexElements);
    }
    // 将合并的数组注入到BaseDexClassLoader的dexElements 中
    injectDexElements(applicationClassLoader, oldDexElements);
}
Also used : BaseDexClassLoader(dalvik.system.BaseDexClassLoader) BaseDexClassLoader(dalvik.system.BaseDexClassLoader) File(java.io.File)

Aggregations

BaseDexClassLoader (dalvik.system.BaseDexClassLoader)6 ActivityInfo (android.content.pm.ActivityInfo)5 PackageManager (android.content.pm.PackageManager)5 InputMethodManager (android.view.inputmethod.InputMethodManager)5 File (java.io.File)1