Search in sources :

Example 56 with WifiInfo

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();
}
Also used : WifiManager(android.net.wifi.WifiManager) WifiInfo(android.net.wifi.WifiInfo)

Example 57 with WifiInfo

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;
        }
    });
}
Also used : PhoneInfoDelegate(com.lody.virtual.client.hook.delegate.PhoneInfoDelegate) StaticHook(com.lody.virtual.client.hook.base.StaticHook) Method(java.lang.reflect.Method) WifiInfo(android.net.wifi.WifiInfo)

Example 58 with WifiInfo

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);
}
Also used : Context(android.content.Context) WifiManager(android.net.wifi.WifiManager) Intent(android.content.Intent) TextView(android.widget.TextView) ImageView(android.widget.ImageView) InetAddress(java.net.InetAddress) WifiInfo(android.net.wifi.WifiInfo)

Example 59 with WifiInfo

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;
}
Also used : WifiManager(android.net.wifi.WifiManager) WifiInfo(android.net.wifi.WifiInfo)

Example 60 with WifiInfo

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;
}
Also used : WifiManager(android.net.wifi.WifiManager) WifiInfo(android.net.wifi.WifiInfo)

Aggregations

WifiInfo (android.net.wifi.WifiInfo)99 WifiManager (android.net.wifi.WifiManager)53 WifiConfiguration (android.net.wifi.WifiConfiguration)16 NetworkInfo (android.net.NetworkInfo)13 Intent (android.content.Intent)11 IOException (java.io.IOException)8 Test (org.junit.Test)8 Bundle (android.os.Bundle)7 ScanResult (android.net.wifi.ScanResult)6 WifiAssociationTestRunner (com.android.connectivitymanagertest.WifiAssociationTestRunner)6 PendingIntent (android.app.PendingIntent)5 ConnectivityManager (android.net.ConnectivityManager)5 Network (android.net.Network)5 CellIdentityCdma (android.telephony.CellIdentityCdma)5 CellIdentityGsm (android.telephony.CellIdentityGsm)5 CellIdentityLte (android.telephony.CellIdentityLte)5 CellIdentityWcdma (android.telephony.CellIdentityWcdma)5 CellInfo (android.telephony.CellInfo)5 CellInfoCdma (android.telephony.CellInfoCdma)5 CellInfoGsm (android.telephony.CellInfoGsm)5