public static void postInitApplication() { if (applicationInited) { return; } applicationInited = true; try { LocaleController.getInstance(); } catch (Exception e) { e.printStackTrace(); } try { final IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); final BroadcastReceiver mReceiver = new ScreenReceiver(); applicationContext.registerReceiver(mReceiver, filter); } catch (Exception e) { e.printStackTrace(); } try { PowerManager pm = (PowerManager) ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE); isScreenOn = pm.isScreenOn(); FileLog.e("tmessages", "screen state = " + isScreenOn); } catch (Exception e) { FileLog.e("tmessages", e); } UserConfig.loadConfig(); if (UserConfig.getCurrentUser() != null) { MessagesController.getInstance().putUser(UserConfig.getCurrentUser(), true); ConnectionsManager.getInstance().applyCountryPortNumber(UserConfig.getCurrentUser().phone); ConnectionsManager.getInstance().initPushConnection(); MessagesController.getInstance().getBlockedUsers(true); SendMessagesHelper.getInstance().checkUnsentMessages(); } ApplicationLoader app = (ApplicationLoader) ApplicationLoader.applicationContext; app.initPlayServices(); FileLog.e("tmessages", "app initied"); ContactsController.getInstance().checkAppAccount(); MediaController.getInstance(); }
void beginExport() { TLRPC.TL_auth_exportAuthorization exportAuthorization = new TLRPC.TL_auth_exportAuthorization(); exportAuthorization.dc_id = datacenter.datacenterId; ConnectionsManager.getInstance() .performRpc( exportAuthorization, new RPCRequest.RPCRequestDelegate() { @Override public void run(TLObject response, TLRPC.TL_error error) { if (delegate == null) { return; } if (error == null) { exportedAuthorization = (TLRPC.TL_auth_exportedAuthorization) response; beginImport(); } else { retryCount++; if (retryCount >= 3) { delegate.ActionDidFailExecution(ExportAuthorizationAction.this); } else { Utilities.stageQueue.postRunnable( new Runnable() { @Override public void run() { beginExport(); } }, retryCount * 1500); } } } }); }
void beginImport() { TLRPC.TL_auth_importAuthorization importAuthorization = new TLRPC.TL_auth_importAuthorization(); importAuthorization.bytes = exportedAuthorization.bytes; importAuthorization.id = exportedAuthorization.id; ConnectionsManager.getInstance() .performRpc( importAuthorization, new RPCRequest.RPCRequestDelegate() { @Override public void run(TLObject response, TLRPC.TL_error error) { if (delegate == null) { return; } if (error == null) { delegate.ActionDidFinishExecution(ExportAuthorizationAction.this, null); } else { exportedAuthorization = null; retryCount++; if (retryCount >= 3) { delegate.ActionDidFailExecution(ExportAuthorizationAction.this); } else { Utilities.stageQueue.postRunnable( new Runnable() { @Override public void run() { beginExport(); } }, retryCount * 1500); } } } }, null, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassEnableUnauthorized | RPCRequest.RPCRequestClassWithoutLogin, datacenter.datacenterId); }