Settings: Use new API for setting wifi scan always on
Bug: 148514485 Test: Manually verified the toggle from Settings Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.wifi Change-Id: I0a55b7212c97c11d50b0a05eec743e8ebe9ea6d8
This commit is contained in:
@@ -24,7 +24,6 @@ import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
@@ -80,8 +79,7 @@ public class WifiScanModeActivity extends FragmentActivity {
|
||||
}
|
||||
|
||||
private void doPositiveClick() {
|
||||
Settings.Global.putInt(getContentResolver(),
|
||||
Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 1);
|
||||
getApplicationContext().getSystemService(WifiManager.class).setScanAlwaysAvailable(true);
|
||||
setResult(RESULT_OK);
|
||||
finish();
|
||||
}
|
||||
|
@@ -23,8 +23,8 @@ import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
@@ -69,8 +69,7 @@ public class WifiScanningRequiredFragment extends InstrumentedDialogFragment imp
|
||||
ContentResolver contentResolver = context.getContentResolver();
|
||||
switch(which) {
|
||||
case DialogInterface.BUTTON_POSITIVE:
|
||||
Settings.Global.putInt(contentResolver,
|
||||
Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 1);
|
||||
context.getSystemService(WifiManager.class).setScanAlwaysAvailable(true);
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.wifi_settings_scanning_required_enabled),
|
||||
|
@@ -1048,8 +1048,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
final PowerManager powerManager = context.getSystemService(PowerManager.class);
|
||||
final ContentResolver contentResolver = context.getContentResolver();
|
||||
return mWifiManager.isAutoWakeupEnabled()
|
||||
&& Settings.Global.getInt(contentResolver,
|
||||
Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1
|
||||
&& mWifiManager.isScanAlwaysAvailable()
|
||||
&& Settings.Global.getInt(contentResolver,
|
||||
Settings.Global.AIRPLANE_MODE_ON, 0) == 0
|
||||
&& !powerManager.isPowerSaveMode();
|
||||
@@ -1060,8 +1059,8 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
// Don't use WifiManager.isScanAlwaysAvailable() to check the Wi-Fi scanning mode. Instead,
|
||||
// read the system settings directly. Because when the device is in Airplane mode, even if
|
||||
// Wi-Fi scanning mode is on, WifiManager.isScanAlwaysAvailable() still returns "off".
|
||||
final boolean wifiScanningMode = Settings.Global.getInt(getActivity().getContentResolver(),
|
||||
Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1;
|
||||
// TODO(b/149421497): Fix this?
|
||||
final boolean wifiScanningMode = mWifiManager.isScanAlwaysAvailable();
|
||||
final CharSequence description = wifiScanningMode ? getText(R.string.wifi_scan_notify_text)
|
||||
: getText(R.string.wifi_scan_notify_text_scanning_off);
|
||||
final LinkifyUtils.OnClickListener clickListener =
|
||||
|
@@ -852,8 +852,7 @@ public class WifiSettings2 extends RestrictedSettingsFragment
|
||||
final PowerManager powerManager = context.getSystemService(PowerManager.class);
|
||||
final ContentResolver contentResolver = context.getContentResolver();
|
||||
return mWifiManager.isAutoWakeupEnabled()
|
||||
&& Settings.Global.getInt(contentResolver,
|
||||
Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1
|
||||
&& mWifiManager.isScanAlwaysAvailable()
|
||||
&& Settings.Global.getInt(contentResolver,
|
||||
Settings.Global.AIRPLANE_MODE_ON, 0) == 0
|
||||
&& !powerManager.isPowerSaveMode();
|
||||
@@ -864,8 +863,8 @@ public class WifiSettings2 extends RestrictedSettingsFragment
|
||||
// Don't use WifiManager.isScanAlwaysAvailable() to check the Wi-Fi scanning mode. Instead,
|
||||
// read the system settings directly. Because when the device is in Airplane mode, even if
|
||||
// Wi-Fi scanning mode is on, WifiManager.isScanAlwaysAvailable() still returns "off".
|
||||
final boolean wifiScanningMode = Settings.Global.getInt(getActivity().getContentResolver(),
|
||||
Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1;
|
||||
// TODO(b/149421497): Fix this?
|
||||
final boolean wifiScanningMode = mWifiManager.isScanAlwaysAvailable();
|
||||
final CharSequence description = wifiScanningMode ? getText(R.string.wifi_scan_notify_text)
|
||||
: getText(R.string.wifi_scan_notify_text_scanning_off);
|
||||
final LinkifyUtils.OnClickListener clickListener =
|
||||
|
@@ -153,8 +153,7 @@ public class WifiWakeupPreferenceController extends TogglePreferenceController i
|
||||
}
|
||||
|
||||
private boolean getWifiScanningEnabled() {
|
||||
return Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1;
|
||||
return mWifiManager.isScanAlwaysAvailable();
|
||||
}
|
||||
|
||||
private void showScanningDialog() {
|
||||
|
Reference in New Issue
Block a user