Remove Modify popup menu for non-admin
- Don't add the Modify ContextMenu if the user is not an admin. Bug: 237672190 Test: manual test make RunSettingsRoboTests ROBOTEST_FILTER=NetworkProviderSettingsTest Change-Id: I62e0f5559fa2315450221fcb71e348af59af9549
This commit is contained in:
@@ -34,6 +34,7 @@ import android.net.wifi.WifiManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.PowerManager;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.TelephonyManager;
|
||||
@@ -598,10 +599,7 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
|
||||
return;
|
||||
}
|
||||
|
||||
if (mSelectedWifiEntry.isSaved() && mSelectedWifiEntry.getConnectedState()
|
||||
!= WifiEntry.CONNECTED_STATE_CONNECTED) {
|
||||
menu.add(Menu.NONE, MENU_ID_MODIFY, 0 /* order */, R.string.wifi_modify);
|
||||
}
|
||||
addModifyMenuIfSuitable(menu, mSelectedWifiEntry);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -621,6 +619,14 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void addModifyMenuIfSuitable(ContextMenu menu, WifiEntry wifiEntry) {
|
||||
if (mIsAdmin && wifiEntry.isSaved()
|
||||
&& wifiEntry.getConnectedState() != WifiEntry.CONNECTED_STATE_CONNECTED) {
|
||||
menu.add(Menu.NONE, MENU_ID_MODIFY, 0 /* order */, R.string.wifi_modify);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canForgetNetwork() {
|
||||
return mSelectedWifiEntry.canForget() && !WifiUtils.isNetworkLockedDown(getActivity(),
|
||||
mSelectedWifiEntry.getWifiConfiguration());
|
||||
@@ -643,6 +649,12 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
|
||||
() -> launchWifiDppConfiguratorActivity(mSelectedWifiEntry));
|
||||
return true;
|
||||
case MENU_ID_MODIFY:
|
||||
if (!mIsAdmin) {
|
||||
Log.e(TAG, "Can't modify Wi-Fi because the user isn't admin.");
|
||||
EventLog.writeEvent(0x534e4554, "237672190", UserHandle.myUserId(),
|
||||
"User isn't admin");
|
||||
return true;
|
||||
}
|
||||
showDialog(mSelectedWifiEntry, WifiConfigUiBase2.MODE_MODIFY);
|
||||
return true;
|
||||
default:
|
||||
|
Reference in New Issue
Block a user