當前位置: 首頁>>代碼示例>>Java>>正文


Java SupplicantState類代碼示例

本文整理匯總了Java中android.net.wifi.SupplicantState的典型用法代碼示例。如果您正苦於以下問題:Java SupplicantState類的具體用法?Java SupplicantState怎麽用?Java SupplicantState使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SupplicantState類屬於android.net.wifi包,在下文中一共展示了SupplicantState類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onReceive

import android.net.wifi.SupplicantState; //導入依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
    _logger.Debug("_wifiStateReceiver onReceive");

    String action = intent.getAction();
    if (WifiManager.SUPPLICANT_STATE_CHANGED_ACTION.equals(action)) {
        SupplicantState state = intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE);
        if ((SupplicantState.isValidState(state) && state == SupplicantState.COMPLETED)) {
            _logger.Debug("Successfully connected WIFI completed!");

            if (_sendDataController.GetSelectedServerIp() == null) {
                SearchForServer();
            }
        }
    } else {
        _logger.Warn(String.format("Action is %s", action));
    }
}
 
開發者ID:GuepardoApps,項目名稱:PasswordSafe-AndroidClient,代碼行數:19,代碼來源:AccountListViewController.java

示例2: createWifiInfo

import android.net.wifi.SupplicantState; //導入依賴的package包/類
private static WifiInfo createWifiInfo() throws Exception {
    WifiInfo info = mirror.android.net.wifi.WifiInfo.ctor.newInstance();
    IPInfo ip = getIPInfo();
    InetAddress address = (ip != null ? ip.addr : null);
    mirror.android.net.wifi.WifiInfo.mNetworkId.set(info, 1);
    mirror.android.net.wifi.WifiInfo.mSupplicantState.set(info, SupplicantState.COMPLETED);
    mirror.android.net.wifi.WifiInfo.mBSSID.set(info, VASettings.Wifi.BSSID);
    mirror.android.net.wifi.WifiInfo.mMacAddress.set(info, VASettings.Wifi.MAC);
    mirror.android.net.wifi.WifiInfo.mIpAddress.set(info, address);
    mirror.android.net.wifi.WifiInfo.mLinkSpeed.set(info, 65);
    if (Build.VERSION.SDK_INT >= 21) {
        mirror.android.net.wifi.WifiInfo.mFrequency.set(info, 5000); // MHz
    }
    mirror.android.net.wifi.WifiInfo.mRssi.set(info, 200); // MAX_RSSI
    if (mirror.android.net.wifi.WifiInfo.mWifiSsid != null) {
        mirror.android.net.wifi.WifiInfo.mWifiSsid.set(info, WifiSsid.createFromAsciiEncoded.call(VASettings.Wifi.SSID));
    } else {
        mirror.android.net.wifi.WifiInfo.mSSID.set(info, VASettings.Wifi.SSID);
    }
    return info;
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:22,代碼來源:WifiManagerStub.java

示例3: isAlreadyConnected

import android.net.wifi.SupplicantState; //導入依賴的package包/類
/**
 * Checks if the user is already connected to a wifi access point.
 * @return True, if connected.
 */
public boolean isAlreadyConnected() {
    // get an instance of the wifi-manager and information of the current access point
    WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    SupplicantState supplicantState = wifiInfo.getSupplicantState();

    // does the supplicant wifi-cli have a completed-state?
    if(SupplicantState.COMPLETED.equals(supplicantState)) {
        // completed state, connected to access point
        Log.d(LOG_TAG, "Already connected to an access point");

        return true;
    }
    else {
        return false;
    }
}
 
開發者ID:deshi-basara,項目名稱:susurrus-android-app,代碼行數:22,代碼來源:WifiDirectService.java

示例4: onReceive

import android.net.wifi.SupplicantState; //導入依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action)) {
        handleWifiStateChanged(intent.getIntExtra(
                WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_UNKNOWN));
    } else if (WifiManager.SUPPLICANT_STATE_CHANGED_ACTION.equals(action)) {
        if (!mConnected.get()) {
            handleStateChanged(WifiInfo.getDetailedStateOf((SupplicantState)
                    intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE)));
        }
    } else if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(action)) {
        NetworkInfo info = (NetworkInfo) intent.getParcelableExtra(
                WifiManager.EXTRA_NETWORK_INFO);
        mConnected.set(info.isConnected());
        handleStateChanged(info.getDetailedState());
    }
}
 
