public void listDBProxies(View caller) {
    TextView textViewTest = new TextView(this);
    testDBContainer.addView(textViewTest);
    textViewTest.setTextSize(10);

    Map<Long, ProxyEntity> savedProxies = App.getDBManager().getAllProxiesWithTAGs();
    List<ProxyEntity> list = new ArrayList<ProxyEntity>(savedProxies.values());
    for (ProxyEntity p : list) {
      textViewTest.append(p.toString() + "\n");
    }

    Map<Long, PacEntity> savedPac = App.getDBManager().getAllPac();
    List<PacEntity> pacslist = new ArrayList<PacEntity>(savedPac.values());
    for (PacEntity p : pacslist) {
      textViewTest.append(p.toString() + "\n");
    }
  }
 public void listDBTags(View caller) {
   TextView textViewTest = new TextView(this);
   testDBContainer.addView(textViewTest);
   textViewTest.setTextSize(10);
   List<TagEntity> list = App.getDBManager().getAllTags();
   for (TagEntity t : list) {
     textViewTest.append(t.toString() + "\n");
   }
 }
 public void listDBWifiAp(View caller) {
   TextView textViewTest = new TextView(this);
   textViewTest.setTextSize(10);
   testDBContainer.addView(textViewTest);
   Map<Long, WiFiAPEntity> savedAp = App.getDBManager().getAllWifiAp();
   List<WiFiAPEntity> list = new ArrayList<WiFiAPEntity>(savedAp.values());
   for (WiFiAPEntity p : list) {
     textViewTest.append(p.toString() + "\n");
   }
 }
  private void checkValidation() {
    if (validateHost() && validatePort() && validateBypass()) {
      ((ProxyDetailActivity) getActivity()).enableSave();
    } else {
      ((ProxyDetailActivity) getActivity()).disableSave();
    }

    // TODO: Add check for duplicated configuration to Async handler
    proxyDuplicatedBanner.setVisibility(View.GONE);
    String host = selectedProxy.host;
    Integer port = selectedProxy.port;
    if (host != null && port != null) {
      List<Long> duplicatedIDs = App.getDBManager().findDuplicatedProxy(host, port);
      if (selectedProxy.isPersisted) {
        proxyDuplicatedBanner.setVisibility(UIUtils.booleanToVisibility(duplicatedIDs.size() > 1));
      } else {
        proxyDuplicatedBanner.setVisibility(UIUtils.booleanToVisibility(duplicatedIDs.size() > 0));
      }
    }
  }
    @Override
    protected Void doInBackground(Void... params) {
      if (_action == TestAction.CLEAR_ALL) {
        TestUtils.resetPreferences(_developerOptionsActivity);
        App.getDBManager().resetDB();
      } else if (_action == TestAction.ADD_EXAMPLE_PROXIES) {
        TestUtils.addProxyExamples(_developerOptionsActivity);
      } else if (_action == TestAction.ADD_TEST_WIFI_NETWORKS) {
        int numWifis = (Integer) _params[0];

        for (int i = 0; i <= numWifis; i++) {
          String ssid = TestUtils.createFakeWifiNetwork(_developerOptionsActivity);
          Timber.e("----------------------------------------------");
          publishProgress(
              String.format("Created #[%d / %d] TEST Wi-Fi network: %s", i, numWifis, ssid));

          try {
            Thread.sleep(500);
          } catch (InterruptedException e) {
            Timber.e(e, "Exception during sleep");
          }
        }
      } else if (_action == TestAction.REMOVE_TEST_WIFI_NETWORKS) {
        int removedCount = TestUtils.deleteFakeWifiNetworks(_developerOptionsActivity);
        publishProgress(String.format("Removed #[%d] TEST Wi-Fi networks", removedCount));
      } else if (_action == TestAction.RUN_STARTUP_ACTIONS) {
        App.getAppStats().updateInstallationDetails();

        publishProgress(App.getAppStats().toString());

        AsyncStartupActions async = new AsyncStartupActions(_developerOptionsActivity);
        async.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
      } else if (_action == TestAction.TOGGLE_DEMO_MODE) {
        // TODO: improve handling of preference cache
        Utils.checkDemoMode(_developerOptionsActivity);
        Utils.setDemoMode(_developerOptionsActivity, !App.getInstance().demoMode);
        Utils.checkDemoMode(_developerOptionsActivity);

        //                for (WiFiApConfig conf :
        // App.getWifiNetworksManager().getSortedWifiApConfigsList())
        //                {
        //                    if (App.getInstance().demoMode)
        //                        conf.setAPDescription(UIUtils.getRandomCodeName().toString());
        //                    else
        //                        conf.setAPDescription(null);
        //                }
      } else if (_action == TestAction.SET_ALL_PROXIES) {
        TestUtils.setProxyForAllAP(_developerOptionsActivity);
      } else if (_action == TestAction.CLEAR_ALL_PROXIES) {
        TestUtils.clearProxyForAllAP(_developerOptionsActivity);
      } else if (_action == TestAction.TEST_VALIDATION) {
        TestUtils.testValidation();
      } else {
        for (int i = 0; i < 10; i++) {
          switch (_action) {
            case ADD_PROXY:
              TestUtils.addRandomProxy();
              break;
            case TEST_SERIALIZATION:
              TestUtils.testSerialization();
              break;
            case ADD_TAGS:
              TestUtils.addTags();
              break;
            case UPDATE_TAGS:
              //                            TestUtils.addRandomProxy();
              break;
          }

          publishProgress(String.valueOf(i));
        }
      }

      return null;
    }