Remove Wi-Fi hotspot from settings search for non-admin users
- Don't use ViewModel if the settings UI is restricted Bug: 284931681 Test: manual test atest -c WifiTetherSettingsTest Change-Id: I3ae23b01b3be821c3560552b39cbd83ab51b2095
This commit is contained in:
@@ -91,7 +91,8 @@ public class WifiTetherSettings extends RestrictedDashboardFragment
|
||||
@VisibleForTesting
|
||||
WifiTetherAutoOffPreferenceController mWifiTetherAutoOffPreferenceController;
|
||||
|
||||
private boolean mUnavailable;
|
||||
@VisibleForTesting
|
||||
boolean mUnavailable;
|
||||
private WifiRestriction mWifiRestriction;
|
||||
@VisibleForTesting
|
||||
TetherChangeReceiver mTetherChangeReceiver;
|
||||
@@ -139,6 +140,9 @@ public class WifiTetherSettings extends RestrictedDashboardFragment
|
||||
|
||||
setIfOnlyAvailableForAdmins(true);
|
||||
mUnavailable = isUiRestricted() || !mWifiRestriction.isHotspotAvailable(getContext());
|
||||
if (mUnavailable) {
|
||||
return;
|
||||
}
|
||||
|
||||
mWifiTetherViewModel = FeatureFactory.getFactory(getContext()).getWifiFeatureProvider()
|
||||
.getWifiTetherViewModel(this);
|
||||
@@ -342,7 +346,16 @@ public class WifiTetherSettings extends RestrictedDashboardFragment
|
||||
|
||||
@Override
|
||||
protected boolean isPageSearchEnabled(Context context) {
|
||||
if (context == null || !WifiUtils.canShowWifiHotspot(context)) return false;
|
||||
if (context == null) {
|
||||
return false;
|
||||
}
|
||||
UserManager userManager = context.getSystemService(UserManager.class);
|
||||
if (userManager == null || !userManager.isAdminUser()) {
|
||||
return false;
|
||||
}
|
||||
if (!WifiUtils.canShowWifiHotspot(context)) {
|
||||
return false;
|
||||
}
|
||||
return !FeatureFlagUtils.isEnabled(context, FeatureFlags.TETHER_ALL_IN_ONE);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user