開發者ID:voyagewu,項目名稱:AndroidSettingDemoAP,代碼行數:19,代碼來源:WifiEnabler.java

示例5: supplicantStateChanges

import android.net.wifi.SupplicantState; //導入依賴的package包/類
@SuppressWarnings("ResourceType") @Test //
public void supplicantStateChanges() throws IllegalAccessException, InstantiationException {
  Application application = RuntimeEnvironment.application;

  TestSubscriber<SupplicantStateChangedEvent> o = new TestSubscriber<>();
  RxWifiManager.supplicantStateChanges(application).subscribe(o);
  o.assertValues();

  Intent intent1 = new Intent(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION) //
      .putExtra(EXTRA_NEW_STATE, (Parcelable) SupplicantState.INACTIVE)
      .putExtra(EXTRA_SUPPLICANT_ERROR, ERROR_AUTHENTICATING);
  application.sendBroadcast(intent1);
  SupplicantStateChangedEvent event1 =
      SupplicantStateChangedEvent.create(SupplicantState.INACTIVE, ERROR_AUTHENTICATING);
  o.assertValues(event1);

  Intent intent2 = new Intent(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION) //
      .putExtra(EXTRA_NEW_STATE, (Parcelable) SupplicantState.ASSOCIATING)
      .putExtra(EXTRA_SUPPLICANT_ERROR, -1);
  application.sendBroadcast(intent2);
  SupplicantStateChangedEvent event2 =
      SupplicantStateChangedEvent.create(SupplicantState.ASSOCIATING, -1);
  o.assertValues(event1, event2);
}
 
開發者ID:f2prateek,項目名稱:rx-receivers,代碼行數:25,代碼來源:RxWifiManagerTest.java

示例6: updateTrust

import android.net.wifi.SupplicantState; //導入依賴的package包/類
private void updateTrust(String trustedSsid) {
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    if (wifiInfo == null) {
        return;
    }

    if (wifiInfo.getSSID() == null) {
        return;
    }

    if (wifiInfo.getSupplicantState() == SupplicantState.COMPLETED) {
        if (trustedSsid.equals(wifiInfo.getSSID())) {
            GhettoTrustAgent.sendGrantTrust(this, "GhettoTrustAgent", TRUST_DURATION_30SECS,
                    false);
        }
        else {
            Log.d(TAG, "Found insecure SSID: " + trustedSsid);
            GhettoTrustAgent.sendRevokeTrust(this);
        }
    } else {
        Log.d(TAG, "Disconnected from Wifi: " + trustedSsid);
        GhettoTrustAgent.sendRevokeTrust(this);
    }
}
 
開發者ID:nelenkov,項目名稱:ghetto-unlock,代碼行數:25,代碼來源:GhettoTrustAgentSettings.java

示例7: isAlreadyConnected

import android.net.wifi.SupplicantState; //導入依賴的package包/類
private boolean isAlreadyConnected(WifiManager wm) {
	boolean alreadyConnected = false;
	WifiInfo connectionInfo = wm.getConnectionInfo();
	if (connectionInfo != null) {
		SupplicantState supplicantState = connectionInfo.getSupplicantState();
		if (supplicantState != null) {
			alreadyConnected = supplicantState.equals(SupplicantState.ASSOCIATING)
					|| supplicantState.equals(SupplicantState.ASSOCIATED)
					|| supplicantState.equals(SupplicantState.COMPLETED)
					|| supplicantState.equals(SupplicantState.FOUR_WAY_HANDSHAKE)
					|| supplicantState.equals(SupplicantState.GROUP_HANDSHAKE);
		}
	}

	return alreadyConnected;
}
 
開發者ID:gjedeer,項目名稱:androidwisprclient,代碼行數:17,代碼來源:NetworkScanReceiver.java

