Added WiFi Assistant settings.
+ Added ability to setup Wifi Assistant. - Removed 'Avoid poor connections' from WiFi Advance Settings. - Removed 'Optimize Wi-Fi' from WiFi Advance Settings. + Replaced checkboxes with switches in WifFI Advance Settings. + Added horizontal rule to seperate MAC/IP address text. Bug: 15698824 Change-Id: Ia319ff5fb2566854666a07d0e77c8816a49fd3d6
This commit is contained in:
79
res/layout/mac_preference.xml
Normal file
79
res/layout/mac_preference.xml
Normal file
@@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2014 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.
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical"
|
||||
android:background="?android:attr/selectableItemBackground">
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="@dimen/wifi_divider_height"
|
||||
android:background="@color/wifi_divider" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:gravity="center_vertical"
|
||||
android:background="?android:attr/selectableItemBackground">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingTop="6dip"
|
||||
android:paddingBottom="6dip">
|
||||
|
||||
<TextView
|
||||
android:id="@+android:id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingStart="16dip"
|
||||
android:paddingEnd="16dip"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:ellipsize="marquee"
|
||||
android:fadingEdge="horizontal" />
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/summary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@android:id/title"
|
||||
android:layout_alignStart="@android:id/title"
|
||||
android:paddingStart="16dip"
|
||||
android:layout_marginEnd="16dip"
|
||||
android:visibility="gone"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:maxLines="4" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@android:id/widget_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@@ -85,4 +85,6 @@
|
||||
<!-- Avatar color used for guest -->
|
||||
<color name="grey_500">@*android:color/material_grey_500</color>
|
||||
|
||||
<color name="wifi_divider">#ffe0e0e0</color>
|
||||
|
||||
</resources>
|
||||
|
@@ -217,4 +217,6 @@
|
||||
<dimen name="bluetooth_dialog_padding">8dip</dimen>
|
||||
<integer name="bluetooth_name_length">32</integer>
|
||||
|
||||
<dimen name="wifi_divider_height">1px</dimen>
|
||||
|
||||
</resources>
|
||||
|
@@ -1486,7 +1486,7 @@
|
||||
<!-- Checkbox title for option to Automatically manage Wi\u2011Fi [CHAR LIMIT=40] -->
|
||||
<string name="wifi_automatically_manage_title">Automatically manage Wi\u2011Fi</string>
|
||||
<!-- Checkbox summary for option to Automatically manage Wi\u2011Fi [CHAR LIMIT=100] -->
|
||||
<string name="wifi_automatically_manage_summary">Let a Wi\u2011Fi assistant manage your Wi\u2011Fi connection</string>
|
||||
<string name="wifi_automatically_manage_summary">Let <xliff:g id="wifi_assistant">%1$s</xliff:g> manage your Wi\u2011Fi connection</string>
|
||||
<!-- Checkbox title for option for Wi\u2011Fi Assistant [CHAR LIMIT=40] -->
|
||||
<string name="wifi_assistant_setting_title">Wi\u2011Fi assistant</string>
|
||||
<!-- Checkbox summary for option for Wi\u2011Fi Assistant [CHAR LIMIT=40] -->
|
||||
|
@@ -18,31 +18,30 @@
|
||||
android:title="@string/wifi_advanced_titlebar">
|
||||
|
||||
<!-- android:dependency="enable_wifi" -->
|
||||
<CheckBoxPreference
|
||||
<SwitchPreference
|
||||
android:key="notify_open_networks"
|
||||
android:title="@string/wifi_notify_open_networks"
|
||||
android:summary="@string/wifi_notify_open_networks_summary"
|
||||
android:persistent="false" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="wifi_scan_always_available"
|
||||
android:title="@string/wifi_scan_always_available"
|
||||
android:summary="@string/wifi_scan_always_available_summary"
|
||||
android:persistent="false" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="wifi_assistant"
|
||||
android:title="@string/wifi_automatically_manage_title"
|
||||
android:summary="@string/wifi_assistant_setting_summary"
|
||||
android:persistent="false" />
|
||||
|
||||
<ListPreference
|
||||
android:key="sleep_policy"
|
||||
android:title="@string/wifi_setting_sleep_policy_title"
|
||||
android:persistent="false"
|
||||
android:entries="@array/wifi_sleep_policy_entries"
|
||||
android:entryValues="@array/wifi_sleep_policy_values"
|
||||
/>
|
||||
<CheckBoxPreference
|
||||
android:key="wifi_scan_always_available"
|
||||
android:title="@string/wifi_scan_always_available"
|
||||
android:summary="@string/wifi_scan_always_available_summary"
|
||||
android:persistent="false" />
|
||||
|
||||
<!-- android:dependency="enable_wifi" -->
|
||||
<CheckBoxPreference
|
||||
android:key="wifi_poor_network_detection"
|
||||
android:title="@string/wifi_poor_network_detection"
|
||||
android:summary="@string/wifi_poor_network_detection_summary"
|
||||
android:persistent="false" />
|
||||
android:entryValues="@array/wifi_sleep_policy_values" />
|
||||
|
||||
<ListPreference
|
||||
android:key="frequency_band"
|
||||
@@ -50,8 +49,7 @@
|
||||
android:summary="@string/wifi_setting_frequency_band_summary"
|
||||
android:persistent="false"
|
||||
android:entries="@array/wifi_frequency_band_entries"
|
||||
android:entryValues="@array/wifi_frequency_band_values"
|
||||
/>
|
||||
android:entryValues="@array/wifi_frequency_band_values" />
|
||||
|
||||
<Preference
|
||||
android:key="install_credentials"
|
||||
@@ -73,16 +71,10 @@
|
||||
android:title="@string/wifi_menu_wps_pin"
|
||||
android:persistent="false" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="suspend_optimizations"
|
||||
android:title="@string/wifi_suspend_optimizations"
|
||||
android:summary="@string/wifi_suspend_optimizations_summary"
|
||||
android:persistent="false" />
|
||||
|
||||
<Preference
|
||||
android:key="mac_address"
|
||||
android:title="@string/wifi_advanced_mac_address_title"
|
||||
android:layout="@layout/wifi_advance_layout" />
|
||||
android:layout="@layout/mac_preference" />
|
||||
|
||||
<Preference
|
||||
android:key="current_ip_address"
|
||||
|
@@ -20,6 +20,9 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.NetworkScoreManager;
|
||||
import android.net.NetworkScorerAppManager;
|
||||
import android.net.NetworkScorerAppManager.NetworkScorerAppData;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.net.wifi.WpsInfo;
|
||||
@@ -29,6 +32,7 @@ import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.Preference.OnPreferenceClickListener;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.preference.SwitchPreference;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Settings.Global;
|
||||
import android.security.Credentials;
|
||||
@@ -40,6 +44,8 @@ import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.Utils;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class AdvancedWifiSettings extends SettingsPreferenceFragment
|
||||
implements Preference.OnPreferenceChangeListener {
|
||||
|
||||
@@ -49,13 +55,12 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
|
||||
private static final String KEY_FREQUENCY_BAND = "frequency_band";
|
||||
private static final String KEY_NOTIFY_OPEN_NETWORKS = "notify_open_networks";
|
||||
private static final String KEY_SLEEP_POLICY = "sleep_policy";
|
||||
private static final String KEY_POOR_NETWORK_DETECTION = "wifi_poor_network_detection";
|
||||
private static final String KEY_SCAN_ALWAYS_AVAILABLE = "wifi_scan_always_available";
|
||||
private static final String KEY_INSTALL_CREDENTIALS = "install_credentials";
|
||||
private static final String KEY_WIFI_ASSISTANT = "wifi_assistant";
|
||||
private static final String KEY_WIFI_DIRECT = "wifi_direct";
|
||||
private static final String KEY_WPS_PUSH = "wps_push_button";
|
||||
private static final String KEY_WPS_PIN = "wps_pin_entry";
|
||||
private static final String KEY_SUSPEND_OPTIMIZATIONS = "suspend_optimizations";
|
||||
|
||||
private WifiManager mWifiManager;
|
||||
|
||||
@@ -102,27 +107,14 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
|
||||
}
|
||||
|
||||
private void initPreferences() {
|
||||
CheckBoxPreference notifyOpenNetworks =
|
||||
(CheckBoxPreference) findPreference(KEY_NOTIFY_OPEN_NETWORKS);
|
||||
SwitchPreference notifyOpenNetworks =
|
||||
(SwitchPreference) findPreference(KEY_NOTIFY_OPEN_NETWORKS);
|
||||
notifyOpenNetworks.setChecked(Settings.Global.getInt(getContentResolver(),
|
||||
Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0) == 1);
|
||||
notifyOpenNetworks.setEnabled(mWifiManager.isWifiEnabled());
|
||||
|
||||
CheckBoxPreference poorNetworkDetection =
|
||||
(CheckBoxPreference) findPreference(KEY_POOR_NETWORK_DETECTION);
|
||||
if (poorNetworkDetection != null) {
|
||||
if (Utils.isWifiOnly(getActivity())) {
|
||||
getPreferenceScreen().removePreference(poorNetworkDetection);
|
||||
} else {
|
||||
poorNetworkDetection.setChecked(Global.getInt(getContentResolver(),
|
||||
Global.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED,
|
||||
WifiManager.DEFAULT_POOR_NETWORK_AVOIDANCE_ENABLED ?
|
||||
1 : 0) == 1);
|
||||
}
|
||||
}
|
||||
|
||||
CheckBoxPreference scanAlwaysAvailable =
|
||||
(CheckBoxPreference) findPreference(KEY_SCAN_ALWAYS_AVAILABLE);
|
||||
SwitchPreference scanAlwaysAvailable =
|
||||
(SwitchPreference) findPreference(KEY_SCAN_ALWAYS_AVAILABLE);
|
||||
scanAlwaysAvailable.setChecked(Global.getInt(getContentResolver(),
|
||||
Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1);
|
||||
|
||||
@@ -133,7 +125,20 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
|
||||
Preference pref = findPreference(KEY_INSTALL_CREDENTIALS);
|
||||
pref.setIntent(intent);
|
||||
|
||||
Intent wifiDirectIntent = new Intent(getActivity(),
|
||||
final Context context = getActivity();
|
||||
NetworkScorerAppData scorer = WifiSettings.getWifiAssistantApp(context);
|
||||
SwitchPreference wifiAssistant = (SwitchPreference)findPreference(KEY_WIFI_ASSISTANT);
|
||||
if (scorer != null) {
|
||||
final boolean checked = NetworkScorerAppManager.getActiveScorer(context) != null;
|
||||
wifiAssistant.setSummary(getResources().getString(
|
||||
R.string.wifi_automatically_manage_summary, scorer.mScorerName));
|
||||
wifiAssistant.setOnPreferenceChangeListener(this);
|
||||
wifiAssistant.setChecked(checked);
|
||||
} else {
|
||||
getPreferenceScreen().removePreference(wifiAssistant);
|
||||
}
|
||||
|
||||
Intent wifiDirectIntent = new Intent(context,
|
||||
com.android.settings.Settings.WifiP2pSettingsActivity.class);
|
||||
Preference wifiDirectPref = findPreference(KEY_WIFI_DIRECT);
|
||||
wifiDirectPref.setIntent(wifiDirectIntent);
|
||||
@@ -142,7 +147,7 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
|
||||
Preference wpsPushPref = findPreference(KEY_WPS_PUSH);
|
||||
wpsPushPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference arg0) {
|
||||
WpsDialog wpsDialog = new WpsDialog(getActivity(), WpsInfo.PBC);
|
||||
WpsDialog wpsDialog = new WpsDialog(context, WpsInfo.PBC);
|
||||
wpsDialog.show();
|
||||
return true;
|
||||
}
|
||||
@@ -152,17 +157,12 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
|
||||
Preference wpsPinPref = findPreference(KEY_WPS_PIN);
|
||||
wpsPinPref.setOnPreferenceClickListener(new OnPreferenceClickListener(){
|
||||
public boolean onPreferenceClick(Preference arg0) {
|
||||
WpsDialog wpsDialog = new WpsDialog(getActivity(), WpsInfo.DISPLAY);
|
||||
WpsDialog wpsDialog = new WpsDialog(context, WpsInfo.DISPLAY);
|
||||
wpsDialog.show();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
CheckBoxPreference suspendOptimizations =
|
||||
(CheckBoxPreference) findPreference(KEY_SUSPEND_OPTIMIZATIONS);
|
||||
suspendOptimizations.setChecked(Global.getInt(getContentResolver(),
|
||||
Global.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED, 1) == 1);
|
||||
|
||||
ListPreference frequencyPref = (ListPreference) findPreference(KEY_FREQUENCY_BAND);
|
||||
|
||||
if (mWifiManager.isDualBandSupported()) {
|
||||
@@ -183,7 +183,7 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
|
||||
|
||||
ListPreference sleepPolicyPref = (ListPreference) findPreference(KEY_SLEEP_POLICY);
|
||||
if (sleepPolicyPref != null) {
|
||||
if (Utils.isWifiOnly(getActivity())) {
|
||||
if (Utils.isWifiOnly(context)) {
|
||||
sleepPolicyPref.setEntries(R.array.wifi_sleep_policy_entries_wifi_only);
|
||||
}
|
||||
sleepPolicyPref.setOnPreferenceChangeListener(this);
|
||||
@@ -228,19 +228,11 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
|
||||
if (KEY_NOTIFY_OPEN_NETWORKS.equals(key)) {
|
||||
Global.putInt(getContentResolver(),
|
||||
Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
|
||||
((CheckBoxPreference) preference).isChecked() ? 1 : 0);
|
||||
} else if (KEY_POOR_NETWORK_DETECTION.equals(key)) {
|
||||
Global.putInt(getContentResolver(),
|
||||
Global.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED,
|
||||
((CheckBoxPreference) preference).isChecked() ? 1 : 0);
|
||||
} else if (KEY_SUSPEND_OPTIMIZATIONS.equals(key)) {
|
||||
Global.putInt(getContentResolver(),
|
||||
Global.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED,
|
||||
((CheckBoxPreference) preference).isChecked() ? 1 : 0);
|
||||
((SwitchPreference) preference).isChecked() ? 1 : 0);
|
||||
} else if (KEY_SCAN_ALWAYS_AVAILABLE.equals(key)) {
|
||||
Global.putInt(getContentResolver(),
|
||||
Global.WIFI_SCAN_ALWAYS_AVAILABLE,
|
||||
((CheckBoxPreference) preference).isChecked() ? 1 : 0);
|
||||
((SwitchPreference) preference).isChecked() ? 1 : 0);
|
||||
} else {
|
||||
return super.onPreferenceTreeClick(screen, preference);
|
||||
}
|
||||
@@ -249,6 +241,7 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
final Context context = getActivity();
|
||||
String key = preference.getKey();
|
||||
|
||||
if (KEY_FREQUENCY_BAND.equals(key)) {
|
||||
@@ -257,10 +250,32 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
|
||||
mWifiManager.setFrequencyBand(value, true);
|
||||
updateFrequencyBandSummary(preference, value);
|
||||
} catch (NumberFormatException e) {
|
||||
Toast.makeText(getActivity(), R.string.wifi_setting_frequency_band_error,
|
||||
Toast.makeText(context, R.string.wifi_setting_frequency_band_error,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
} else if (KEY_WIFI_ASSISTANT.equals(key)) {
|
||||
if (((Boolean)newValue).booleanValue() == false) {
|
||||
NetworkScorerAppManager.setActiveScorer(context, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
NetworkScorerAppData wifiAssistant = WifiSettings.getWifiAssistantApp(context);
|
||||
Intent intent = new Intent();
|
||||
if (wifiAssistant.mConfigurationActivityClassName != null) {
|
||||
// App has a custom configuration activity; launch that.
|
||||
// This custom activity will be responsible for launching the system
|
||||
// dialog.
|
||||
intent.setClassName(wifiAssistant.mPackageName,
|
||||
wifiAssistant.mConfigurationActivityClassName);
|
||||
} else {
|
||||
// Fall back on the system dialog.
|
||||
intent.setAction(NetworkScoreManager.ACTION_CHANGE_ACTIVE);
|
||||
intent.putExtra(NetworkScoreManager.EXTRA_PACKAGE_NAME,
|
||||
wifiAssistant.mPackageName);
|
||||
}
|
||||
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
if (KEY_SLEEP_POLICY.equals(key)) {
|
||||
@@ -270,7 +285,7 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
|
||||
Integer.parseInt(stringValue));
|
||||
updateSleepPolicySummary(preference, stringValue);
|
||||
} catch (NumberFormatException e) {
|
||||
Toast.makeText(getActivity(), R.string.wifi_setting_sleep_policy_error,
|
||||
Toast.makeText(context, R.string.wifi_setting_sleep_policy_error,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
@@ -280,18 +295,19 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
|
||||
}
|
||||
|
||||
private void refreshWifiInfo() {
|
||||
final Context context = getActivity();
|
||||
WifiInfo wifiInfo = mWifiManager.getConnectionInfo();
|
||||
|
||||
Preference wifiMacAddressPref = findPreference(KEY_MAC_ADDRESS);
|
||||
String macAddress = wifiInfo == null ? null : wifiInfo.getMacAddress();
|
||||
wifiMacAddressPref.setSummary(!TextUtils.isEmpty(macAddress) ? macAddress
|
||||
: getActivity().getString(R.string.status_unavailable));
|
||||
: context.getString(R.string.status_unavailable));
|
||||
wifiMacAddressPref.setSelectable(false);
|
||||
|
||||
Preference wifiIpAddressPref = findPreference(KEY_CURRENT_IP_ADDRESS);
|
||||
String ipAddress = Utils.getWifiIpAddresses(getActivity());
|
||||
String ipAddress = Utils.getWifiIpAddresses(context);
|
||||
wifiIpAddressPref.setSummary(ipAddress == null ?
|
||||
getActivity().getString(R.string.status_unavailable) : ipAddress);
|
||||
context.getString(R.string.status_unavailable) : ipAddress);
|
||||
wifiIpAddressPref.setSelectable(false);
|
||||
}
|
||||
|
||||
|
@@ -44,6 +44,7 @@ import android.net.wifi.WpsInfo;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.Parcelable;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.util.Log;
|
||||
@@ -685,6 +686,22 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Network Scorer for the Wifi Assistant App.
|
||||
*/
|
||||
public static NetworkScorerAppData getWifiAssistantApp(Context context) {
|
||||
Collection<NetworkScorerAppData> scorers =
|
||||
NetworkScorerAppManager.getAllValidScorers(context);
|
||||
|
||||
if (scorers.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO: b/13780935 - Implement proper scorer selection. Rather than pick the first
|
||||
// scorer on the system, we should allow the user to select one.
|
||||
return scorers.iterator().next();
|
||||
}
|
||||
|
||||
private void prepareWifiAssistantCard() {
|
||||
if (getActivity() instanceof WifiPickerActivity) {
|
||||
return;
|
||||
|
Reference in New Issue
Block a user