VirtualApp - 2 -2 Application 的 onCreate中调用了virtualCore的initialize用来处理不同进程的初始化逻辑。
在onCreate中调用了virtualCore的initialize方法注册了一个VirtualInitializer的callback,用来处理不同进程的初始化逻辑。
@Override public void onCreate() { gApp = this; super.onCreate(); VirtualCore virtualCore = VirtualCore.get(); /** * virtualCore的initialize方法注册了一个VirtualInitializer的callback, * 用来处理不同进程的初始化逻辑(进行四种进程) */ virtualCore.initialize(new VirtualCore.VirtualInitializer() { @Override public void onMainProcess() { Once.initialise(VApp.this); //主进程 这是在统计什么??? new FlurryAgent.Builder() .withLogEnabled(true) .withListener(() -> { // nothing }) .build(VApp.this, "48RJJP7ZCZZBB6KMMWW5"); } @Override public void onVirtualProcess() { //客户App进程的回调 //listener components virtualCore.setComponentDelegate(new MyComponentDelegate()); //fake phone imei,macAddress,BluetoothAddress virtualCore.setPhoneInfoDelegate(new MyPhoneInfoDelegate()); //fake task description's icon and title virtualCore.setTaskDescriptionDelegate(new MyTaskDescriptionDelegate()); } @Override public void onServerProcess() { virtualCore.setAppRequestListener(new MyAppRequestListener(VApp.this)); virtualCore.addVisibleOutsidePackage("com.tencent.mobileqq"); virtualCore.addVisibleOutsidePackage("com.tencent.mobileqqi"); virtualCore.addVisibleOutsidePackage("com.tencent.minihd.qq"); virtualCore.addVisibleOutsidePackage("com.tencent.qqlite"); virtualCore.addVisibleOutsidePackage("com.facebook.katana"); virtualCore.addVisibleOutsidePackage("com.whatsapp"); virtualCore.addVisibleOutsidePackage("com.tencent.mm"); virtualCore.addVisibleOutsidePackage("com.immomo.momo"); } }); }