正在查看: imToken v3.28.8 应用的 MainApplication.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: imToken v3.28.8 应用的 MainApplication.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package org.consenlabs.imtoken;
import android.app.Application;
import android.content.Context;
import android.database.CursorWindow;
import android.os.Build;
import android.webkit.WebView;
import androidx.multidex.MultiDex;
import cl.json.ShareApplication;
import cn.jiguang.plugins.push.JPushModule;
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.facebook.soloader.SoLoader;
import com.google.protobuf.Any;
import com.microsoft.codepush.react.CodePush;
import com.sensorsdata.analytics.android.sdk.SAConfigOptions;
import com.sensorsdata.analytics.android.sdk.SensorsDataAPI;
import io.sentry.Sentry;
import io.sentry.SentryOptions;
import io.sentry.android.core.SentryAndroid;
import io.sentry.android.core.SentryAndroidOptions;
import java.io.File;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import org.consenlabs.imtoken.dappbrowser.DAppBrowserPackage;
import org.consenlabs.imtoken.httpcache.HttpCachePackage;
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.imtoken.walletapi.Util;
import org.consenlabs.tokencore.foundation.utils.NumericUtil;
import org.consenlabs.tokencore.wallet.KeystoreStorage;
import org.consenlabs.tokencore.wallet.WalletManager;
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 final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
protected String getJSMainModuleName() {
return "index";
}
public boolean getUseDeveloperSupport() {
return false;
}
public String getJSBundleFile() {
return CodePush.getJSBundleFile();
}
protected List<ReactPackage> getPackages() {
ArrayList packages = new PackageList(this).getPackages();
packages.add(new TokenPackage());
packages.add(new DAppBrowserPackage());
packages.add(new HttpCachePackage());
return packages;
}
};
private static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
}
public String getFileProviderAuthority() {
return "im.token.app.provider";
}
static {
System.loadLibrary("connector");
}
public static MainApplication getsInstance() {
return sInstance;
}
public ReactNativeHost getReactNativeHost() {
return this.mReactNativeHost;
}
static File getDefaultKeyDirectory() {
File file = new File(getsInstance().getKeystoreDir(), "wallets");
if (!file.exists()) {
file.mkdirs();
}
return file;
}
@Override
public void onCreate() {
super.onCreate();
sInstance = this;
SentryAndroid.init(getApplicationContext(), new Sentry.OptionsConfiguration() {
@Override
public final void configure(SentryOptions sentryOptions) {
((SentryAndroidOptions) sentryOptions).setDsn("https://[email protected]/621773");
}
});
initSensorsDataSDK();
HDMnemonicKeystore.XPubCommonKey128 = "4A2B655485ABBAB54BD30298BB0A5B55";
HDMnemonicKeystore.XPubCommonIv = "73518399CB98DCD114D873E06EBF4BCC";
Util.XPubCommonKey128 = "4A2B655485ABBAB54BD30298BB0A5B55";
Util.XPubCommonIv = "73518399CB98DCD114D873E06EBF4BCC";
WalletManager.storage = this;
WalletManager.scanWallets();
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()));
SoLoader.init(this, false);
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
setCursorWindowSize();
JPushModule.registerActivityLifecycle(this);
if (Build.VERSION.SDK_INT < 19 || (getApplicationInfo().flags & 2) == 0) {
return;
}
WebView.setWebContentsDebuggingEnabled(true);
}
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
protected void attachBaseContext(Context context) {
super.attachBaseContext(context);
if (Build.VERSION.SDK_INT < 21) {
MultiDex.install(this);
}
}
public File getKeystoreDir() {
return getFilesDir();
}
@Override
public void onTerminate() {
HardWalletAPI.getInstance().disconnectAllDevices();
super.onTerminate();
}
private void initSensorsDataSDK() {
try {
SAConfigOptions sAConfigOptions = new SAConfigOptions(SA_SERVER_URL_RELEASE);
sAConfigOptions.enableLog(isDebugMode(this)).setAutoTrackEventType(3).enableTrackAppCrash();
SensorsDataAPI.startWithConfigOptions(this, sAConfigOptions);
} catch (Exception e) {
e.printStackTrace();
}
}
public static boolean isDebugMode(Context context) {
try {
return (context.getApplicationInfo().flags & 2) != 0;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
}