use of android.net.wifi.WifiInfo in project SmartAndroidSource by jaychou2012.
the class SystemInfo method getWifiLinkSpeed.
/**
* getWifiLinkSpeed
*
* @return the wifi's LinkSpeed
*/
public int getWifiLinkSpeed() {
WifiManager wifi_service = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifi_service.getConnectionInfo();
return wifiInfo.getLinkSpeed();
}
use of android.net.wifi.WifiInfo in project VirtualApp by asLody.
the class WifiManagerPatch method onBindHooks.
@Override
protected void onBindHooks() {
super.onBindHooks();
addHook(new StaticHook("getConnectionInfo") {
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
WifiInfo info = (WifiInfo) method.invoke(who, args);
PhoneInfoDelegate delegate = VirtualCore.get().getPhoneInfoDelegate();
if (info != null && delegate != null) {
String oldMac = info.getMacAddress();
if (oldMac != null) {
String newMac = delegate.getMacAddress(oldMac, getAppUserId());
if (!TextUtils.equals(oldMac, newMac)) {
mirror.android.net.wifi.WifiInfo.mMacAddress.set(info, newMac);
}
}
}
return info;
}
});
}
use of android.net.wifi.WifiInfo in project FileExplorer by MiCode.
the class ServerControlActivity method updateUi.
/**
* This will be called by the static UiUpdater whenever the service has
* changed state in a way that requires us to update our UI. We can't use
* any myLog.l() calls in this function, because that will trigger an
* endless loop of UI updates.
*/
public void updateUi() {
myLog.l(Log.DEBUG, "Updating UI", true);
WifiManager wifiMgr = (WifiManager) mActivity.getSystemService(Context.WIFI_SERVICE);
int wifiState = wifiMgr.getWifiState();
WifiInfo info = wifiMgr.getConnectionInfo();
String wifiId = info != null ? info.getSSID() : null;
boolean isWifiReady = FTPServerService.isWifiEnabled();
setText(R.id.wifi_state, isWifiReady ? wifiId : getString(R.string.no_wifi_hint));
ImageView wifiImg = (ImageView) mRootView.findViewById(R.id.wifi_state_image);
wifiImg.setImageResource(isWifiReady ? R.drawable.wifi_state4 : R.drawable.wifi_state0);
boolean running = FTPServerService.isRunning();
if (running) {
myLog.l(Log.DEBUG, "updateUi: server is running", true);
// Put correct text in start/stop button
// Fill in wifi status and address
InetAddress address = FTPServerService.getWifiIp();
if (address != null) {
String port = ":" + FTPServerService.getPort();
ipText.setText("ftp://" + address.getHostAddress() + (FTPServerService.getPort() == 21 ? "" : port));
} else {
// could not get IP address, stop the service
Context context = mActivity.getApplicationContext();
Intent intent = new Intent(context, FTPServerService.class);
context.stopService(intent);
ipText.setText("");
}
}
startStopButton.setEnabled(isWifiReady);
TextView startStopButtonText = (TextView) mRootView.findViewById(R.id.start_stop_button_text);
if (isWifiReady) {
startStopButtonText.setText(running ? R.string.stop_server : R.string.start_server);
startStopButtonText.setCompoundDrawablesWithIntrinsicBounds(running ? R.drawable.disconnect : R.drawable.connect, 0, 0, 0);
startStopButtonText.setTextColor(running ? getResources().getColor(R.color.remote_disconnect_text) : getResources().getColor(R.color.remote_connect_text));
} else {
if (FTPServerService.isRunning()) {
Context context = mActivity.getApplicationContext();
Intent intent = new Intent(context, FTPServerService.class);
context.stopService(intent);
}
startStopButtonText.setText(R.string.no_wifi);
startStopButtonText.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
startStopButtonText.setTextColor(Color.GRAY);
}
ipText.setVisibility(running ? View.VISIBLE : View.INVISIBLE);
instructionText.setVisibility(running ? View.VISIBLE : View.GONE);
instructionTextPre.setVisibility(running ? View.GONE : View.VISIBLE);
}
use of android.net.wifi.WifiInfo in project carat by amplab.
the class SamplingLibrary method getWifiInfo.
public static WifiInfo getWifiInfo(Context context) {
WifiManager myWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
WifiInfo connectionInfo = myWifiManager.getConnectionInfo();
// Log.v("WifiInfo", "Wifi information:" + connectionInfo);
return connectionInfo;
}
use of android.net.wifi.WifiInfo in project carat by amplab.
the class SamplingLibrary method getWifiLinkSpeed.
/* Get current WiFi link speed */
public static int getWifiLinkSpeed(Context context) {
WifiManager myWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
WifiInfo myWifiInfo = myWifiManager.getConnectionInfo();
int linkSpeed = myWifiInfo.getLinkSpeed();
// Log.v("linkSpeed", "Link speed:" + linkSpeed);
return linkSpeed;
}
Aggregations