Merge "New pref toggle for network recommendations." am: a5249906ab
am: 2b03ffb264
am: 6061ca1b1a
Change-Id: I05753f7a5d54cd7707531c0a6cd9491c081454b3
This commit is contained in:
@@ -2556,16 +2556,6 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name=".ActiveNetworkScorerDialog"
|
|
||||||
android:label="@string/wifi_assistant_title"
|
|
||||||
android:excludeFromRecents="true"
|
|
||||||
android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.Alert">
|
|
||||||
<intent-filter android:priority="1">
|
|
||||||
<action android:name="android.net.scoring.CHANGE_ACTIVE" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity android:name="Settings$NotificationAccessSettingsActivity"
|
<activity android:name="Settings$NotificationAccessSettingsActivity"
|
||||||
android:label="@string/manage_notification_access_title"
|
android:label="@string/manage_notification_access_title"
|
||||||
android:taskAffinity="">
|
android:taskAffinity="">
|
||||||
|
@@ -1460,9 +1460,6 @@
|
|||||||
<!-- Bluetooth settings. Dock Setting Dialog - Remember setting and don't ask user again -->
|
<!-- Bluetooth settings. Dock Setting Dialog - Remember setting and don't ask user again -->
|
||||||
<string name="bluetooth_dock_settings_remember">Remember settings</string>
|
<string name="bluetooth_dock_settings_remember">Remember settings</string>
|
||||||
|
|
||||||
<!-- Wifi Assistant title. [CHAR LIMIT=40] -->
|
|
||||||
<string name="wifi_assistant_title">Wi\u2011Fi Assistant</string>
|
|
||||||
|
|
||||||
<!-- Wifi Display settings. The title of the screen. [CHAR LIMIT=40] -->
|
<!-- Wifi Display settings. The title of the screen. [CHAR LIMIT=40] -->
|
||||||
<string name="wifi_display_settings_title">Cast</string>
|
<string name="wifi_display_settings_title">Cast</string>
|
||||||
<!-- Wifi Display settings. The title of a menu item to enable wireless display [CHAR LIMIT=40] -->
|
<!-- Wifi Display settings. The title of a menu item to enable wireless display [CHAR LIMIT=40] -->
|
||||||
@@ -1581,12 +1578,12 @@
|
|||||||
<string name="wifi_poor_network_detection_summary">Don\u2019t use a Wi\u2011Fi network unless it has a good Internet connection</string>
|
<string name="wifi_poor_network_detection_summary">Don\u2019t use a Wi\u2011Fi network unless it has a good Internet connection</string>
|
||||||
<!-- Checkbox summary for option to toggle poor network detection [CHAR LIMIT=60] -->
|
<!-- Checkbox summary for option to toggle poor network detection [CHAR LIMIT=60] -->
|
||||||
<string name="wifi_avoid_poor_network_detection_summary">Only use networks that have a good Internet connection</string>
|
<string name="wifi_avoid_poor_network_detection_summary">Only use networks that have a good Internet connection</string>
|
||||||
<!-- Checkbox title for option to connect to open Wi-Fi automatically [CHAR LIMIT=40] -->
|
|
||||||
<string name="wifi_automatically_connect_title">Use open Wi\u2011Fi automatically</string>
|
<!-- Network recommendations toggle -->
|
||||||
<!-- Checkbox summary for option to connect to open Wi-Fi automatically [CHAR LIMIT=100] -->
|
<!--TODO(jjoslin): Provide final strings and mark for translation. BUG: 32913919 -->
|
||||||
<string name="wifi_automatically_connect_summary">Let a Wi\u2011Fi assistant automatically connect to open networks determined to be high quality</string>
|
<string translatable="false" name="networking_allow_recommendations_title">Use network recommendations</string>
|
||||||
<!-- Dialog title for option to select an app which connects to open Wi-Fi automatically [CHAR LIMIT=40] -->
|
<string translatable="false" name="networking_allow_recommendations_summary">When enabled, use network recommendations when selecting the Wi\u2011Fi network to connect to</string>
|
||||||
<string name="wifi_select_assistant_dialog_title">Choose assistant</string>
|
|
||||||
<!-- Preference title for option to install certificates -->
|
<!-- Preference title for option to install certificates -->
|
||||||
<string name="wifi_install_credentials">Install certificates</string>
|
<string name="wifi_install_credentials">Install certificates</string>
|
||||||
<!-- Message to describe "Wi-Fi scan always available feature" when Wi-Fi is off. The
|
<!-- Message to describe "Wi-Fi scan always available feature" when Wi-Fi is off. The
|
||||||
|
@@ -35,11 +35,10 @@
|
|||||||
android:entries="@array/wifi_sleep_policy_entries"
|
android:entries="@array/wifi_sleep_policy_entries"
|
||||||
android:entryValues="@array/wifi_sleep_policy_values" />
|
android:entryValues="@array/wifi_sleep_policy_values" />
|
||||||
|
|
||||||
<com.android.settings.AppListSwitchPreference
|
<SwitchPreference
|
||||||
android:key="wifi_assistant"
|
android:key="allow_recommendations"
|
||||||
android:title="@string/wifi_automatically_connect_title"
|
android:title="@string/networking_allow_recommendations_title"
|
||||||
android:summary="@string/wifi_automatically_connect_summary"
|
android:summary="@string/networking_allow_recommendations_summary"/>
|
||||||
android:dialogTitle="@string/wifi_select_assistant_dialog_title" />
|
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="wifi_cellular_data_fallback"
|
android:key="wifi_cellular_data_fallback"
|
||||||
|
@@ -1,112 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.settings;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.net.NetworkScoreManager;
|
|
||||||
import android.net.NetworkScorerAppManager;
|
|
||||||
import android.net.NetworkScorerAppManager.NetworkScorerAppData;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.UserHandle;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.android.internal.app.AlertActivity;
|
|
||||||
import com.android.internal.app.AlertController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Dialog to allow a user to select a new network scorer.
|
|
||||||
*
|
|
||||||
* <p>Finishes with {@link #RESULT_CANCELED} in all circumstances unless the scorer is successfully
|
|
||||||
* changed or was already set to the new value (in which case it finishes with {@link #RESULT_OK}).
|
|
||||||
*/
|
|
||||||
public final class ActiveNetworkScorerDialog extends AlertActivity implements
|
|
||||||
DialogInterface.OnClickListener {
|
|
||||||
private static final String TAG = "ActiveNetScorerDlg";
|
|
||||||
|
|
||||||
private String mNewPackageName;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
Intent intent = getIntent();
|
|
||||||
mNewPackageName = intent.getStringExtra(NetworkScoreManager.EXTRA_PACKAGE_NAME);
|
|
||||||
|
|
||||||
if (!buildDialog()) {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
switch (which) {
|
|
||||||
case BUTTON_POSITIVE:
|
|
||||||
NetworkScoreManager nsm =
|
|
||||||
(NetworkScoreManager) getSystemService(Context.NETWORK_SCORE_SERVICE);
|
|
||||||
if (nsm.setActiveScorer(mNewPackageName)) {
|
|
||||||
setResult(RESULT_OK);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case BUTTON_NEGATIVE:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean buildDialog() {
|
|
||||||
// TOOD: http://b/23422763
|
|
||||||
if (UserHandle.myUserId() != UserHandle.USER_SYSTEM) {
|
|
||||||
Log.i(TAG, "Can only set scorer for owner/system user.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
NetworkScorerAppManager networkScorerAppManager = new NetworkScorerAppManager(this);
|
|
||||||
NetworkScorerAppData newScorer = networkScorerAppManager.getScorer(mNewPackageName);
|
|
||||||
if (newScorer == null) {
|
|
||||||
Log.e(TAG, "New package " + mNewPackageName + " is not a valid scorer.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkScorerAppData oldScorer = networkScorerAppManager.getActiveScorer();
|
|
||||||
if (oldScorer != null && TextUtils.equals(oldScorer.mPackageName, mNewPackageName)) {
|
|
||||||
Log.i(TAG, "New package " + mNewPackageName + " is already the active scorer.");
|
|
||||||
// Set RESULT_OK to indicate to the caller that the "switch" was successful.
|
|
||||||
setResult(RESULT_OK);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compose dialog.
|
|
||||||
CharSequence newName = newScorer.mScorerName;
|
|
||||||
final AlertController.AlertParams p = mAlertParams;
|
|
||||||
p.mTitle = getString(R.string.network_scorer_change_active_dialog_title);
|
|
||||||
if (oldScorer != null) {
|
|
||||||
p.mMessage = getString(R.string.network_scorer_change_active_dialog_text, newName,
|
|
||||||
oldScorer.mScorerName);
|
|
||||||
} else {
|
|
||||||
p.mMessage = getString(R.string.network_scorer_change_active_no_previous_dialog_text,
|
|
||||||
newName);
|
|
||||||
}
|
|
||||||
p.mPositiveButtonText = getString(R.string.yes);
|
|
||||||
p.mNegativeButtonText = getString(R.string.no);
|
|
||||||
p.mPositiveButtonListener = this;
|
|
||||||
p.mNegativeButtonListener = this;
|
|
||||||
setupAlert();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -19,14 +19,10 @@ import android.content.BroadcastReceiver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.net.NetworkScoreManager;
|
|
||||||
import android.net.NetworkScorerAppManager;
|
|
||||||
import android.net.wifi.WifiConfiguration;
|
import android.net.wifi.WifiConfiguration;
|
||||||
import android.net.wifi.WifiInfo;
|
import android.net.wifi.WifiInfo;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.UserManager;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.v14.preference.SwitchPreference;
|
import android.support.v14.preference.SwitchPreference;
|
||||||
import android.support.v7.preference.ListPreference;
|
import android.support.v7.preference.ListPreference;
|
||||||
@@ -35,12 +31,9 @@ import android.text.TextUtils;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||||
import com.android.settings.AppListSwitchPreference;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ConfigureWifiSettings extends SettingsPreferenceFragment
|
public class ConfigureWifiSettings extends SettingsPreferenceFragment
|
||||||
@@ -53,12 +46,9 @@ public class ConfigureWifiSettings extends SettingsPreferenceFragment
|
|||||||
private static final String KEY_NOTIFY_OPEN_NETWORKS = "notify_open_networks";
|
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_SLEEP_POLICY = "sleep_policy";
|
||||||
private static final String KEY_CELLULAR_FALLBACK = "wifi_cellular_data_fallback";
|
private static final String KEY_CELLULAR_FALLBACK = "wifi_cellular_data_fallback";
|
||||||
private static final String KEY_WIFI_ASSISTANT = "wifi_assistant";
|
private static final String KEY_ALLOW_RECOMMENDATIONS = "allow_recommendations";
|
||||||
|
|
||||||
private WifiManager mWifiManager;
|
private WifiManager mWifiManager;
|
||||||
private NetworkScoreManager mNetworkScoreManager;
|
|
||||||
private AppListSwitchPreference mWifiAssistantPreference;
|
|
||||||
|
|
||||||
private IntentFilter mFilter;
|
private IntentFilter mFilter;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -74,8 +64,6 @@ public class ConfigureWifiSettings extends SettingsPreferenceFragment
|
|||||||
mFilter = new IntentFilter();
|
mFilter = new IntentFilter();
|
||||||
mFilter.addAction(WifiManager.LINK_CONFIGURATION_CHANGED_ACTION);
|
mFilter.addAction(WifiManager.LINK_CONFIGURATION_CHANGED_ACTION);
|
||||||
mFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
mFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
||||||
mNetworkScoreManager =
|
|
||||||
(NetworkScoreManager) getSystemService(Context.NETWORK_SCORE_SERVICE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -119,15 +107,10 @@ public class ConfigureWifiSettings extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mWifiAssistantPreference = (AppListSwitchPreference) findPreference(KEY_WIFI_ASSISTANT);
|
SwitchPreference allowRecommendations =
|
||||||
Collection<NetworkScorerAppManager.NetworkScorerAppData> scorers =
|
(SwitchPreference) findPreference(KEY_ALLOW_RECOMMENDATIONS);
|
||||||
new NetworkScorerAppManager(context).getAllValidScorers();
|
allowRecommendations.setChecked(Settings.Global.getInt(getContentResolver(),
|
||||||
if (UserManager.get(context).isAdminUser() && !scorers.isEmpty()) {
|
Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED, 0) == 1);
|
||||||
mWifiAssistantPreference.setOnPreferenceChangeListener(this);
|
|
||||||
initWifiAssistantPreference(scorers);
|
|
||||||
} else if (mWifiAssistantPreference != null) {
|
|
||||||
getPreferenceScreen().removePreference(mWifiAssistantPreference);
|
|
||||||
}
|
|
||||||
|
|
||||||
ListPreference sleepPolicyPref = (ListPreference) findPreference(KEY_SLEEP_POLICY);
|
ListPreference sleepPolicyPref = (ListPreference) findPreference(KEY_SLEEP_POLICY);
|
||||||
if (sleepPolicyPref != null) {
|
if (sleepPolicyPref != null) {
|
||||||
@@ -187,6 +170,10 @@ public class ConfigureWifiSettings extends SettingsPreferenceFragment
|
|||||||
String settingName = Settings.Global.NETWORK_AVOID_BAD_WIFI;
|
String settingName = Settings.Global.NETWORK_AVOID_BAD_WIFI;
|
||||||
Settings.Global.putString(getContentResolver(), settingName,
|
Settings.Global.putString(getContentResolver(), settingName,
|
||||||
((SwitchPreference) preference).isChecked() ? "1" : null);
|
((SwitchPreference) preference).isChecked() ? "1" : null);
|
||||||
|
} else if (KEY_ALLOW_RECOMMENDATIONS.equals(key)) {
|
||||||
|
Settings.Global.putInt(getActivity().getContentResolver(),
|
||||||
|
Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED,
|
||||||
|
((SwitchPreference) preference).isChecked() ? 1 : 0);
|
||||||
} else {
|
} else {
|
||||||
return super.onPreferenceTreeClick(preference);
|
return super.onPreferenceTreeClick(preference);
|
||||||
}
|
}
|
||||||
@@ -198,34 +185,6 @@ public class ConfigureWifiSettings extends SettingsPreferenceFragment
|
|||||||
final Context context = getActivity();
|
final Context context = getActivity();
|
||||||
String key = preference.getKey();
|
String key = preference.getKey();
|
||||||
|
|
||||||
if (KEY_WIFI_ASSISTANT.equals(key)) {
|
|
||||||
NetworkScorerAppManager.NetworkScorerAppData wifiAssistant =
|
|
||||||
new NetworkScorerAppManager(context).getScorer((String) newValue);
|
|
||||||
if (wifiAssistant == null) {
|
|
||||||
mNetworkScoreManager.setActiveScorer(null);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
// Don't update the preference widget state until the child activity returns.
|
|
||||||
// It will be updated in onResume after the activity finishes.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (KEY_SLEEP_POLICY.equals(key)) {
|
if (KEY_SLEEP_POLICY.equals(key)) {
|
||||||
try {
|
try {
|
||||||
String stringValue = (String) newValue;
|
String stringValue = (String) newValue;
|
||||||
@@ -259,19 +218,6 @@ public class ConfigureWifiSettings extends SettingsPreferenceFragment
|
|||||||
wifiIpAddressPref.setSelectable(false);
|
wifiIpAddressPref.setSelectable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initWifiAssistantPreference(
|
|
||||||
Collection<NetworkScorerAppManager.NetworkScorerAppData> scorers) {
|
|
||||||
int count = scorers.size();
|
|
||||||
String[] packageNames = new String[count];
|
|
||||||
int i = 0;
|
|
||||||
for (NetworkScorerAppManager.NetworkScorerAppData scorer : scorers) {
|
|
||||||
packageNames[i] = scorer.mPackageName;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
mWifiAssistantPreference.setPackageNames(packageNames,
|
|
||||||
mNetworkScoreManager.getActiveScorerPackage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getMetricsCategory() {
|
protected int getMetricsCategory() {
|
||||||
return MetricsEvent.CONFIGURE_WIFI;
|
return MetricsEvent.CONFIGURE_WIFI;
|
||||||
|
Reference in New Issue
Block a user