示例8: execute

import android.net.wifi.SupplicantState; //導入依賴的package包/類
@Override
public void execute(Context service) 
{
       delegate.setInstallingState(IndicatorState.ACTIVE, 0, service.getString(R.string.if_ardrone_led_green_reset_wifi_connection));
       
       boolean connected = false;
       WifiManager mgr = (WifiManager) service.getSystemService(Context.WIFI_SERVICE);
       
       while (!connected) {
           WifiInfo info = mgr.getConnectionInfo();
           
           SupplicantState state = info.getSupplicantState();
           
           if (state == SupplicantState.COMPLETED ||
               state == SupplicantState.DORMANT) {
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                  break;
               }
               break;
           }
       }
       
       delegate.setInstallingState(IndicatorState.ACTIVE, 0, service.getString(R.string.if_ardrone_led_green_reset_wifi_connection));
}
 
開發者ID:fblandroidhackathon,項目名稱:persontracker,代碼行數:27,代碼來源:UpdaterInstallCommand.java

示例9: onReceive

import android.net.wifi.SupplicantState; //導入依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {

    final String action = intent.getAction();
    if(BuildConfig.DEBUG) Logger.debug(TAG, "onReceive:" + action);

    if (WifiManager.SUPPLICANT_STATE_CHANGED_ACTION .equals(action)) {
        SupplicantState state = intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE);
        if(state == SupplicantState.COMPLETED) {
            final WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
            if(wifiManager != null) {
                WifiInfo info = wifiManager.getConnectionInfo();
                if (info != null) {
                    mContext = context;
                    onWiFiConnected(info.getSSID());
                }
            }
        }
    }
}
 
開發者ID:hmrs-cr,項目名稱:android-wear-gopro-remote,代碼行數:21,代碼來源:WifiIntentReceiver.java

示例10: isWifiConnected

import android.net.wifi.SupplicantState; //導入依賴的package包/類
/**
 * Check whether WiFi is connected
 * @param context a Context instance
 * @return true if Wifi is connected
 */
// @RequiresPermission(value = Manifest.permission.ACCESS_WIFI_STATE)
public static boolean isWifiConnected(Context context) {
    WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
    if (wifiManager == null || !wifiManager.isWifiEnabled()) return false;
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    if (wifiInfo == null || wifiInfo.getNetworkId() == -1) return false;
    return wifiInfo.getSupplicantState() == SupplicantState.ASSOCIATED;
}
 
開發者ID:PrivacyStreams,項目名稱:PrivacyStreams,代碼行數:14,代碼來源:DeviceUtils.java

示例11: onReceive

import android.net.wifi.SupplicantState; //導入依賴的package包/類
@Override
public void onReceive(final Context context, Intent intent) {
    String action = intent.getAction();
    if (WifiManager.SUPPLICANT_STATE_CHANGED_ACTION.equals(action)) {
        SupplicantState state = intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE);
        if (!(SupplicantState.isValidState(state) && state == SupplicantState.COMPLETED)) {
            Logger.getInstance().Warning(TAG, "Not yet a valid connection!");
            return;
        }
    }

    new Handler().postDelayed(() -> {
        BroadcastController broadcastController = new BroadcastController(context);
        if (new NetworkController(context).IsHomeNetwork(SettingsController.getInstance().GetHomeSsid())) {
            if (!new AndroidSystemController(context).IsServiceRunning(MainService.class)) {
                Intent startMainServiceIntent = new Intent(context, MainService.class);
                startMainServiceIntent.putExtra(MainService.MainServiceOnStartCommandBundle, true);
                context.startService(startMainServiceIntent);
            } else {
                broadcastController.SendSimpleBroadcast(MainService.MainServiceStartDownloadAllBroadcast);
            }
            broadcastController.SendSimpleBroadcast(NetworkController.WIFIReceiverInHomeNetworkBroadcast);
        } else {
            TemperatureService.getInstance().CloseNotification();
            WirelessSocketService.getInstance().CloseNotification();
            WirelessSwitchService.getInstance().CloseNotification();
            broadcastController.SendSimpleBroadcast(NetworkController.WIFIReceiverNoHomeNetworkBroadcast);
        }
    }, 10 * 1000);
}
 
