public boolean enable() { return setEnabled(getConfiguration(), true); }
public Inet6Address getInet6Address() { if (!isEnabled()) { return null; } return getInetAddress(Inet6Address.class); }
private WifiApControl(Context context) { wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); deviceName = getDeviceName(wm); }
private void updateText() { StringBuilder sb = new StringBuilder(); if (!WifiApControl.isSupported()) { sb.append("Warning: Wifi AP mode not supported!\n"); sb.append("You should get unknown or zero values below.\n"); int state = apControl.getState(); sb.append("State: ").append(stateString(state)).append('\n'); boolean enabled = apControl.isEnabled(); sb.append("Enabled: ").append(enabled ? "YES" : "NO").append('\n'); WifiConfiguration config = apControl.getConfiguration(); sb.append("WifiConfiguration:"); if (config == null) { Inet4Address addr4 = apControl.getInet4Address(); sb.append("Inet4Address: "); sb.append(addr4 == null ? "null" : addr4.toString()).append('\n'); Inet6Address addr6 = apControl.getInet6Address(); sb.append("Inet6Address: "); sb.append(addr6 == null ? "null" : addr6.toString()).append('\n');
public List<Client> getClients() { if (!isEnabled()) { return null;
public static WifiApControl getInstance(Context context) { if (instance == null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.System.canWrite(context)) { Log.e(TAG, "6.0 or later, but haven't been granted WRITE_SETTINGS!"); return null; } instance = new WifiApControl(context); } return instance; }
private void disable() { apControl.disable(); wifiManager.setWifiEnabled(true); refresh(); }
private void enable() { wifiManager.setWifiEnabled(false); apControl.enable(); refresh(); }
public List<Client> getReachableClients(final int timeout, final ReachableClientListener listener) { List<Client> clients = getClients(); if (clients == null) { return null;
public Inet4Address getInet4Address() { if (!isEnabled()) { return null; } return getInetAddress(Inet4Address.class); }