Fix adding wifi configuration issue

- The Wi-Fi Enterprise Restrictions add a new
  UserManager.DISALLOW_ADD_WIFI_CONFIG restriction from T.

- When a user requests to add Wi-Fi configuration, Settings will
  reject the request if the user is not allowed.

- The above restriction need to be retrieved in advance so that the
  user's request will not be rejected.

- See the result screenshot in b/224459753#comment8

Bug: 224459753
Test: manual test
make RunSettingsRoboTests ROBOTEST_FILTER=AddAppNetworksActivity

Change-Id: I2dfb6b9946dd9dbd4eb8bf0f6549ac5cb4466f17
This commit is contained in:
Weng Su
2022-03-23 06:16:59 +08:00
parent b39ab3e1c4
commit f5cd7140f4
2 changed files with 17 additions and 8 deletions

View File

@@ -56,8 +56,6 @@ public class AddAppNetworksActivity extends FragmentActivity {
final Bundle mBundle = new Bundle();
@VisibleForTesting
IActivityManager mActivityManager = ActivityManager.getService();
@VisibleForTesting
boolean mIsAddWifiConfigAllow;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -74,8 +72,6 @@ public class AddAppNetworksActivity extends FragmentActivity {
window.setGravity(Gravity.BOTTOM);
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT);
mIsAddWifiConfigAllow = WifiEnterpriseRestrictionUtils.isAddWifiConfigAllowed(this);
}
@Override
@@ -90,7 +86,7 @@ public class AddAppNetworksActivity extends FragmentActivity {
@VisibleForTesting
protected boolean showAddNetworksFragment() {
if (!mIsAddWifiConfigAllow) {
if (!isAddWifiConfigAllow()) {
Log.d(TAG, "Not allowed by Enterprise Restriction");
return false;
}
@@ -129,4 +125,9 @@ public class AddAppNetworksActivity extends FragmentActivity {
}
return packageName;
}
@VisibleForTesting
boolean isAddWifiConfigAllow() {
return WifiEnterpriseRestrictionUtils.isAddWifiConfigAllowed(this);
}
}