diff options
author | Zoltan Szatmary-Ban <szatmz@google.com> | 2015-05-15 20:22:34 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-05-15 20:22:34 +0000 |
commit | cb5444ad2ccf2f16bddafb8844cde6a1a92adddb (patch) | |
tree | a79d26575e5550d4aa76d7d25797975cd559aaf2 /src/com/android/settings/wifi | |
parent | 0c0e35ef3008e3b2c8c67d7454cbe46d3d848625 (diff) | |
parent | 1a2aa9942f2c14bdaf46ce4911f9838dc21652ba (diff) | |
download | packages_apps_Settings-cb5444ad2ccf2f16bddafb8844cde6a1a92adddb.zip packages_apps_Settings-cb5444ad2ccf2f16bddafb8844cde6a1a92adddb.tar.gz packages_apps_Settings-cb5444ad2ccf2f16bddafb8844cde6a1a92adddb.tar.bz2 |
Merge "Reflect Wifi config lockdown restriction in Settings" into mnc-dev
Diffstat (limited to 'src/com/android/settings/wifi')
-rw-r--r-- | src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java | 2 | ||||
-rw-r--r-- | src/com/android/settings/wifi/WifiSettings.java | 19 |
2 files changed, 13 insertions, 8 deletions
diff --git a/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java b/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java index 1444ad5..2d200b5 100644 --- a/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java +++ b/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java @@ -147,7 +147,7 @@ public class SavedAccessPointsWifiSettings extends SettingsPreferenceFragment mSelectedAccessPoint = mDlgAccessPoint; // Hide forget button if config editing is locked down - final boolean hideForgetButton = WifiSettings.isCreatorDeviceOwner(getActivity(), + final boolean hideForgetButton = WifiSettings.isEditabilityLockedDown(getActivity(), mDlgAccessPoint.getConfig()); mDialog = new WifiDialog(getActivity(), this, mDlgAccessPoint, false /* not editting */, true /* hide the submit button */, diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java index 0c28db3..97612a9 100644 --- a/src/com/android/settings/wifi/WifiSettings.java +++ b/src/com/android/settings/wifi/WifiSettings.java @@ -43,6 +43,7 @@ import android.nfc.NfcAdapter; import android.os.Bundle; import android.os.RemoteException; import android.os.UserHandle; +import android.os.UserManager; import android.preference.Preference; import android.preference.PreferenceScreen; import android.text.Spannable; @@ -439,8 +440,8 @@ public class WifiSettings extends RestrictedSettingsFragment } WifiConfiguration config = mSelectedAccessPoint.getConfig(); - // Device Owner created configs are uneditable - if (isCreatorDeviceOwner(getActivity(), config)) { + // Some configs are ineditable + if (isEditabilityLockedDown(getActivity(), config)) { return; } @@ -522,7 +523,7 @@ public class WifiSettings extends RestrictedSettingsFragment private void showDialog(AccessPoint accessPoint, boolean edit) { if (accessPoint != null) { WifiConfiguration config = accessPoint.getConfig(); - if (isCreatorDeviceOwner(getActivity(), config) && accessPoint.isActive()) { + if (isEditabilityLockedDown(getActivity(), config) && accessPoint.isActive()) { final int userId = UserHandle.getUserId(config.creatorUid); final PackageManager pm = getActivity().getPackageManager(); final IPackageManager ipm = AppGlobals.getPackageManager(); @@ -575,7 +576,7 @@ public class WifiSettings extends RestrictedSettingsFragment } // If it's null, fine, it's for Add Network mSelectedAccessPoint = ap; - final boolean hideForget = (ap == null || isCreatorDeviceOwner(getActivity(), + final boolean hideForget = (ap == null || isEditabilityLockedDown(getActivity(), ap.getConfig())); mDialog = new WifiDialog(getActivity(), this, ap, mDlgEdit, /* no hide submit/connect */ false, @@ -913,11 +914,11 @@ public class WifiSettings extends RestrictedSettingsFragment }; /** - * Returns the true if the app that created this config is the device owner of the device. + * Returns true if the config is not editable/removable except by its creating Device Owner. * @param config The WiFi config. - * @return creator package name or null if creator package is not device owner. + * @return true if the config is not editable/removable except by its creating Device Owner. */ - static boolean isCreatorDeviceOwner(Context context, WifiConfiguration config) { + static boolean isEditabilityLockedDown(Context context, WifiConfiguration config) { if (config == null) { return false; } @@ -927,6 +928,10 @@ public class WifiSettings extends RestrictedSettingsFragment if (deviceOwnerPackageName == null) { return false; } + UserManager um = UserManager.get(context); + if (um.hasUserRestriction(UserManager.DISALLOW_CONFIG_WIFI)) { + return false; + } final PackageManager pm = context.getPackageManager(); try { final int deviceOwnerUid = pm.getPackageUid(deviceOwnerPackageName, |