Merge "Make auto Wi-Fi summary text consistent with feature availability." into oc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
194638ac78
@@ -78,7 +78,7 @@ public class ConfigureWifiSettings extends DashboardFragment {
|
||||
final NetworkScoreManagerWrapper networkScoreManagerWrapper =
|
||||
new NetworkScoreManagerWrapper(context.getSystemService(NetworkScoreManager.class));
|
||||
mWifiWakeupPreferenceController = new WifiWakeupPreferenceController(
|
||||
context, getLifecycle(), networkScoreManagerWrapper);
|
||||
context, getLifecycle());
|
||||
mUseOpenWifiPreferenceController = new UseOpenWifiPreferenceController(context, this,
|
||||
networkScoreManagerWrapper, getLifecycle());
|
||||
final WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
|
||||
|
@@ -38,6 +38,7 @@ import android.net.wifi.WpsInfo;
|
||||
import android.nfc.NfcAdapter;
|
||||
import android.os.Bundle;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.PowerManager;
|
||||
import android.os.Process;
|
||||
import android.provider.Settings;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
@@ -920,9 +921,8 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
getContentResolver(), Settings.Global.WIFI_WAKEUP_AVAILABLE, defaultWakeupAvailable)
|
||||
== 1;
|
||||
if (wifiWakeupAvailable) {
|
||||
boolean wifiWakeupEnabled = Settings.Global.getInt(
|
||||
getContentResolver(), Settings.Global.WIFI_WAKEUP_ENABLED, 0) == 1;
|
||||
mConfigureWifiSettingsPreference.setSummary(getString(wifiWakeupEnabled
|
||||
mConfigureWifiSettingsPreference.setSummary(getString(
|
||||
isWifiWakeupEnabled()
|
||||
? R.string.wifi_configure_settings_preference_summary_wakeup_on
|
||||
: R.string.wifi_configure_settings_preference_summary_wakeup_off));
|
||||
}
|
||||
@@ -937,6 +937,20 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isWifiWakeupEnabled() {
|
||||
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
ContentResolver contentResolver = getContentResolver();
|
||||
return Settings.Global.getInt(contentResolver,
|
||||
Settings.Global.WIFI_WAKEUP_ENABLED, 0) == 1
|
||||
&& Settings.Global.getInt(contentResolver,
|
||||
Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1
|
||||
&& Settings.Global.getInt(contentResolver,
|
||||
Settings.Global.AIRPLANE_MODE_ON, 0) == 0
|
||||
&& Settings.Global.getInt(contentResolver,
|
||||
Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED, 0) == 1
|
||||
&& !powerManager.isPowerSaveMode();
|
||||
}
|
||||
|
||||
private void setOffMessage() {
|
||||
final CharSequence title = getText(R.string.wifi_empty_list_wifi_off);
|
||||
// Don't use WifiManager.isScanAlwaysAvailable() to check the Wi-Fi scanning mode. Instead,
|
||||
|
@@ -44,13 +44,10 @@ public class WifiWakeupPreferenceController extends AbstractPreferenceController
|
||||
implements PreferenceControllerMixin, LifecycleObserver, OnResume, OnPause {
|
||||
|
||||
private static final String KEY_ENABLE_WIFI_WAKEUP = "enable_wifi_wakeup";
|
||||
private final NetworkScoreManagerWrapper mNetworkScoreManager;
|
||||
private SettingObserver mSettingObserver;
|
||||
|
||||
public WifiWakeupPreferenceController(
|
||||
Context context, Lifecycle lifecycle, NetworkScoreManagerWrapper networkScoreManager) {
|
||||
public WifiWakeupPreferenceController(Context context, Lifecycle lifecycle) {
|
||||
super(context);
|
||||
mNetworkScoreManager = networkScoreManager;
|
||||
lifecycle.addObserver(this);
|
||||
}
|
||||
|
||||
@@ -116,11 +113,9 @@ public class WifiWakeupPreferenceController extends AbstractPreferenceController
|
||||
boolean networkRecommendationsEnabled = Settings.Global.getInt(
|
||||
mContext.getContentResolver(),
|
||||
Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED, 0) == 1;
|
||||
boolean activeScorerSet = mNetworkScoreManager.getActiveScorerPackage() != null;
|
||||
enableWifiWakeup.setEnabled(
|
||||
networkRecommendationsEnabled && wifiScanningEnabled && activeScorerSet);
|
||||
enableWifiWakeup.setEnabled(networkRecommendationsEnabled && wifiScanningEnabled);
|
||||
|
||||
if (!activeScorerSet) {
|
||||
if (!networkRecommendationsEnabled) {
|
||||
enableWifiWakeup.setSummary(R.string.wifi_wakeup_summary_scoring_disabled);
|
||||
} else if (!wifiScanningEnabled) {
|
||||
enableWifiWakeup.setSummary(R.string.wifi_wakeup_summary_scanning_disabled);
|
||||
|
Reference in New Issue
Block a user