開發者ID:GuepardoApps,項目名稱:LucaHome-AndroidApplication,代碼行數:31,代碼來源:WIFIReceiver.java

示例12: serializeWifiInfo

import android.net.wifi.SupplicantState; //導入依賴的package包/類
private JSONObject serializeWifiInfo(WifiInfo data) throws JSONException {
    JSONObject result = new JSONObject(mGson.toJson(data));
    result.put("SSID", trimQuotationMarks(data.getSSID()));
    for (SupplicantState state : SupplicantState.values()) {
        if (data.getSupplicantState().equals(state)) {
            result.put("SupplicantState", state.name());
        }
    }
    return result;
}
 
開發者ID:google,項目名稱:mobly-bundled-snippets,代碼行數:11,代碼來源:JsonSerializer.java

示例13: connectNetwork

import android.net.wifi.SupplicantState; //導入依賴的package包/類
/**
 *    This method connects a network.
 *
 *    @param    callbackContext        A Cordova callback context
 *    @param    data                JSON Array, with [0] being SSID to connect
 *    @return    true if network connected, false if failed
 */
private boolean connectNetwork(CallbackContext callbackContext, JSONArray data) {
    Log.d(TAG, "WifiWizard: connectNetwork entered.");
    if(!validateData(data)) {
        callbackContext.error("WifiWizard: connectNetwork invalid data");
        Log.d(TAG, "WifiWizard: connectNetwork invalid data.");
        return false;
    }
    String ssidToConnect = "";

    try {
        ssidToConnect = data.getString(0);
    }
    catch (Exception e) {
        callbackContext.error(e.getMessage());
        Log.d(TAG, e.getMessage());
        return false;
    }

    int networkIdToConnect = ssidToNetworkId(ssidToConnect);

    if (networkIdToConnect >= 0) {
        // We disable the network before connecting, because if this was the last connection before
        // a disconnect(), this will not reconnect.
        wifiManager.disableNetwork(networkIdToConnect);
        wifiManager.enableNetwork(networkIdToConnect, true);

        SupplicantState supState;
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        supState = wifiInfo.getSupplicantState();
        callbackContext.success(supState.toString());
        return true;

    }else{
        callbackContext.error("WifiWizard: cannot connect to network");
        return false;
    }
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:45,代碼來源:WifiWizard.java

示例14: startScan

import android.net.wifi.SupplicantState; //導入依賴的package包/類
private void startScan() {
  SupplicantState wifiState = remoController.getWifiState();
  Log.d(TAG, "startScan: " + wifiState);

  if (wifiState != SupplicantState.COMPLETED) {
    changeState(State.WIFI_ERROR);
    showWifiErrorDialog();
    return;
  } else {
    changeState(State.SCAN);
    remoController.startDiscovery();
    deviceMap = new HashMap<String, String>();
    showScanDialog();
  }
}
 
開發者ID:tkrworks,項目名稱:JinsMemeBRIDGE-Android,代碼行數:16,代碼來源:RemoConfigFragment.java

示例15: onReceive

import android.net.wifi.SupplicantState; //導入依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    if (WifiManager.SUPPLICANT_STATE_CHANGED_ACTION .equals(action)) {
        SupplicantState state = intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE);
        if (SupplicantState.isValidState(state)
                && state == SupplicantState.COMPLETED) {

            mIsConnected = checkConnectedToDesiredWifi();
            if(mCallback != null){
                if(mIsConnected){
                    mCallback.onSuccess();
                }
                else{
                    mCallback.onFailed();
                }
            }

        }
        else if(SupplicantState.isValidState(state)
                && state == SupplicantState.DISCONNECTED){
            Log.d(mTAG, "Wifi STA is disconnected");
            WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
            wifiManager.reconnect();
        }
    }
}
 
開發者ID:dmtan90,項目名稱:Sense-Hub-Android-Things,代碼行數:28,代碼來源:WifiSta.java


注:本文中的android.net.wifi.SupplicantState類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。