use of android.net.wifi.WifiManager in project weiui by kuaifan.
the class DeviceUtils method getMacAddressByWifiInfo.
@SuppressLint({ "HardwareIds", "MissingPermission" })
private static String getMacAddressByWifiInfo() {
try {
Context context = Utils.getApp().getApplicationContext();
WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
if (wifi != null) {
WifiInfo info = wifi.getConnectionInfo();
if (info != null)
return info.getMacAddress();
}
} catch (Exception e) {
e.printStackTrace();
}
return "02:00:00:00:00:00";
}
use of android.net.wifi.WifiManager in project fdroidclient by f-droid.
the class ManageReposActivity method checkIfNewRepoOnSameWifi.
private void checkIfNewRepoOnSameWifi(NewRepoConfig newRepo) {
// if this is a local repo, check we're on the same wifi
if (!TextUtils.isEmpty(newRepo.getBssid())) {
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
String bssid = wifiInfo.getBSSID();
if (TextUtils.isEmpty(bssid)) {
/* not all devices have wifi */
return;
}
bssid = bssid.toLowerCase(Locale.ENGLISH);
String newRepoBssid = Uri.decode(newRepo.getBssid()).toLowerCase(Locale.ENGLISH);
if (!bssid.equals(newRepoBssid)) {
String msg = String.format(getString(R.string.not_on_same_wifi), newRepo.getSsid());
Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
}
// TODO we should help the user to the right thing here,
// instead of just showing a message!
}
}
use of android.net.wifi.WifiManager in project fdroidclient by f-droid.
the class SwapWorkflowActivity method promptToSetupWifiAP.
private void promptToSetupWifiAP() {
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
WifiApControl ap = WifiApControl.getInstance(this);
wifiManager.setWifiEnabled(false);
if (!ap.enable()) {
Log.e(TAG, "Could not enable WiFi AP.");
// TODO: Feedback to user?
} else {
Utils.debugLog(TAG, "WiFi AP enabled.");
// TODO: Seems to be broken some times...
}
}
use of android.net.wifi.WifiManager in project mapbox-plugins-android by mapbox.
the class PlaceAutocompleteFragmentTest method offline_doesShowCorrectViewWhenDeviceOffline.
//
// Offline state test
//
// Note, device should also not have data enabled for test to pass. Cannot currently find a way to
// disable this however.
@Test
public void offline_doesShowCorrectViewWhenDeviceOffline() throws Exception {
WifiManager wifi = (WifiManager) activityRule.getActivity().getSystemService(Context.WIFI_SERVICE);
wifi.setWifiEnabled(false);
onView(withId(R.id.edittext_search)).perform(typeText("W"));
onView(withId(R.id.offlineResultView)).check(matches(isDisplayed()));
}
use of android.net.wifi.WifiManager in project mapbox-plugins-android by mapbox.
the class PlaceAutocompleteFragmentTest method offline_doesShowCorrectViewWhenDeviceGoesBackOnline.
@Test
public void offline_doesShowCorrectViewWhenDeviceGoesBackOnline() throws Exception {
WifiManager wifi = (WifiManager) activityRule.getActivity().getSystemService(Context.WIFI_SERVICE);
wifi.setWifiEnabled(true);
onView(withId(R.id.edittext_search)).perform(typeText("W"));
onView(withId(R.id.offlineResultView)).check(matches(not((isDisplayed()))));
}
Aggregations