Reflect Wifi config lockdown restriction in Settings
DO created WiFi configurations are now only locked down for editing/removing if DISALLOW_CONFIG_WIFI is not set. This needed to be reflected on Settings UI. Bug: 20719934 Change-Id: Ibd218821ab46cca8396084e2d73ae5ee00b584b3
This commit is contained in:
@@ -158,7 +158,7 @@ public class SavedAccessPointsWifiSettings extends SettingsPreferenceFragment
|
|||||||
mSelectedAccessPoint = mDlgAccessPoint;
|
mSelectedAccessPoint = mDlgAccessPoint;
|
||||||
|
|
||||||
// Hide forget button if config editing is locked down
|
// Hide forget button if config editing is locked down
|
||||||
final boolean hideForgetButton = WifiSettings.isCreatorDeviceOwner(getActivity(),
|
final boolean hideForgetButton = WifiSettings.isEditabilityLockedDown(getActivity(),
|
||||||
mDlgAccessPoint.getConfig());
|
mDlgAccessPoint.getConfig());
|
||||||
mDialog = new WifiDialog(getActivity(), this, mDlgAccessPoint,
|
mDialog = new WifiDialog(getActivity(), this, mDlgAccessPoint,
|
||||||
false /* not editting */, true /* hide the submit button */,
|
false /* not editting */, true /* hide the submit button */,
|
||||||
|
@@ -43,6 +43,7 @@ import android.nfc.NfcAdapter;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
|
import android.os.UserManager;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
@@ -450,8 +451,8 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
WifiConfiguration config = mSelectedAccessPoint.getConfig();
|
WifiConfiguration config = mSelectedAccessPoint.getConfig();
|
||||||
// Device Owner created configs are uneditable
|
// Some configs are ineditable
|
||||||
if (isCreatorDeviceOwner(getActivity(), config)) {
|
if (isEditabilityLockedDown(getActivity(), config)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -533,7 +534,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
private void showDialog(AccessPoint accessPoint, boolean edit) {
|
private void showDialog(AccessPoint accessPoint, boolean edit) {
|
||||||
if (accessPoint != null) {
|
if (accessPoint != null) {
|
||||||
WifiConfiguration config = accessPoint.getConfig();
|
WifiConfiguration config = accessPoint.getConfig();
|
||||||
if (isCreatorDeviceOwner(getActivity(), config) && accessPoint.isActive()) {
|
if (isEditabilityLockedDown(getActivity(), config) && accessPoint.isActive()) {
|
||||||
final int userId = UserHandle.getUserId(config.creatorUid);
|
final int userId = UserHandle.getUserId(config.creatorUid);
|
||||||
final PackageManager pm = getActivity().getPackageManager();
|
final PackageManager pm = getActivity().getPackageManager();
|
||||||
final IPackageManager ipm = AppGlobals.getPackageManager();
|
final IPackageManager ipm = AppGlobals.getPackageManager();
|
||||||
@@ -586,7 +587,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
}
|
}
|
||||||
// If it's null, fine, it's for Add Network
|
// If it's null, fine, it's for Add Network
|
||||||
mSelectedAccessPoint = ap;
|
mSelectedAccessPoint = ap;
|
||||||
final boolean hideForget = (ap == null || isCreatorDeviceOwner(getActivity(),
|
final boolean hideForget = (ap == null || isEditabilityLockedDown(getActivity(),
|
||||||
ap.getConfig()));
|
ap.getConfig()));
|
||||||
mDialog = new WifiDialog(getActivity(), this, ap, mDlgEdit,
|
mDialog = new WifiDialog(getActivity(), this, ap, mDlgEdit,
|
||||||
/* no hide submit/connect */ false,
|
/* no hide submit/connect */ false,
|
||||||
@@ -918,11 +919,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.
|
* @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) {
|
if (config == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -932,6 +933,10 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
if (deviceOwnerPackageName == null) {
|
if (deviceOwnerPackageName == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
UserManager um = UserManager.get(context);
|
||||||
|
if (um.hasUserRestriction(UserManager.DISALLOW_CONFIG_WIFI)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
final PackageManager pm = context.getPackageManager();
|
final PackageManager pm = context.getPackageManager();
|
||||||
try {
|
try {
|
||||||
final int deviceOwnerUid = pm.getPackageUid(deviceOwnerPackageName,
|
final int deviceOwnerUid = pm.getPackageUid(deviceOwnerPackageName,
|
||||||
|
Reference in New Issue
Block a user