com.google.zxing.client.result.WifiParsedResult Java Examples

The following examples show how to use com.google.zxing.client.result.WifiParsedResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WifiResultHandler.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 6 votes vote down vote up
@Override
public void handleButtonPress(int index) {
  if (index == 0) {
    WifiParsedResult wifiResult = (WifiParsedResult) getResult();
    WifiManager wifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE);
    if (wifiManager == null) {
      Log.w(TAG, "No WifiManager available from device");
      return;
    }
    final Activity activity = getActivity();
    activity.runOnUiThread(new Runnable() {
      @Override
      public void run() {
        Toast.makeText(activity.getApplicationContext(), R.string.wifi_changing_network, Toast.LENGTH_SHORT).show();
      }
    });
    new WifiConfigManager(wifiManager).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, wifiResult);
    parent.restartPreviewAfterDelay(0L);
  }
}
 
Example #2
Source File: WifiResultHandler.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
@Override
public void handleButtonPress(int index) {
  if (index == 0) {
    WifiParsedResult wifiResult = (WifiParsedResult) getResult();
    WifiManager wifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE);
    if (wifiManager == null) {
      Log.w(TAG, "No WifiManager available from device");
      return;
    }
    final Activity activity = getActivity();
    activity.runOnUiThread(new Runnable() {
      @Override
      public void run() {
        Toast.makeText(activity.getApplicationContext(), R.string.wifi_changing_network, Toast.LENGTH_SHORT).show();
      }
    });
    new WifiConfigManager(wifiManager).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, wifiResult);
    parent.restartPreviewAfterDelay(0L);
  }
}
 
Example #3
Source File: WifiResultFragment.java    From privacy-friendly-qr-scanner with GNU General Public License v3.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    View v = inflater.inflate(R.layout.fragment_result_wifi, container, false);
    result = (WifiParsedResult) parsedResult;

    ssid = result.getSsid();
    String encryption = result.getNetworkEncryption();
    pw = result.getPassword();

    TextView resultField = (TextView) v.findViewById(R.id.result_field_wifi);
    TextView resultFieldEncryption = (TextView) v.findViewById(R.id.result_field_wifi_encryption);
    TextView resultFieldPassword = (TextView) v.findViewById(R.id.result_field_wifi_pw);
    resultField.setText("SSID: " + ssid);
    resultFieldEncryption.setText(getString(R.string.encryption) + ": " + encryption);
    resultFieldPassword.setText("PW: " + pw);

    return v;
}
 
Example #4
Source File: WifiResultHandler.java    From weex with Apache License 2.0 6 votes vote down vote up
@Override
public void handleButtonPress(int index) {
  if (index == 0) {
    WifiParsedResult wifiResult = (WifiParsedResult) getResult();
    WifiManager wifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE);
    if (wifiManager == null) {
      Log.w(TAG, "No WifiManager available from device");
      return;
    }
    final Activity activity = getActivity();
    activity.runOnUiThread(new Runnable() {
      @Override
      public void run() {
        Toast.makeText(activity.getApplicationContext(), R.string.wifi_changing_network, Toast.LENGTH_SHORT).show();
      }
    });
    new WifiConfigManager(wifiManager).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, wifiResult);
    parent.restartPreviewAfterDelay(0L);
  }
}
 
Example #5
Source File: WifiResultHandler.java    From barcodescanner-lib-aar with MIT License 6 votes vote down vote up
@Override
public void handleButtonPress(int index) {
  if (index == 0) {
    WifiParsedResult wifiResult = (WifiParsedResult) getResult();
    WifiManager wifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE);
    if (wifiManager == null) {
      Log.w(TAG, "No WifiManager available from device");
      return;
    }
    final Activity activity = getActivity();
    activity.runOnUiThread(new Runnable() {
      @Override
      public void run() {
        Toast.makeText(activity.getApplicationContext(), R.string.wifi_changing_network, Toast.LENGTH_SHORT).show();
      }
    });
    new WifiConfigManager(wifiManager).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, wifiResult);
    parent.restartPreviewAfterDelay(0L);
  }
}
 
