Merge "Add config for Wi-Fi Hotspot Settings hidden" into tm-qpr-dev am: 87d2f6d3cb
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/20244146 Change-Id: I7b3275ffad2af79bb81c3761b691ab793a61168a Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -16,9 +16,10 @@
|
||||
|
||||
package com.android.settings.wifi.tether;
|
||||
|
||||
import static com.android.settings.wifi.WifiUtils.canShowWifiHotspot;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.net.TetheringManager;
|
||||
import android.net.wifi.SoftApConfiguration;
|
||||
import android.net.wifi.WifiClient;
|
||||
import android.net.wifi.WifiManager;
|
||||
@@ -46,7 +47,6 @@ public class WifiTetherPreferenceController extends AbstractPreferenceController
|
||||
|
||||
private static final String WIFI_TETHER_SETTINGS = "wifi_tether";
|
||||
|
||||
private boolean mIsWifiTetherable;
|
||||
private WifiManager mWifiManager;
|
||||
private boolean mIsWifiTetheringAllow;
|
||||
private int mSoftApState;
|
||||
@@ -57,8 +57,7 @@ public class WifiTetherPreferenceController extends AbstractPreferenceController
|
||||
|
||||
public WifiTetherPreferenceController(Context context, Lifecycle lifecycle) {
|
||||
this(context, lifecycle,
|
||||
context.getSystemService(WifiManager.class),
|
||||
context.getSystemService(TetheringManager.class),
|
||||
context.getApplicationContext().getSystemService(WifiManager.class),
|
||||
true /* initSoftApManager */,
|
||||
WifiEnterpriseRestrictionUtils.isWifiTetheringAllowed(context));
|
||||
}
|
||||
@@ -68,15 +67,9 @@ public class WifiTetherPreferenceController extends AbstractPreferenceController
|
||||
Context context,
|
||||
Lifecycle lifecycle,
|
||||
WifiManager wifiManager,
|
||||
TetheringManager tetheringManager,
|
||||
boolean initSoftApManager,
|
||||
boolean isWifiTetheringAllow) {
|
||||
super(context);
|
||||
final String[] wifiRegexs = tetheringManager.getTetherableWifiRegexs();
|
||||
if (wifiRegexs != null && wifiRegexs.length != 0) {
|
||||
mIsWifiTetherable = true;
|
||||
}
|
||||
|
||||
mIsWifiTetheringAllow = isWifiTetheringAllow;
|
||||
if (!isWifiTetheringAllow) return;
|
||||
|
||||
@@ -92,7 +85,7 @@ public class WifiTetherPreferenceController extends AbstractPreferenceController
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return mIsWifiTetherable && !Utils.isMonkeyRunning();
|
||||
return canShowWifiHotspot(mContext) && !Utils.isMonkeyRunning();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -18,6 +18,8 @@ package com.android.settings.wifi.tether;
|
||||
|
||||
import static android.net.wifi.WifiManager.WIFI_AP_STATE_CHANGED_ACTION;
|
||||
|
||||
import static com.android.settings.wifi.WifiUtils.canShowWifiHotspot;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
@@ -108,6 +110,13 @@ public class WifiTetherSettings extends RestrictedDashboardFragment
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
if (!canShowWifiHotspot(getContext())) {
|
||||
Log.e(TAG, "can not launch Wi-Fi hotspot settings"
|
||||
+ " because the config is not set to show.");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
setIfOnlyAvailableForAdmins(true);
|
||||
mUnavailable = isUiRestricted() || !mWifiRestriction.isHotspotAvailable(getContext());
|
||||
}
|
||||
|
Reference in New Issue
Block a user