Merge "Remove Sleep options from Advanced wifi."

This commit is contained in:
Pankaj Kanwar
2017-05-15 20:23:15 +00:00
committed by Android (Google) Code Review
4 changed files with 0 additions and 143 deletions

View File

@@ -326,38 +326,6 @@
<item>Excellent</item>
</string-array>
<!-- Wi-Fi settings. Presented as a list dialog to the user to choose the Wi-Fi sleep policy. -->
<string-array name="wifi_sleep_policy_entries">
<!-- Always keep Wi-Fi on when screen turns off. -->
<item>Always</item>
<!-- Keep Wi-Fi on when screen turns off and plugged in. When on battery, go to sleep when screen turns off. -->
<item>Only when plugged in</item>
<!-- Do not keep Wi-Fi on when screen turns off. [CHAR LIMIT=40] -->
<item>Never</item>
</string-array>
<!-- Wi-Fi settings. Presented as a list dialog to the user to choose the Wi-Fi sleep policy. Used when
the device is Wi-Fi-only. [CHAR LIMIT=30] -->
<string-array name="wifi_sleep_policy_entries_wifi_only">
<!-- Always keep Wi-Fi on when screen turns off. -->
<item>Always</item>
<!-- Keep Wi-Fi on when screen turns off and plugged in. When on battery, go to sleep when screen turns off. -->
<item>Only when plugged in</item>
<!-- Do not keep Wi-Fi on when screen turns off, for Wi-Fi-only devices, no other data connection -->
<item>Never</item>
</string-array>
<!-- Match with wifi_sleep_policy_entries and the values of the settings in Settings class. --> <skip />
<!-- Do not translate. -->
<string-array name="wifi_sleep_policy_values">
<!-- Do not translate. -->
<item>2</item>
<!-- Do not translate. -->
<item>1</item>
<!-- Do not translate. -->
<item>0</item>
</string-array>
<!-- Data Usage settings. Range of data usage. -->
<string-array name="data_usage_data_range">
<!-- Last 30 days [CHAR LIMIT=25]-->

View File

@@ -42,12 +42,6 @@
android:title="@string/wifi_cellular_data_fallback_title"
android:summary="@string/wifi_cellular_data_fallback_summary"/>
<ListPreference
android:key="sleep_policy"
android:title="@string/wifi_setting_sleep_policy_title"
android:entries="@array/wifi_sleep_policy_entries"
android:entryValues="@array/wifi_sleep_policy_values" />
<Preference
android:key="install_credentials"
android:title="@string/wifi_install_credentials">

View File

@@ -82,7 +82,6 @@ public class ConfigureWifiSettings extends DashboardFragment {
networkScoreManagerWrapper));
controllers.add(new NotifyOpenNetworksPreferenceController(context, getLifecycle()));
controllers.add(mUseOpenWifiPreferenceController);
controllers.add(new WifiSleepPolicyPreferenceController(context));
controllers.add(new WifiInfoPreferenceController(context, getLifecycle(), wifiManager));
controllers.add(new CellularFallbackPreferenceController(context));
controllers.add(new WifiP2pPreferenceController(context, getLifecycle(), wifiManager));

View File

@@ -1,104 +0,0 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.wifi;
import android.content.Context;
import android.provider.Settings;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
import android.util.Log;
import android.widget.Toast;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.PreferenceController;
import static com.android.internal.os.MemoryPowerCalculator.TAG;
public class WifiSleepPolicyPreferenceController extends PreferenceController implements
Preference.OnPreferenceChangeListener {
private static final String KEY_SLEEP_POLICY = "sleep_policy";
public WifiSleepPolicyPreferenceController(Context context) {
super(context);
}
@Override
public boolean isAvailable() {
return true;
}
@Override
public String getPreferenceKey() {
return KEY_SLEEP_POLICY;
}
@Override
public void updateState(Preference preference) {
ListPreference sleepPolicyPref = (ListPreference) preference;
if (sleepPolicyPref != null) {
if (Utils.isWifiOnly(mContext)) {
sleepPolicyPref.setEntries(R.array.wifi_sleep_policy_entries_wifi_only);
}
int value = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.WIFI_SLEEP_POLICY,
Settings.Global.WIFI_SLEEP_POLICY_NEVER);
String stringValue = String.valueOf(value);
sleepPolicyPref.setValue(stringValue);
updateSleepPolicySummary(sleepPolicyPref, stringValue);
}
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
try {
String stringValue = (String) newValue;
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.WIFI_SLEEP_POLICY,
Integer.parseInt(stringValue));
updateSleepPolicySummary(preference, stringValue);
} catch (NumberFormatException e) {
Toast.makeText(mContext, R.string.wifi_setting_sleep_policy_error,
Toast.LENGTH_SHORT).show();
return false;
}
return true;
}
private void updateSleepPolicySummary(Preference sleepPolicyPref, String value) {
if (value != null) {
String[] values = mContext.getResources().getStringArray(R.array
.wifi_sleep_policy_values);
final int summaryArrayResId = Utils.isWifiOnly(mContext)
? R.array.wifi_sleep_policy_entries_wifi_only
: R.array.wifi_sleep_policy_entries;
String[] summaries = mContext.getResources().getStringArray(summaryArrayResId);
for (int i = 0; i < values.length; i++) {
if (value.equals(values[i])) {
if (i < summaries.length) {
sleepPolicyPref.setSummary(summaries[i]);
return;
}
}
}
}
sleepPolicyPref.setSummary("");
Log.e(TAG, "Invalid sleep policy value: " + value);
}
}