Example #6
Source File: WifiResultHandler.java    From ZXing-Standalone-library with Apache License 2.0 6 votes vote down vote up
@Override
public void handleButtonPress(int index) {
  if (index == 0) {
    WifiParsedResult wifiResult = (WifiParsedResult) getResult();
    WifiManager wifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE);
    if (wifiManager == null) {
      Log.w(TAG, "No WifiManager available from device");
      return;
    }
    final Activity activity = getActivity();
    activity.runOnUiThread(new Runnable() {
      @Override
      public void run() {
        Toast.makeText(activity.getApplicationContext(), R.string.wifi_changing_network, Toast.LENGTH_SHORT).show();
      }
    });
    new WifiConfigManager(wifiManager).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, wifiResult);
    parent.restartPreviewAfterDelay(0L);
  }
}
 
Example #7
Source File: WifiConfigManager.java    From reacteu-app with MIT License 5 votes vote down vote up
private static void changeNetworkWPA(WifiManager wifiManager, WifiParsedResult wifiResult) {
  WifiConfiguration config = changeNetworkCommon(wifiResult);
  // Hex passwords that are 64 bits long are not to be quoted.
  config.preSharedKey = quoteNonHex(wifiResult.getPassword(), 64);
  config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
  config.allowedProtocols.set(WifiConfiguration.Protocol.WPA); // For WPA
  config.allowedProtocols.set(WifiConfiguration.Protocol.RSN); // For WPA2
  config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
  config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);
  config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
  config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
  updateNetwork(wifiManager, config);
}
 
Example #8
Source File: WifiConfigManager.java    From BarcodeEye with Apache License 2.0 5 votes vote down vote up
private static void changeNetworkWPA(WifiManager wifiManager, WifiParsedResult wifiResult) {
  WifiConfiguration config = changeNetworkCommon(wifiResult);
  // Hex passwords that are 64 bits long are not to be quoted.
  config.preSharedKey = quoteNonHex(wifiResult.getPassword(), 64);
  config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
  config.allowedProtocols.set(WifiConfiguration.Protocol.WPA); // For WPA
  config.allowedProtocols.set(WifiConfiguration.Protocol.RSN); // For WPA2
  config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
  config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);
  config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
  config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
  updateNetwork(wifiManager, config);
}
 
Example #9
Source File: WifiConfigManager.java    From BarcodeEye with Apache License 2.0 5 votes vote down vote up
private static void changeNetworkWEP(WifiManager wifiManager, WifiParsedResult wifiResult) {
  WifiConfiguration config = changeNetworkCommon(wifiResult);
  config.wepKeys[0] = quoteNonHex(wifiResult.getPassword(), 10, 26, 58);
  config.wepTxKeyIndex = 0;
  config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED);
  config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);
  updateNetwork(wifiManager, config);
}
 
Example #10
Source File: WifiConfigManager.java    From barcodescanner-lib-aar with MIT License 5 votes vote down vote up
private static WifiConfiguration changeNetworkCommon(WifiParsedResult wifiResult) {
  WifiConfiguration config = new WifiConfiguration();
  config.allowedAuthAlgorithms.clear();
  config.allowedGroupCiphers.clear();
  config.allowedKeyManagement.clear();
  config.allowedPairwiseCiphers.clear();
  config.allowedProtocols.clear();
  // Android API insists that an ascii SSID must be quoted to be correctly handled.
  config.SSID = quoteNonHex(wifiResult.getSsid());
  config.hiddenSSID = wifiResult.isHidden();
  return config;
}
 
Example #11
Source File: WifiConfigManager.java    From barcodescanner-lib-aar with MIT License 5 votes vote down vote up
private static void changeNetworkWEP(WifiManager wifiManager, WifiParsedResult wifiResult) {
  WifiConfiguration config = changeNetworkCommon(wifiResult);
  config.wepKeys[0] = quoteNonHex(wifiResult.getPassword(), 10, 26, 58);
  config.wepTxKeyIndex = 0;
  config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED);
  config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);
  updateNetwork(wifiManager, config);
}
 
