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:
@@ -56,8 +56,6 @@ public class AddAppNetworksActivity extends FragmentActivity {
|
|||||||
final Bundle mBundle = new Bundle();
|
final Bundle mBundle = new Bundle();
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
IActivityManager mActivityManager = ActivityManager.getService();
|
IActivityManager mActivityManager = ActivityManager.getService();
|
||||||
@VisibleForTesting
|
|
||||||
boolean mIsAddWifiConfigAllow;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
@@ -74,8 +72,6 @@ public class AddAppNetworksActivity extends FragmentActivity {
|
|||||||
window.setGravity(Gravity.BOTTOM);
|
window.setGravity(Gravity.BOTTOM);
|
||||||
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT,
|
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT,
|
||||||
WindowManager.LayoutParams.WRAP_CONTENT);
|
WindowManager.LayoutParams.WRAP_CONTENT);
|
||||||
|
|
||||||
mIsAddWifiConfigAllow = WifiEnterpriseRestrictionUtils.isAddWifiConfigAllowed(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -90,7 +86,7 @@ public class AddAppNetworksActivity extends FragmentActivity {
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected boolean showAddNetworksFragment() {
|
protected boolean showAddNetworksFragment() {
|
||||||
if (!mIsAddWifiConfigAllow) {
|
if (!isAddWifiConfigAllow()) {
|
||||||
Log.d(TAG, "Not allowed by Enterprise Restriction");
|
Log.d(TAG, "Not allowed by Enterprise Restriction");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -129,4 +125,9 @@ public class AddAppNetworksActivity extends FragmentActivity {
|
|||||||
}
|
}
|
||||||
return packageName;
|
return packageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
boolean isAddWifiConfigAllow() {
|
||||||
|
return WifiEnterpriseRestrictionUtils.isAddWifiConfigAllowed(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -39,15 +39,14 @@ public class AddAppNetworksActivityTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private IActivityManager mIActivityManager;
|
private IActivityManager mIActivityManager;
|
||||||
|
|
||||||
private AddAppNetworksActivity mActivity;
|
private FakeAddAppNetworksActivity mActivity;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
mActivity = Robolectric.buildActivity(AddAppNetworksActivity.class).create().get();
|
mActivity = Robolectric.buildActivity(FakeAddAppNetworksActivity.class).create().get();
|
||||||
mActivity.mActivityManager = mIActivityManager;
|
mActivity.mActivityManager = mIActivityManager;
|
||||||
mActivity.mIsAddWifiConfigAllow = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -92,4 +91,13 @@ public class AddAppNetworksActivityTest {
|
|||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class FakeAddAppNetworksActivity extends AddAppNetworksActivity {
|
||||||
|
boolean mIsAddWifiConfigAllow = true;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean isAddWifiConfigAllow() {
|
||||||
|
return mIsAddWifiConfigAllow;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user