Implement Settings app UX for when a user has wifi config locked down.
When the user is restricted from configuring wifi: - Leave the on/off button enabled - Hide all menu options - Hide all networks, and display a message saying: "This user is not allowed to configure wireless networks." Change-Id: I20193b552ea071740686bd9091637459e9b668b5
This commit is contained in:
@@ -1207,6 +1207,8 @@
|
|||||||
<string name="wifi_display_searching_for_devices">Searching\u2026</string>
|
<string name="wifi_display_searching_for_devices">Searching\u2026</string>
|
||||||
<!-- Wifi Display settings. Text that appears when scanning for devices is finished and no nearby device was found [CHAR LIMIT=40]-->
|
<!-- Wifi Display settings. Text that appears when scanning for devices is finished and no nearby device was found [CHAR LIMIT=40]-->
|
||||||
<string name="wifi_display_no_devices_found">No nearby wireless displays were found.</string>
|
<string name="wifi_display_no_devices_found">No nearby wireless displays were found.</string>
|
||||||
|
<!-- Wifi Display settings. Text displayed when user has restriction DISALLOW_CONFIG_WIFI-->
|
||||||
|
<string name="wifi_display_settings_empty_list_user_restricted">This user is not allowed to configure wireless networks.</string>
|
||||||
<!-- Wifi Display settings. The sub heading for devices which have already been paired with this device. [CHAR LIMIT=40] -->
|
<!-- Wifi Display settings. The sub heading for devices which have already been paired with this device. [CHAR LIMIT=40] -->
|
||||||
<string name="wifi_display_paired_devices">Paired displays</string>
|
<string name="wifi_display_paired_devices">Paired displays</string>
|
||||||
<!-- Wifi Display settings. The sub heading for available devices during and after scanning. [CHAR LIMIT=40] -->
|
<!-- Wifi Display settings. The sub heading for available devices during and after scanning. [CHAR LIMIT=40] -->
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
package com.android.settings.wifi;
|
package com.android.settings.wifi;
|
||||||
|
|
||||||
import static android.net.wifi.WifiConfiguration.INVALID_NETWORK_ID;
|
import static android.net.wifi.WifiConfiguration.INVALID_NETWORK_ID;
|
||||||
|
import static android.os.UserManager.DISALLOW_CONFIG_WIFI;
|
||||||
|
|
||||||
import android.app.ActionBar;
|
import android.app.ActionBar;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
@@ -41,6 +42,7 @@ import android.net.wifi.WpsInfo;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
import android.os.UserManager;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
@@ -126,6 +128,8 @@ public class WifiSettings extends SettingsPreferenceFragment
|
|||||||
private boolean mP2pSupported;
|
private boolean mP2pSupported;
|
||||||
|
|
||||||
|
|
||||||
|
private UserManager mUserManager;
|
||||||
|
|
||||||
private WifiEnabler mWifiEnabler;
|
private WifiEnabler mWifiEnabler;
|
||||||
// An access point being editted is stored here.
|
// An access point being editted is stored here.
|
||||||
private AccessPoint mSelectedAccessPoint;
|
private AccessPoint mSelectedAccessPoint;
|
||||||
@@ -276,6 +280,7 @@ public class WifiSettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
mP2pSupported = getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI_DIRECT);
|
mP2pSupported = getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI_DIRECT);
|
||||||
mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
|
mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
|
||||||
|
mUserManager = (UserManager) getSystemService(Context.USER_SERVICE);
|
||||||
|
|
||||||
mConnectListener = new WifiManager.ActionListener() {
|
mConnectListener = new WifiManager.ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -431,6 +436,9 @@ public class WifiSettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
|
// If the user is not allowed to configure wifi, do not show the menu.
|
||||||
|
if (mUserManager.hasUserRestriction(DISALLOW_CONFIG_WIFI)) return;
|
||||||
|
|
||||||
final boolean wifiIsEnabled = mWifiManager.isWifiEnabled();
|
final boolean wifiIsEnabled = mWifiManager.isWifiEnabled();
|
||||||
if (mSetupWizardMode) {
|
if (mSetupWizardMode) {
|
||||||
// FIXME: add setIcon() when graphics are available
|
// FIXME: add setIcon() when graphics are available
|
||||||
@@ -486,6 +494,9 @@ public class WifiSettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
// If the user is not allowed to configure wifi, do not handle menu selections.
|
||||||
|
if (mUserManager.hasUserRestriction(DISALLOW_CONFIG_WIFI)) return false;
|
||||||
|
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case MENU_ID_WPS_PBC:
|
case MENU_ID_WPS_PBC:
|
||||||
showDialog(WPS_PBC_DIALOG_ID);
|
showDialog(WPS_PBC_DIALOG_ID);
|
||||||
@@ -704,6 +715,10 @@ public class WifiSettings extends SettingsPreferenceFragment
|
|||||||
// Safeguard from some delayed event handling
|
// Safeguard from some delayed event handling
|
||||||
if (getActivity() == null) return;
|
if (getActivity() == null) return;
|
||||||
|
|
||||||
|
if (mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_WIFI)) {
|
||||||
|
addMessagePreference(R.string.wifi_display_settings_empty_list_user_restricted);
|
||||||
|
return;
|
||||||
|
}
|
||||||
final int wifiState = mWifiManager.getWifiState();
|
final int wifiState = mWifiManager.getWifiState();
|
||||||
|
|
||||||
switch (wifiState) {
|
switch (wifiState) {
|
||||||
|
Reference in New Issue
Block a user