Example #12
Source File: WifiConfigManager.java    From barcodescanner-lib-aar with MIT License 5 votes vote down vote up
private static void changeNetworkWPA(WifiManager wifiManager, WifiParsedResult wifiResult) {
  WifiConfiguration config = changeNetworkCommon(wifiResult);
  // Hex passwords that are 64 bits long are not to be quoted.
  config.preSharedKey = quoteNonHex(wifiResult.getPassword(), 64);
  config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
  config.allowedProtocols.set(WifiConfiguration.Protocol.WPA); // For WPA
  config.allowedProtocols.set(WifiConfiguration.Protocol.RSN); // For WPA2
  config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
  config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);
  config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
  config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
  updateNetwork(wifiManager, config);
}
 
Example #13
Source File: WifiConfigManager.java    From BarcodeEye with Apache License 2.0 5 votes vote down vote up
private static WifiConfiguration changeNetworkCommon(WifiParsedResult wifiResult) {
  WifiConfiguration config = new WifiConfiguration();
  config.allowedAuthAlgorithms.clear();
  config.allowedGroupCiphers.clear();
  config.allowedKeyManagement.clear();
  config.allowedPairwiseCiphers.clear();
  config.allowedProtocols.clear();
  // Android API insists that an ascii SSID must be quoted to be correctly handled.
  config.SSID = quoteNonHex(wifiResult.getSsid());
  config.hiddenSSID = wifiResult.isHidden();
  return config;
}
 
Example #14
Source File: WifiConfigManager.java    From zxingfragmentlib with Apache License 2.0 5 votes vote down vote up
private static void changeNetworkWPA(WifiManager wifiManager, WifiParsedResult wifiResult) {
  WifiConfiguration config = changeNetworkCommon(wifiResult);
  // Hex passwords that are 64 bits long are not to be quoted.
  config.preSharedKey = quoteNonHex(wifiResult.getPassword(), 64);
  config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
  config.allowedProtocols.set(WifiConfiguration.Protocol.WPA); // For WPA
  config.allowedProtocols.set(WifiConfiguration.Protocol.RSN); // For WPA2
  config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
  config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);
  config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
  config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
  updateNetwork(wifiManager, config);
}
 
Example #15
Source File: WifiConfigManager.java    From reacteu-app with MIT License 5 votes vote down vote up
private static WifiConfiguration changeNetworkCommon(WifiParsedResult wifiResult) {
  WifiConfiguration config = new WifiConfiguration();
  config.allowedAuthAlgorithms.clear();
  config.allowedGroupCiphers.clear();
  config.allowedKeyManagement.clear();
  config.allowedPairwiseCiphers.clear();
  config.allowedProtocols.clear();
  // Android API insists that an ascii SSID must be quoted to be correctly handled.
  config.SSID = quoteNonHex(wifiResult.getSsid());
  config.hiddenSSID = wifiResult.isHidden();
  return config;
}
 
Example #16
Source File: WifiConfigManager.java    From reacteu-app with MIT License 5 votes vote down vote up
private static void changeNetworkWEP(WifiManager wifiManager, WifiParsedResult wifiResult) {
  WifiConfiguration config = changeNetworkCommon(wifiResult);
  config.wepKeys[0] = quoteNonHex(wifiResult.getPassword(), 10, 26, 58);
  config.wepTxKeyIndex = 0;
  config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED);
  config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);
  updateNetwork(wifiManager, config);
}
 
Example #17
Source File: WifiResultHandler.java    From reacteu-app with MIT License 5 votes vote down vote up
@Override
public void handleButtonPress(int index) {
  if (index == 0) {
    WifiParsedResult wifiResult = (WifiParsedResult) getResult();
    WifiManager wifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE);
    Toast.makeText(getActivity(), fakeR.getId("string", "wifi_changing_network"), Toast.LENGTH_LONG).show();
    taskExec.execute(new WifiConfigManager(wifiManager), wifiResult);
    parent.restartPreviewAfterDelay(0L);
  }
}
 
