@Override protected void onResume() { super.onResume(); if (isLaunched) { checkAll(); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); PreferenceManager.setDefaultValues(this, R.xml.preferences, true); setTitle("fqrouter " + LaunchService.getMyVersion(this)); setupUI(); LaunchedIntent.register(this); UpdateFoundIntent.register(this); ExitedIntent.register(this); WifiRepeaterChangedIntent.register(this); PickAndPlayChangedIntent.register(this); FreeInternetChangedIntent.register(this); DownloadingIntent.register(this); DownloadedIntent.register(this); DownloadFailedIntent.register(this); HandleFatalErrorIntent.register(this); DnsPollutedIntent.register(this); HandleAlertIntent.register(this); ExitingIntent.register(this); blinkStatus(0); String apnName = getApnName(); LogUtils.i("apn name: " + apnName); final File ignoredFile = new File("/data/data/fq.router2/etc/apn-alert-ignored"); if (apnName != null && WAP_APN_LIST.contains(apnName.trim().toLowerCase()) && !ignoredFile.exists()) { new AlertDialog.Builder(MainActivity.this) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle(R.string.wap_apn_alert_title) .setMessage(String.format(_(R.string.wap_apn_alert_message), apnName)) .setPositiveButton(R.string.wap_apn_alert_change_now, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { Intent intent = new Intent(Settings.ACTION_APN_SETTINGS); startActivity(intent); clearNotification(); MainActivity.this.finish(); } }) .setNegativeButton(R.string.wap_apn_alert_ignore, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { IOUtils.writeToFile(ignoredFile, "OK"); launch(); } }) .show(); } else { launch(); } }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { try { if (ASK_VPN_PERMISSION == requestCode) { if (resultCode == RESULT_OK) { if (LaunchService.SOCKS_VPN_SERVICE_CLASS == null) { onHandleFatalError("vpn class not loaded"); } else { updateStatus(_(R.string.status_launch_vpn)); stopService(new Intent(this, LaunchService.SOCKS_VPN_SERVICE_CLASS)); startService(new Intent(this, LaunchService.SOCKS_VPN_SERVICE_CLASS)); uninstallOldVersion(); } } else { onHandleFatalError(_(R.string.status_vpn_rejected)); LogUtils.e("failed to start vpn service: " + resultCode); } } else { super.onActivityResult(requestCode, resultCode, data); } } catch (Exception e) { LogUtils.e("failed to handle onActivityResult", e); } }
@Override public void onStop() { super.onStop(); EasyTracker.getInstance().activityStop(this); }