List of usage examples for android.app.admin DevicePolicyManager EXTRA_PROVISIONING_WIFI_SSID
String EXTRA_PROVISIONING_WIFI_SSID
To view the source code for android.app.admin DevicePolicyManager EXTRA_PROVISIONING_WIFI_SSID.
Click Source Link
From source file:com.example.android.nfcprovisioning.NfcProvisioningFragment.java
@Override public NdefMessage createNdefMessage(NfcEvent event) { if (mProvisioningValues == null) { return null; }// w w w .j a v a2s . com ByteArrayOutputStream stream = new ByteArrayOutputStream(); Properties properties = new Properties(); // Store all the values into the Properties object for (Map.Entry<String, String> e : mProvisioningValues.entrySet()) { if (!TextUtils.isEmpty(e.getValue())) { String value; if (e.getKey().equals(DevicePolicyManager.EXTRA_PROVISIONING_WIFI_SSID)) { // Make sure to surround SSID with double quotes value = e.getValue(); if (!value.startsWith("\"") || !value.endsWith("\"")) { value = "\"" + value + "\""; } } else { value = e.getValue(); } properties.put(e.getKey(), value); } } // Make sure to put local time in the properties. This is necessary on some devices to // reliably download the device owner APK from an HTTPS connection. if (!properties.contains(DevicePolicyManager.EXTRA_PROVISIONING_LOCAL_TIME)) { properties.put(DevicePolicyManager.EXTRA_PROVISIONING_LOCAL_TIME, String.valueOf(System.currentTimeMillis())); } try { properties.store(stream, getString(R.string.nfc_comment)); NdefRecord record = NdefRecord.createMime(DevicePolicyManager.MIME_TYPE_PROVISIONING_NFC, stream.toByteArray()); return new NdefMessage(new NdefRecord[] { record }); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:com.example.android.nfcprovisioning.ProvisioningValuesLoader.java
private void loadSystemValues(HashMap<String, String> values) { Context context = getContext(); putIfMissing(values, DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME, "com.example.android.deviceowner"); putIfMissing(values, DevicePolicyManager.EXTRA_PROVISIONING_LOCALE, context.getResources().getConfiguration().locale.toString()); putIfMissing(values, DevicePolicyManager.EXTRA_PROVISIONING_TIME_ZONE, TimeZone.getDefault().getID()); if (!values.containsKey(DevicePolicyManager.EXTRA_PROVISIONING_WIFI_SSID)) { WifiManager wifiManager = (WifiManager) context.getSystemService(Activity.WIFI_SERVICE); WifiInfo info = wifiManager.getConnectionInfo(); values.put(DevicePolicyManager.EXTRA_PROVISIONING_WIFI_SSID, trimSsid(info.getSSID())); }// w w w . ja v a 2s . co m }
From source file:com.example.android.nfcprovisioning.NfcProvisioningFragment.java
@Override public void onTextChanged(int id, String s) { if (mProvisioningValues == null) { return;//from ww w . j a v a 2 s . c o m } switch (id) { case R.id.package_name: mProvisioningValues.put(DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME, s); break; case R.id.locale: mProvisioningValues.put(DevicePolicyManager.EXTRA_PROVISIONING_LOCALE, s); break; case R.id.timezone: mProvisioningValues.put(DevicePolicyManager.EXTRA_PROVISIONING_TIME_ZONE, s); break; case R.id.wifi_ssid: mProvisioningValues.put(DevicePolicyManager.EXTRA_PROVISIONING_WIFI_SSID, s); break; case R.id.wifi_security_type: mProvisioningValues.put(DevicePolicyManager.EXTRA_PROVISIONING_WIFI_SECURITY_TYPE, s); break; case R.id.wifi_password: mProvisioningValues.put(DevicePolicyManager.EXTRA_PROVISIONING_WIFI_PASSWORD, s); break; } }
From source file:com.example.android.nfcprovisioning.NfcProvisioningFragment.java
@Override public void onLoadFinished(Loader<Map<String, String>> loader, Map<String, String> values) { if (loader.getId() == LOADER_PROVISIONING_VALUES) { mProvisioningValues = values;//from w ww.j a v a 2s.c o m mEditPackageName.setText(values.get(DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME)); mEditLocale.setText(values.get(DevicePolicyManager.EXTRA_PROVISIONING_LOCALE)); mEditTimezone.setText(values.get(DevicePolicyManager.EXTRA_PROVISIONING_TIME_ZONE)); mEditWifiSsid.setText(values.get(DevicePolicyManager.EXTRA_PROVISIONING_WIFI_SSID)); mEditWifiSecurityType.setText(values.get(DevicePolicyManager.EXTRA_PROVISIONING_WIFI_SECURITY_TYPE)); mEditWifiPassword.setText(null); } }