Search in sources :

Example 1 with AppEnterForegroundCallBack

use of com.huami.watch.companion.util.AppEnterForegroundCallBack in project AmazMod by edotassi.

the class CompanionApplication method onCreate.

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
@SuppressLint({ "MissingSuperCall", "ResourceType" })
@DexWrap
public void onCreate() {
    Boolean enableRtl = PreferenceManager.getBoolean(this, Constants.PREFERENCE_ENABLE_RTL, false);
    Configuration configuration = getResources().getConfiguration();
    configuration.setLayoutDirection(new Locale(enableRtl ? "fa" : "en"));
    getResources().updateConfiguration(configuration, getResources().getDisplayMetrics());
    Boolean disableCrashReporting = PreferenceManager.getBoolean(this, Constants.PREFERENCE_DISABLE_CRASH_REPORTING, false);
    CrashlyticsCore crashlyticsCore = new CrashlyticsCore.Builder().disabled(!disableCrashReporting.booleanValue()).build();
    Fabric.with(this, new Crashlytics.Builder().core(crashlyticsCore).build());
    a = this;
    if (!Config.isOversea() && !b()) {
        return;
    }
    Box.initDefault(this);
    a();
    Log.Settings settings = Log.init();
    settings.setLogLevel(Config.isDebug() ? Log.LogLevel.FULL : Log.LogLevel.FILE_ONLY).setLogFile(StorageUtil.getLogFile(this));
    Log.d("CompanionApp", "OnAppCreate : " + AppUtil.getVersionNameAndCode(this), new Object[0]);
    super.onCreate();
    /*
        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
            @Override
            public void uncaughtException(Thread thread, Throwable throwable) {
                Log.e("CompanionApp", "Crash(" + thread + ")", throwable, new Object[0]);
                System.exit(1);
            }
        });
        */
    Analytics.config(true, Config.isDebug(), true, this, AppUtil.getMetaDataChannel(this));
    AccountManager.getDefault(this).setTestMode(Config.isTestHosts());
    // AccountManager.getDefault(this).setGlobalMode(true);
    ActiveAndroid.initialize(this, Config.isDebug());
    NotificationManager.getManager(this).init();
    if (DeviceCompatibility.MIUI.isMIUI(this)) {
        MiuiAPI.getInstance(this).init();
    }
    SyncThrottler.init(this);
    BindUtil.unbindUnfinishedDevice(this);
    j = Transporter.get(this, "com.huami.watch.companion");
    j.addChannelListener(k);
    j.addDataListener(l);
    j.connectTransportService();
    Transporter object = Transporter.get(this, "com.huami.watch.companion.syncdata");
    object.addDataListener(m);
    object.connectTransportService();
    object = Transporter.get(this, "com.huami.action.notification");
    object.addDataListener(n);
    object.connectTransportService();
    o = Transporter.get(this, "com.huami.watch.health");
    o.addDataListener(p);
    o.connectTransportService();
    if (f == null) {
        f = new AskAndAnswer(this);
    }
    if (g == null) {
        g = new CallingWearHelper(this);
    }
    if (h == null) {
        h = new DataCollection(this);
    }
    startService(new Intent(this, BGService_msg.class));
    startService(new Intent(this, OtaService.class));
    startService(new Intent(this, IMEservice.class));
    SyncWatchFaceBgHelper.getHelper().startFileTransporter(this);
    AGpsSyncHelper.getHelper().startFileTransporter(this);
    if (DeviceManager.getManager(this).hasBoundDevice()) {
        AGpsSyncService.scheduleSync(this, "AppOnCreate");
        startService(new Intent(this, WeatherService.class));
    }
    a(this);
    SyncWatchHealthHelper.getHelper().init(this);
    SyncWatchSportHelper.getHelper().init(this);
    WearHttpSupportInterface.doInit(this);
    /* Ok */
    ConnectionReceiver connectionReceiver = new ConnectionReceiver();
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
    intentFilter.addAction("com.huami.watch.WATCH_CONNED_4_COMPANION");
    intentFilter.addAction("com.huami.watch.companion.action.UnbindDeviceStart");
    intentFilter.addAction("com.huami.watch.httpsupport.COLLECT_DATA");
    intentFilter.addAction("com.huami.watch.companion.action.HOST_START_SYNC_DATA");
    registerReceiver(connectionReceiver, intentFilter);
    TimeChangedReceiver timeChangedReceiver = new CompanionApplication.TimeChangedReceiver();
    IntentFilter timeSet = new IntentFilter("android.intent.action.TIME_SET");
    timeSet.addAction("android.intent.action.TIMEZONE_CHANGED");
    registerReceiver(timeChangedReceiver, timeSet);
    IntentFilter wifiStateChangeConnectivityChange = new IntentFilter();
    wifiStateChangeConnectivityChange.addAction("android.net.wifi.STATE_CHANGE");
    wifiStateChangeConnectivityChange.addAction("android.net.conn.CONNECTIVITY_CHANGE");
    registerReceiver(q, wifiStateChangeConnectivityChange);
    new RxConsumerStarter().init(this);
    BindUtil.connectCurrentDevice(this);
    Device device = DeviceManager.getManager(this).getCurrentDevice();
    if (device != null && DeviceUtil.hasEmptyInfo(device)) {
        SyncDeviceInfoHelper.getHelper(this).startAsync();
    }
    PlayFlavor.initApp(this);
    e = new HttpProxyServer(getApplicationContext());
    e.init();
    if (getResources().getBoolean(2131427330)) {
        CommandHandler.getInstance(this);
    }
    WatchWifiFtpUtil.init(getApplicationContext());
    registerActivityLifecycleCallbacks(new AppEnterForegroundCallBack());
    BleLostWarningManager.init(getApplicationContext());
    if (DeviceCompatibility.isHuaWeiPhone() && !DeviceCompatibility.isO()) {
    // DummyJobService.startSchedule(this);
    }
    FileDownloader.init(getApplicationContext(), new DownloadMgrInitialParams.InitCustomMaker().connectionCreator(new FileDownloadUrlConnection.Creator(new FileDownloadUrlConnection.Configuration().connectTimeout(15000).readTimeout(15000).proxy(Proxy.NO_PROXY))));
    Boot.sharedInstance(this).run();
}
Also used : Locale(java.util.Locale) CrashlyticsCore(com.crashlytics.android.core.CrashlyticsCore) Configuration(android.content.res.Configuration) CallingWearHelper(com.huami.watch.companion.wearcalling.CallingWearHelper) IMEservice(com.huami.watch.companion.IME.IMEservice) AskAndAnswer(com.huami.watch.companion.findphone.AskAndAnswer) WeatherService(com.huami.watch.companion.weather.WeatherService) AppEnterForegroundCallBack(com.huami.watch.companion.util.AppEnterForegroundCallBack) IntentFilter(android.content.IntentFilter) HttpProxyServer(com.huami.watch.companion.components.bluetoothproxyserver.HttpProxyServer) OtaService(com.huami.watch.companion.otaphone.service.OtaService) Log(com.huami.watch.util.Log) ConnectionReceiver(com.huami.watch.transport.httpsupport.global.ConnectionReceiver) Device(com.huami.watch.companion.device.Device) Intent(android.content.Intent) Crashlytics(com.crashlytics.android.Crashlytics) DataCollection(com.huami.watch.companion.datacollection.DataCollection) BGService_msg(com.huami.watch.hmwatchmanager.bt_connect.BGService_msg) Transporter(com.huami.watch.transport.Transporter) DexWrap(lanchon.dexpatcher.annotation.DexWrap) RequiresApi(android.support.annotation.RequiresApi) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 Configuration (android.content.res.Configuration)1 RequiresApi (android.support.annotation.RequiresApi)1 Crashlytics (com.crashlytics.android.Crashlytics)1 CrashlyticsCore (com.crashlytics.android.core.CrashlyticsCore)1 IMEservice (com.huami.watch.companion.IME.IMEservice)1 HttpProxyServer (com.huami.watch.companion.components.bluetoothproxyserver.HttpProxyServer)1 DataCollection (com.huami.watch.companion.datacollection.DataCollection)1 Device (com.huami.watch.companion.device.Device)1 AskAndAnswer (com.huami.watch.companion.findphone.AskAndAnswer)1 OtaService (com.huami.watch.companion.otaphone.service.OtaService)1 AppEnterForegroundCallBack (com.huami.watch.companion.util.AppEnterForegroundCallBack)1 CallingWearHelper (com.huami.watch.companion.wearcalling.CallingWearHelper)1 WeatherService (com.huami.watch.companion.weather.WeatherService)1 BGService_msg (com.huami.watch.hmwatchmanager.bt_connect.BGService_msg)1 Transporter (com.huami.watch.transport.Transporter)1 ConnectionReceiver (com.huami.watch.transport.httpsupport.global.ConnectionReceiver)1 Log (com.huami.watch.util.Log)1