use of android.net.wifi.IWifiManager in project android_frameworks_base by AOSPA.
the class WifiCommand method run.
public void run(String[] args) {
boolean validCommand = false;
if (args.length >= 2) {
boolean flag = false;
if ("enable".equals(args[1])) {
flag = true;
validCommand = true;
} else if ("disable".equals(args[1])) {
flag = false;
validCommand = true;
}
if (validCommand) {
IWifiManager wifiMgr = IWifiManager.Stub.asInterface(ServiceManager.getService(Context.WIFI_SERVICE));
try {
wifiMgr.setWifiEnabled("com.android.shell", flag);
} catch (RemoteException e) {
System.err.println("Wi-Fi operation failed: " + e);
}
return;
}
}
System.err.println(longHelp());
}
use of android.net.wifi.IWifiManager in project android_frameworks_base by DirtyUnicorns.
the class AccessPoint method getSummary.
public static String getSummary(Context context, String ssid, DetailedState state, boolean isEphemeral, String passpointProvider) {
if (state == DetailedState.CONNECTED && ssid == null) {
if (TextUtils.isEmpty(passpointProvider) == false) {
// Special case for connected + passpoint networks.
String format = context.getString(R.string.connected_via_passpoint);
return String.format(format, passpointProvider);
} else if (isEphemeral) {
// Special case for connected + ephemeral networks.
return context.getString(R.string.connected_via_wfa);
}
}
// Case when there is wifi connected without internet connectivity.
final ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (state == DetailedState.CONNECTED) {
IWifiManager wifiManager = IWifiManager.Stub.asInterface(ServiceManager.getService(Context.WIFI_SERVICE));
NetworkCapabilities nc = null;
try {
nc = cm.getNetworkCapabilities(wifiManager.getCurrentNetwork());
} catch (RemoteException e) {
}
if (nc != null) {
if (nc.hasCapability(nc.NET_CAPABILITY_CAPTIVE_PORTAL)) {
return context.getString(com.android.internal.R.string.network_available_sign_in);
} else if (!nc.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)) {
return context.getString(R.string.wifi_connected_no_internet);
}
}
}
if (state == null) {
Log.w(TAG, "state is null, returning empty summary");
return "";
}
String[] formats = context.getResources().getStringArray((ssid == null) ? R.array.wifi_status : R.array.wifi_status_with_ssid);
int index = state.ordinal();
if (index >= formats.length || formats[index].length() == 0) {
return "";
}
return String.format(formats[index], ssid);
}
use of android.net.wifi.IWifiManager in project android_frameworks_base by ResurrectionRemix.
the class AccessPoint method getSummary.
public static String getSummary(Context context, String ssid, DetailedState state, boolean isEphemeral, String passpointProvider) {
if (state == DetailedState.CONNECTED && ssid == null) {
if (TextUtils.isEmpty(passpointProvider) == false) {
// Special case for connected + passpoint networks.
String format = context.getString(R.string.connected_via_passpoint);
return String.format(format, passpointProvider);
} else if (isEphemeral) {
// Special case for connected + ephemeral networks.
return context.getString(R.string.connected_via_wfa);
}
}
// Case when there is wifi connected without internet connectivity.
final ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (state == DetailedState.CONNECTED) {
IWifiManager wifiManager = IWifiManager.Stub.asInterface(ServiceManager.getService(Context.WIFI_SERVICE));
NetworkCapabilities nc = null;
try {
nc = cm.getNetworkCapabilities(wifiManager.getCurrentNetwork());
} catch (RemoteException e) {
}
if (nc != null) {
if (nc.hasCapability(nc.NET_CAPABILITY_CAPTIVE_PORTAL)) {
return context.getString(com.android.internal.R.string.network_available_sign_in);
} else if (!nc.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)) {
return context.getString(R.string.wifi_connected_no_internet);
}
}
}
if (state == null) {
Log.w(TAG, "state is null, returning empty summary");
return "";
}
String[] formats = context.getResources().getStringArray((ssid == null) ? R.array.wifi_status : R.array.wifi_status_with_ssid);
int index = state.ordinal();
if (index >= formats.length || formats[index].length() == 0) {
return "";
}
return String.format(formats[index], ssid);
}
use of android.net.wifi.IWifiManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DevelopmentSettings method updateAdbOverNetwork.
private void updateAdbOverNetwork() {
int port = CMSettings.Secure.getInt(getActivity().getContentResolver(), CMSettings.Secure.ADB_PORT, 0);
boolean enabled = port > 0;
updateSwitchPreference(mAdbOverNetwork, enabled);
WifiInfo wifiInfo = null;
if (enabled) {
IWifiManager wifiManager = IWifiManager.Stub.asInterface(ServiceManager.getService(Context.WIFI_SERVICE));
try {
wifiInfo = wifiManager.getConnectionInfo();
} catch (RemoteException e) {
Log.e(TAG, "wifiManager, getConnectionInfo()", e);
}
}
if (wifiInfo != null) {
String hostAddress = NetworkUtils.intToInetAddress(wifiInfo.getIpAddress()).getHostAddress();
mAdbOverNetwork.setSummary(hostAddress + ":" + String.valueOf(port));
} else {
mAdbOverNetwork.setSummary(R.string.adb_over_network_summary);
}
}
use of android.net.wifi.IWifiManager in project android_frameworks_base by ResurrectionRemix.
the class WifiCommand method run.
public void run(String[] args) {
boolean validCommand = false;
if (args.length >= 2) {
boolean flag = false;
if ("enable".equals(args[1])) {
flag = true;
validCommand = true;
} else if ("disable".equals(args[1])) {
flag = false;
validCommand = true;
}
if (validCommand) {
IWifiManager wifiMgr = IWifiManager.Stub.asInterface(ServiceManager.getService(Context.WIFI_SERVICE));
try {
wifiMgr.setWifiEnabled("com.android.shell", flag);
} catch (RemoteException e) {
System.err.println("Wi-Fi operation failed: " + e);
}
return;
}
}
System.err.println(longHelp());
}
Aggregations