Add more policy transparency for wifi settings.
Show policy transparency dialog if user tries to modify a wifi configuration locked by device owner. Bug: 27375948 Change-Id: I504082282f57bc5de9f097e962d195ecd2cc9da4
This commit is contained in:
@@ -1489,9 +1489,6 @@
|
||||
<!-- Link speed on Wifi Status screen -->
|
||||
<string name="link_speed">%1$d Mbps</string>
|
||||
|
||||
<!-- Wifi Alert message when tapping on a preference for a config locked down by device owner. [CHAR LIMIT=200] -->
|
||||
<string name="wifi_alert_lockdown_by_device_owner"><xliff:g id="app_name">%1$s</xliff:g> manages your device and doesn\u2019t allow modifying or deleting this Wi-Fi network. For more information, contact your administrator.</string>
|
||||
|
||||
<!-- NFC settings -->
|
||||
<!-- Used in the 1st-level settings screen to turn on NFC -->
|
||||
<string name="nfc_quick_toggle_title">NFC</string>
|
||||
|
@@ -143,12 +143,8 @@ public class SavedAccessPointsWifiSettings extends SettingsPreferenceFragment
|
||||
}
|
||||
mSelectedAccessPoint = mDlgAccessPoint;
|
||||
|
||||
// Hide forget button if config editing is locked down
|
||||
final boolean hideForgetButton = WifiSettings.isEditabilityLockedDown(getActivity(),
|
||||
mDlgAccessPoint.getConfig());
|
||||
mDialog = new WifiDialog(getActivity(), this, mDlgAccessPoint,
|
||||
WifiConfigUiBase.MODE_VIEW, true /* hide the submit button */,
|
||||
hideForgetButton);
|
||||
WifiConfigUiBase.MODE_VIEW, true /* hide the submit button */);
|
||||
return mDialog;
|
||||
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.wifi.AccessPoint;
|
||||
|
||||
class WifiDialog extends AlertDialog implements WifiConfigUiBase, DialogInterface.OnClickListener {
|
||||
@@ -43,13 +44,11 @@ class WifiDialog extends AlertDialog implements WifiConfigUiBase, DialogInterfac
|
||||
private View mView;
|
||||
private WifiConfigController mController;
|
||||
private boolean mHideSubmitButton;
|
||||
private boolean mHideForgetButton;
|
||||
|
||||
public WifiDialog(Context context, WifiDialogListener listener, AccessPoint accessPoint,
|
||||
int mode, boolean hideSubmitButton, boolean hideForgetButton) {
|
||||
int mode, boolean hideSubmitButton) {
|
||||
this(context, listener, accessPoint, mode);
|
||||
mHideSubmitButton = hideSubmitButton;
|
||||
mHideForgetButton = hideForgetButton;
|
||||
}
|
||||
|
||||
public WifiDialog(Context context, WifiDialogListener listener, AccessPoint accessPoint,
|
||||
@@ -59,7 +58,6 @@ class WifiDialog extends AlertDialog implements WifiConfigUiBase, DialogInterfac
|
||||
mListener = listener;
|
||||
mAccessPoint = accessPoint;
|
||||
mHideSubmitButton = false;
|
||||
mHideForgetButton = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,7 +81,7 @@ class WifiDialog extends AlertDialog implements WifiConfigUiBase, DialogInterfac
|
||||
mController.enableSubmitIfAppropriate();
|
||||
}
|
||||
|
||||
if (mHideForgetButton) {
|
||||
if (mAccessPoint == null) {
|
||||
mController.hideForgetButton();
|
||||
}
|
||||
}
|
||||
@@ -109,6 +107,12 @@ class WifiDialog extends AlertDialog implements WifiConfigUiBase, DialogInterfac
|
||||
mListener.onSubmit(this);
|
||||
break;
|
||||
case BUTTON_FORGET:
|
||||
if (WifiSettings.isEditabilityLockedDown(
|
||||
getContext(), mAccessPoint.getConfig())) {
|
||||
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(),
|
||||
RestrictedLockUtils.getDeviceOwner(getContext()));
|
||||
return;
|
||||
}
|
||||
mListener.onForget(this);
|
||||
break;
|
||||
}
|
||||
|
@@ -17,8 +17,6 @@
|
||||
package com.android.settings.wifi;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AppGlobals;
|
||||
import android.app.Dialog;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
@@ -27,8 +25,6 @@ import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.IPackageManager;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.res.Resources;
|
||||
@@ -74,6 +70,7 @@ import com.android.settings.location.ScanningSettings;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.search.SearchIndexableRaw;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.wifi.AccessPoint;
|
||||
import com.android.settingslib.wifi.AccessPoint.AccessPointListener;
|
||||
import com.android.settingslib.wifi.AccessPointPreference;
|
||||
@@ -541,26 +538,8 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
if (accessPoint != null) {
|
||||
WifiConfiguration config = accessPoint.getConfig();
|
||||
if (isEditabilityLockedDown(getActivity(), config) && accessPoint.isActive()) {
|
||||
final int userId = UserHandle.getUserId(config.creatorUid);
|
||||
final PackageManager pm = getActivity().getPackageManager();
|
||||
final IPackageManager ipm = AppGlobals.getPackageManager();
|
||||
String appName = pm.getNameForUid(config.creatorUid);
|
||||
try {
|
||||
final ApplicationInfo appInfo = ipm.getApplicationInfo(appName, /* flags */ 0,
|
||||
userId);
|
||||
final CharSequence label = pm.getApplicationLabel(appInfo);
|
||||
if (label != null) {
|
||||
appName = label.toString();
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
// leave appName as packageName
|
||||
}
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setTitle(accessPoint.getSsid())
|
||||
.setMessage(getString(R.string.wifi_alert_lockdown_by_device_owner,
|
||||
appName))
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.show();
|
||||
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getActivity(),
|
||||
RestrictedLockUtils.getDeviceOwner(getActivity()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -593,11 +572,8 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
}
|
||||
// If it's null, fine, it's for Add Network
|
||||
mSelectedAccessPoint = ap;
|
||||
final boolean hideForget = (ap == null || isEditabilityLockedDown(getActivity(),
|
||||
ap.getConfig()));
|
||||
mDialog = new WifiDialog(getActivity(), this, ap, mDialogMode,
|
||||
/* no hide submit/connect */ false,
|
||||
/* hide forget if config locked down */ hideForget);
|
||||
/* no hide submit/connect */ false);
|
||||
return mDialog;
|
||||
case WPS_PBC_DIALOG_ID:
|
||||
return new WpsDialog(getActivity(), WpsInfo.PBC);
|
||||
|
Reference in New Issue
Block a user