@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_master); mNavigationDrawerFragment = (NavDrawFragment) getSupportFragmentManager().findFragmentById(R.id.navigation_drawer); mTitle = getTitle(); // Set up the drawer. mNavigationDrawerFragment.setUp( R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); asyncStartupActionsTask = new AsyncStartupActions(this); asyncStartupActionsTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
@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; }