Example #18
Source File: WifiResultHandler.java    From reacteu-app with MIT License 5 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
  WifiParsedResult wifiResult = (WifiParsedResult) getResult();
  StringBuilder contents = new StringBuilder(50);
  String wifiLabel = parent.getString(fakeR.getId("string", "wifi_ssid_label"));
  ParsedResult.maybeAppend(wifiLabel + '\n' + wifiResult.getSsid(), contents);
  String typeLabel = parent.getString(fakeR.getId("string", "wifi_type_label"));
  ParsedResult.maybeAppend(typeLabel + '\n' + wifiResult.getNetworkEncryption(), contents);
  return contents.toString();
}
 
Example #19
Source File: WifiConfigManager.java    From ZXing-Standalone-library with Apache License 2.0 5 votes vote down vote up
private static WifiConfiguration changeNetworkCommon(WifiParsedResult wifiResult) {
  WifiConfiguration config = new WifiConfiguration();
  config.allowedAuthAlgorithms.clear();
  config.allowedGroupCiphers.clear();
  config.allowedKeyManagement.clear();
  config.allowedPairwiseCiphers.clear();
  config.allowedProtocols.clear();
  // Android API insists that an ascii SSID must be quoted to be correctly handled.
  config.SSID = quoteNonHex(wifiResult.getSsid());
  config.hiddenSSID = wifiResult.isHidden();
  return config;
}
 
Example #20
Source File: WifiResultHandler.java    From android-apps with MIT License 5 votes vote down vote up
@Override
public void handleButtonPress(int index) {
  // Get the underlying wifi config
  WifiParsedResult wifiResult = (WifiParsedResult) getResult();
  if (index == 0) {
    String ssid = wifiResult.getSsid();
    String password = wifiResult.getPassword();
    String networkType = wifiResult.getNetworkEncryption();
    WifiManager wifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE);
    Toast.makeText(getActivity(), R.string.wifi_changing_network, Toast.LENGTH_LONG).show();
    WifiConfigManager.configure(wifiManager, ssid, password, networkType);
    parent.restartPreviewAfterDelay(0L);
  }
}
 
Example #21
Source File: WifiResultHandler.java    From android-apps with MIT License 5 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
  WifiParsedResult wifiResult = (WifiParsedResult) getResult();
  StringBuilder contents = new StringBuilder(50);
  String wifiLabel = parent.getString(R.string.wifi_ssid_label);
  ParsedResult.maybeAppend(wifiLabel + '\n' + wifiResult.getSsid(), contents);
  String typeLabel = parent.getString(R.string.wifi_type_label);
  ParsedResult.maybeAppend(typeLabel + '\n' + wifiResult.getNetworkEncryption(), contents);
  return contents.toString();
}
 
Example #22
Source File: WifiResultHandler.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
    WifiParsedResult wifiResult = (WifiParsedResult) getResult();
    StringBuilder contents = new StringBuilder(50);
    String wifiLabel = parent.getString(R.string.wifi_ssid_label);
    ParsedResult.maybeAppend(wifiLabel + '\n' + wifiResult.getSsid(), contents);
    String typeLabel = parent.getString(R.string.wifi_type_label);
    ParsedResult.maybeAppend(typeLabel + '\n' + wifiResult.getNetworkEncryption(), contents);
    return contents.toString();
}
 
Example #23
Source File: WifiResultHandler.java    From android-quick-response-code with Apache License 2.0 5 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
    WifiParsedResult wifiResult = (WifiParsedResult) getResult();
    StringBuilder contents = new StringBuilder(50);
    String wifiLabel = parent.getString(R.string.wifi_ssid_label);
    ParsedResult.maybeAppend(wifiLabel + '\n' + wifiResult.getSsid(), contents);
    String typeLabel = parent.getString(R.string.wifi_type_label);
    ParsedResult.maybeAppend(typeLabel + '\n' + wifiResult.getNetworkEncryption(), contents);
    return contents.toString();
}
 
