imToken v20.9.11.17版本的 MD5 值为:f7135d2ec367bd3b61d8914bc13d03cb
以下内容为反编译后的 MainApplication.java 源代码,内容仅作参考
package org.consenlabs.imtoken;
import android.app.Application;
import android.content.Context;
import android.database.CursorWindow;
import cl.json.ShareApplication;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.modules.storage.ReactDatabaseSupplier;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.protobuf.Any;
import com.microsoft.codepush.react.CodePush;
import com.nmtoken.token.NativeUtil;
import java.io.File;
import java.lang.reflect.Field;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import org.consenlabs.imtoken.dappbrowser.DAppBrowserPackage;
import org.consenlabs.imtoken.gateway.GatewayPackage;
import org.consenlabs.imtoken.httpcache.HttpCachePackage;
import org.consenlabs.imtoken.urlhook.CustomURLStreamHandlerFactory;
import org.consenlabs.imtoken.walletapi.HardWalletAPI;
import org.consenlabs.imtoken.walletapi.ImkeyApi;
import org.consenlabs.imtoken.walletapi.ImkeyCoreXJna;
import org.consenlabs.imtoken.walletapi.TcxApiStruct;
import org.consenlabs.imtoken.walletapi.TokenCoreXJna;
import org.consenlabs.tokencore.foundation.utils.NumericUtil;
import org.consenlabs.tokencore.wallet.KeystoreStorage;
import org.consenlabs.tokencore.wallet.keystore.HDMnemonicKeystore;
public class MainApplication extends Application implements ReactApplication, ShareApplication, KeystoreStorage {
static final String SA_SERVER_URL_DEBUG = "https://imtoken.datasink.sensorsdata.cn/sa?project=default&token=27d69b3e7fd25949";
static final String SA_SERVER_URL_RELEASE = "https://imtoken.datasink.sensorsdata.cn/sa?project=production&token=27d69b3e7fd25949";
private static MainApplication sInstance;
private ReactNativeHost mReactNativeHost = null;
static native File getDefaultKeyDirectory();
public static native MainApplication getsInstance();
private native void initSensorsDataSDK();
private static native void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager);
@Override
protected native void attachBaseContext(Context context);
@Override
public String getFileProviderAuthority() {
return "im.token.app.provider";
}
@Override
public native File getKeystoreDir();
@Override
public native ReactNativeHost getReactNativeHost();
@Override
public native void onCreate();
static {
NativeUtil.classes4Init0(0);
System.loadLibrary("connector");
URL.setURLStreamHandlerFactory(new CustomURLStreamHandlerFactory());
}
class AnonymousClass1 extends ReactNativeHost {
@Override
protected String getJSMainModuleName() {
return FirebaseAnalytics.Param.INDEX;
}
@Override
public boolean getUseDeveloperSupport() {
return false;
}
AnonymousClass1(Application application) {
super(application);
}
@Override
public String getJSBundleFile() {
return CodePush.getJSBundleFile();
}
@Override
protected List<ReactPackage> getPackages() {
ArrayList<ReactPackage> packages = new PackageList(this).getPackages();
packages.add(new TokenPackage());
packages.add(new DAppBrowserPackage());
packages.add(new GatewayPackage());
packages.add(new HttpCachePackage());
return packages;
}
}
private void initJNA() {
TokenCoreXJna.INSTANCE.call_tcx_api(NumericUtil.bytesToHex(TcxApiStruct.TcxAction.newBuilder().setMethod("init_token_core_x").setParam(Any.newBuilder().setTypeUrl("imtoken.init_token_core_x").setValue(TcxApiStruct.InitTokenCoreXParam.newBuilder().setFileDir(getDefaultKeyDirectory().getAbsolutePath()).setXpubCommonKey(HDMnemonicKeystore.XPubCommonKey128).setXpubCommonIv(HDMnemonicKeystore.XPubCommonIv).setIsDebug(false).build().toByteString()).build()).build().toByteArray()));
ImkeyCoreXJna.INSTANCE.call_imkey_api(NumericUtil.bytesToHex(ImkeyApi.ImkeyAction.newBuilder().setMethod("init_imkey_core_x").setParam(Any.newBuilder().setTypeUrl("imtoken.init_imkey_core_x").setValue(ImkeyApi.InitImKeyCoreXParam.newBuilder().setFileDir(getFilesDir().getAbsolutePath()).setXpubCommonKey(HDMnemonicKeystore.XPubCommonKey128).setXpubCommonIv(HDMnemonicKeystore.XPubCommonIv).setIsDebug(false).setSystem("Android").build().toByteString()).build()).build().toByteArray()));
}
private void setCursorWindowSize() {
try {
Field declaredField = CursorWindow.class.getDeclaredField("sCursorWindowSize");
declaredField.setAccessible(true);
declaredField.set(null, 10485760);
} catch (Exception unused) {
}
try {
ReactDatabaseSupplier.getInstance(getApplicationContext()).setMaximumSize(20971520L);
} catch (Exception unused2) {
}
}
@Override
public void onTerminate() {
HardWalletAPI.getInstance().disconnectAllDevices();
super.onTerminate();
}
public static boolean isDebugMode(Context context) {
try {
return (context.getApplicationInfo().flags & 2) != 0;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
}