use of android.taobao.atlas.runtime.FrameworkLifecycleHandler in project atlas by alibaba.
the class Atlas method init.
/**
* Init the framework
*
* @param application
* @return
* @throws Exception
*/
public void init(Application application, boolean reset) throws AssertionArrayException, Exception {
if (application == null) {
throw new RuntimeException("application is null");
}
ApplicationInfo app_info = application.getApplicationInfo();
sAPKSource = app_info.sourceDir;
boolean DEBUG = (app_info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
RuntimeVariables.androidApplication = application;
RuntimeVariables.delegateResources = application.getResources();
Framework.containerVersion = RuntimeVariables.sInstalledVersionName;
ClassLoader cl = Atlas.class.getClassLoader();
Framework.systemClassLoader = cl;
// defineAndVerify
String packageName = application.getPackageName();
//
DelegateClassLoader newClassLoader = new DelegateClassLoader(cl);
// init RuntimeVariables
RuntimeVariables.delegateClassLoader = newClassLoader;
// try{
// RuntimeVariables.delegateResources = getResources(application);
// }catch(Throwable e){
// e.printStackTrace();
// }
// inject DelegateClassLoader & DelegateResources & InstrumentationHook
AndroidHack.injectClassLoader(packageName, newClassLoader);
AndroidHack.injectInstrumentationHook(new InstrumentationHook(AndroidHack.getInstrumentation(), application.getBaseContext()));
// add listeners
bundleLifecycleHandler = new BundleLifecycleHandler();
Framework.syncBundleListeners.add(bundleLifecycleHandler);
frameworkLifecycleHandler = new FrameworkLifecycleHandler();
Framework.frameworkListeners.add(frameworkLifecycleHandler);
/**
* TODO NEED CHECK
* 解决某些自带LBE机制无法hook execstartactivity以及service start service的hook
*/
try {
ActivityManagrHook activityManagerProxy = new ActivityManagrHook();
Object gDefault = AtlasHacks.ActivityManagerNative_gDefault.get(AtlasHacks.ActivityManagerNative.getmClass());
AtlasHacks.Singleton_mInstance.hijack(gDefault, activityManagerProxy);
} catch (Throwable e) {
}
AndroidHack.hackH();
}
Aggregations