Example #1
0
    @Override
    public void onLaunched(boolean isVpnMode) {
        isLaunched = true;
        ActivityCompat.invalidateOptionsMenu(this);

        ImageView star = (ImageView) findViewById(R.id.star);
        stopBlinkingImage(star);
        enableImage(star);
        stopBlinkingStatus();

        startBlinkingImage((ImageView) findViewById(R.id.freeInternetArrow));
        startBlinkingStatus(_(R.string.status_free_internet_connecting));
        if (isVpnMode) {
            clearNotification();
            if (LaunchService.isVpnRunning()) {
                onFreeInternetChanged(true);
            } else {
                startVpn();
            }
        } else {
            if (ApkUtils.isInstalled(this, "fq.router")) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        ApkUtils.uninstall(MainActivity.this, "fq.router");
                    }
                }).start();
            }
            checkWifiRepeater();
            checkPickAndPlay();
            ConnectFreeInternetService.execute(this);
        }
    }
Example #2
0
 public Intent prepare() {
   Intent i = new Intent(Intent.ACTION_SEND_MULTIPLE);
   i.setType("text/plain");
   i.putExtra(Intent.EXTRA_EMAIL, new String[] {"*****@*****.**"});
   i.putExtra(
       Intent.EXTRA_SUBJECT,
       "android fqrouter error report for version " + LaunchService.getMyVersion(context));
   String error = createLogFiles();
   i.putExtra(Intent.EXTRA_TEXT, getErrorMailBody() + error);
   attachLogFiles(
       i,
       "manager.log",
       "fqsocks.log",
       "fqsocks.log.1",
       "logcat.log",
       "getprop.log",
       "iptables.log",
       "wifi.log",
       "wifi.log.1",
       "fqdns.log",
       "fqting.log",
       "fqlan.log",
       "scan.log",
       "current-java.log",
       "current-python.log");
   return i;
 }
Example #3
0
 private String getErrorMailBody() {
   StringBuilder body = new StringBuilder();
   body.append("phone model: " + Build.MODEL + "\n");
   body.append("android version: " + Build.VERSION.RELEASE + "\n");
   body.append("kernel version: " + System.getProperty("os.version") + "\n");
   body.append("fqrouter version: " + LaunchService.getMyVersion(context) + "\n");
   return body.toString();
 }
Example #4
0
 public void exit() {
     if (LaunchService.isVpnRunning()) {
         Toast.makeText(this, R.string.vpn_exit_hint, 5000).show();
         return;
     }
     ExitService.execute(this);
     showNotification(_(R.string.status_exiting));
     sendBroadcast(new ExitingIntent());
 }
Example #5
0
 private void checkFreeInternet() {
     if (ShellUtils.isRooted()) {
         CheckFreeInternetService.execute(this);
     } else {
         if (LaunchService.isVpnRunning()) {
             onFreeInternetChanged(true);
         }
     }
 }
Example #6
0
 private void showNotification(String text) {
     if (!PreferenceManager.getDefaultSharedPreferences(this).getBoolean("NotificationEnabled", true)) {
         clearNotification();
         return;
     }
     if (LaunchService.isVpnRunning()) {
         clearNotification();
         return;
     }
     displayNotification(this, text);
 }
Example #7
0
 private void startVpn() {
     if (LaunchService.isVpnRunning()) {
         LogUtils.e("vpn is already running, do not start it again");
         return;
     }
     Intent intent = VpnService.prepare(MainActivity.this);
     if (intent == null) {
         onActivityResult(ASK_VPN_PERMISSION, RESULT_OK, null);
     } else {
         startActivityForResult(intent, ASK_VPN_PERMISSION);
     }
 }
Example #8
0
 public void updateStatus(String status) {
     LogUtils.i(status);
     TextView textView = (TextView) findViewById(R.id.statusTextView);
     if (!textView.getText().toString().startsWith("Error:")) {
         textView.setText(status);
         if (LaunchService.isVpnRunning()) {
             clearNotification();
         } else {
             showNotification(status);
         }
     }
 }
Example #9
0
 @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
 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
     if (key.contains("Shortcut") || key.contains("Scrambler") || key.contains("DirectAccess")) {
         if (!sharedPreferences.getBoolean(key, true)) {
             new AlertDialog.Builder(this)
                     .setIcon(android.R.drawable.ic_dialog_alert)
                     .setTitle(R.string.internet_speed_alert_title)
                     .setMessage(R.string.internet_speed_alert_message)
                     .setPositiveButton(R.string.internet_speed_alert_ok, null)
                     .show();
         }
     }
     showToast(_(R.string.pref_restart_app));
     LaunchService.updateConfigFile(this);
 }
Example #11
0
 @Override
 public void onFreeInternetChanged(boolean isConnected) {
     ImageView freeInternetArrow = (ImageView) findViewById(R.id.freeInternetArrow);
     stopBlinkingImage(freeInternetArrow);
     stopBlinkingStatus();
     if (isConnected) {
         updateStatus(_(R.string.status_free_internet_connected));
         enableImage(freeInternetArrow);
         checkUpdate();
     } else {
         clearStatus();
         disableImage(freeInternetArrow);
     }
     if (LaunchService.isVpnRunning()) {
         ToggleButton button = (ToggleButton) findViewById(R.id.freeInternetButton);
         button.setChecked(isConnected);
     } else {
         enableFreeInternetButton(isConnected);
     }
 }
Example #12
0
 private void launch() {
     disableAll();
     startBlinkingImage((ImageView) findViewById(R.id.star));
     startBlinkingStatus(_(R.string.status_launching));
     LaunchService.execute(this);
 }