Example #24
Source File: WifiConfigManager.java    From zxingfragmentlib with Apache License 2.0 5 votes vote down vote up
private static WifiConfiguration changeNetworkCommon(WifiParsedResult wifiResult) {
  WifiConfiguration config = new WifiConfiguration();
  config.allowedAuthAlgorithms.clear();
  config.allowedGroupCiphers.clear();
  config.allowedKeyManagement.clear();
  config.allowedPairwiseCiphers.clear();
  config.allowedProtocols.clear();
  // Android API insists that an ascii SSID must be quoted to be correctly handled.
  config.SSID = quoteNonHex(wifiResult.getSsid());
  config.hiddenSSID = wifiResult.isHidden();
  return config;
}
 
Example #25
Source File: WifiConfigManager.java    From zxingfragmentlib with Apache License 2.0 5 votes vote down vote up
private static void changeNetworkWEP(WifiManager wifiManager, WifiParsedResult wifiResult) {
  WifiConfiguration config = changeNetworkCommon(wifiResult);
  config.wepKeys[0] = quoteNonHex(wifiResult.getPassword(), 10, 26, 58);
  config.wepTxKeyIndex = 0;
  config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED);
  config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);
  updateNetwork(wifiManager, config);
}
 
Example #26
Source File: WifiConfigManager.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
private static void changeNetworkWPA(WifiManager wifiManager, WifiParsedResult wifiResult) {
  WifiConfiguration config = changeNetworkCommon(wifiResult);
  // Hex passwords that are 64 bits long are not to be quoted.
  config.preSharedKey = quoteNonHex(wifiResult.getPassword(), 64);
  config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
  config.allowedProtocols.set(WifiConfiguration.Protocol.WPA); // For WPA
  config.allowedProtocols.set(WifiConfiguration.Protocol.RSN); // For WPA2
  config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
  config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);
  config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
  config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
  updateNetwork(wifiManager, config);
}
 
Example #27
Source File: WifiConfigManager.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
private static void changeNetworkWPA(WifiManager wifiManager, WifiParsedResult wifiResult) {
  WifiConfiguration config = changeNetworkCommon(wifiResult);
  // Hex passwords that are 64 bits long are not to be quoted.
  config.preSharedKey = quoteNonHex(wifiResult.getPassword(), 64);
  config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
  config.allowedProtocols.set(WifiConfiguration.Protocol.WPA); // For WPA
  config.allowedProtocols.set(WifiConfiguration.Protocol.RSN); // For WPA2
  config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
  config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);
  config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
  config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
  updateNetwork(wifiManager, config);
}
 
Example #28
Source File: WifiConfigManager.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
private static void changeNetworkWEP(WifiManager wifiManager, WifiParsedResult wifiResult) {
  WifiConfiguration config = changeNetworkCommon(wifiResult);
  config.wepKeys[0] = quoteNonHex(wifiResult.getPassword(), 10, 26, 58);
  config.wepTxKeyIndex = 0;
  config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED);
  config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);
  updateNetwork(wifiManager, config);
}
 
Example #29
Source File: WifiConfigManager.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
private static WifiConfiguration changeNetworkCommon(WifiParsedResult wifiResult) {
  WifiConfiguration config = new WifiConfiguration();
  config.allowedAuthAlgorithms.clear();
  config.allowedGroupCiphers.clear();
  config.allowedKeyManagement.clear();
  config.allowedPairwiseCiphers.clear();
  config.allowedProtocols.clear();
  // Android API insists that an ascii SSID must be quoted to be correctly handled.
  config.SSID = quoteNonHex(wifiResult.getSsid());
  config.hiddenSSID = wifiResult.isHidden();
  return config;
}
 
Example #30
Source File: WifiConfigManager.java    From weex with Apache License 2.0 5 votes vote down vote up
private static WifiConfiguration changeNetworkCommon(WifiParsedResult wifiResult) {
  WifiConfiguration config = new WifiConfiguration();
  config.allowedAuthAlgorithms.clear();
  config.allowedGroupCiphers.clear();
  config.allowedKeyManagement.clear();
  config.allowedPairwiseCiphers.clear();
  config.allowedProtocols.clear();
  // Android API insists that an ascii SSID must be quoted to be correctly handled.
  config.SSID = quoteNonHex(wifiResult.getSsid());
  config.hiddenSSID = wifiResult.isHidden();
  return config;
}