Show policy transparency dialog for Wi-Fi network restrictions am: 28be567a83
am: cac69880ae
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/24156648 Change-Id: I8c69cfc85156917c0223817fe4409f9b6357f05c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -22,6 +22,7 @@ import androidx.annotation.VisibleForTesting;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.wifitrackerlib.WifiEntry;
|
||||
|
||||
/**
|
||||
@@ -34,7 +35,7 @@ public class LongPressWifiEntryPreference extends WifiEntryPreference {
|
||||
public LongPressWifiEntryPreference(Context context, WifiEntry wifiEntry, Fragment fragment) {
|
||||
super(context, wifiEntry);
|
||||
mFragment = fragment;
|
||||
checkRestrictionAndSetDisabled(UserManager.DISALLOW_ADD_WIFI_CONFIG);
|
||||
checkRestrictionAndSetDisabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,4 +66,22 @@ public class LongPressWifiEntryPreference extends WifiEntryPreference {
|
||||
}
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void checkRestrictionAndSetDisabled() {
|
||||
if (!getWifiEntry().hasAdminRestrictions()) {
|
||||
return;
|
||||
}
|
||||
RestrictedLockUtils.EnforcedAdmin admin = null;
|
||||
Context context = getContext();
|
||||
if (context != null) {
|
||||
admin = RestrictedLockUtils.getProfileOrDeviceOwner(context, context.getUser());
|
||||
}
|
||||
if (admin == null) {
|
||||
// Use UserManager.DISALLOW_ADD_WIFI_CONFIG as default Wi-Fi network restriction.
|
||||
admin = RestrictedLockUtils.EnforcedAdmin.createDefaultEnforcedAdminWithRestriction(
|
||||
UserManager.DISALLOW_ADD_WIFI_CONFIG);
|
||||
}
|
||||
setDisabledByAdmin(admin);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user