Merge "Add a new setting to store the network recommendation app."
This commit is contained in:
committed by
Android (Google) Code Review
commit
f61cdcb60f
@@ -48,6 +48,7 @@ import android.database.Cursor;
|
||||
import android.database.SQLException;
|
||||
import android.location.LocationManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkScoreManager;
|
||||
import android.net.Uri;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.BatteryManager;
|
||||
@@ -8219,6 +8220,19 @@ public final class Settings {
|
||||
public static final String NETWORK_RECOMMENDATIONS_ENABLED =
|
||||
"network_recommendations_enabled";
|
||||
|
||||
/**
|
||||
* Which package name to use for network recommendations. If null, network recommendations
|
||||
* will neither be requested nor accepted.
|
||||
*
|
||||
* Use {@link NetworkScoreManager#getActiveScorerPackage()} to read this value and
|
||||
* {@link NetworkScoreManager#setActiveScorer(String)} to write it.
|
||||
*
|
||||
* Type: string - package name
|
||||
* @hide
|
||||
*/
|
||||
public static final String NETWORK_RECOMMENDATIONS_PACKAGE =
|
||||
"network_recommendations_package";
|
||||
|
||||
/**
|
||||
* Value to specify if the Wi-Fi Framework should defer to
|
||||
* {@link com.android.server.NetworkScoreService} for evaluating saved open networks.
|
||||
|
||||
@@ -328,6 +328,7 @@ message GlobalSettingsProto {
|
||||
SettingProto enable_cellular_on_boot = 283;
|
||||
SettingProto max_notification_enqueue_rate = 284;
|
||||
SettingProto cell_on = 285;
|
||||
SettingProto network_recommendations_package = 286;
|
||||
}
|
||||
|
||||
message SecureSettingsProto {
|
||||
|
||||
@@ -227,4 +227,7 @@
|
||||
|
||||
<!-- default setting for Settings.System.END_BUTTON_BEHAVIOR : END_BUTTON_BEHAVIOR_SLEEP -->
|
||||
<integer name="def_end_button_behavior">0x2</integer>
|
||||
|
||||
<!--Default settings for network recommendations. -->
|
||||
<string name="def_network_recommendations_package" translatable="false">com.android.networkrecommendation</string>
|
||||
</resources>
|
||||
|
||||
@@ -494,6 +494,9 @@ class SettingsProtoDumpUtil {
|
||||
dumpSetting(s, p,
|
||||
Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED,
|
||||
GlobalSettingsProto.NETWORK_RECOMMENDATIONS_ENABLED);
|
||||
dumpSetting(s, p,
|
||||
Settings.Global.NETWORK_RECOMMENDATIONS_PACKAGE,
|
||||
GlobalSettingsProto.NETWORK_RECOMMENDATIONS_PACKAGE);
|
||||
dumpSetting(s, p,
|
||||
Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE,
|
||||
GlobalSettingsProto.BLE_SCAN_ALWAYS_AVAILABLE);
|
||||
|
||||
@@ -2735,7 +2735,7 @@ public class SettingsProvider extends ContentProvider {
|
||||
}
|
||||
|
||||
private final class UpgradeController {
|
||||
private static final int SETTINGS_VERSION = 138;
|
||||
private static final int SETTINGS_VERSION = 139;
|
||||
|
||||
private final int mUserId;
|
||||
|
||||
@@ -3118,26 +3118,7 @@ public class SettingsProvider extends ContentProvider {
|
||||
}
|
||||
|
||||
if (currentVersion == 135) {
|
||||
// Version 135: Migrating the NETWORK_SCORER_APP setting to the
|
||||
// NETWORK_RECOMMENDATIONS_ENABLED setting.
|
||||
if (userId == UserHandle.USER_SYSTEM) {
|
||||
final SettingsState globalSettings = getGlobalSettingsLocked();
|
||||
Setting currentSetting = globalSettings.getSettingLocked(
|
||||
Global.NETWORK_SCORER_APP);
|
||||
if (!currentSetting.isNull()) {
|
||||
// A scorer was set so enable recommendations.
|
||||
globalSettings.insertSettingLocked(
|
||||
Global.NETWORK_RECOMMENDATIONS_ENABLED,
|
||||
"1", null, true,
|
||||
SettingsState.SYSTEM_PACKAGE_NAME);
|
||||
|
||||
// and clear the scorer setting since it's no longer needed.
|
||||
globalSettings.insertSettingLocked(
|
||||
Global.NETWORK_SCORER_APP,
|
||||
null, null, true,
|
||||
SettingsState.SYSTEM_PACKAGE_NAME);
|
||||
}
|
||||
}
|
||||
// Version 135 no longer used.
|
||||
currentVersion = 136;
|
||||
}
|
||||
|
||||
@@ -3200,6 +3181,28 @@ public class SettingsProvider extends ContentProvider {
|
||||
currentVersion = 138;
|
||||
}
|
||||
|
||||
if (currentVersion == 138) {
|
||||
// Version 139: Applying the default to NETWORK_RECOMMENDATIONS_PACKAGE
|
||||
if (userId == UserHandle.USER_SYSTEM) {
|
||||
final SettingsState globalSettings = getGlobalSettingsLocked();
|
||||
final String defaultAppPackage = getContext().getResources()
|
||||
.getString(R.string.def_network_recommendations_package);
|
||||
|
||||
// Set the network recommendations package name
|
||||
globalSettings.insertSettingLocked(
|
||||
Global.NETWORK_RECOMMENDATIONS_PACKAGE,
|
||||
defaultAppPackage, null, true,
|
||||
SettingsState.SYSTEM_PACKAGE_NAME);
|
||||
|
||||
// Clear the scorer setting since it's no longer needed.
|
||||
globalSettings.insertSettingLocked(
|
||||
Global.NETWORK_SCORER_APP,
|
||||
null, null, true,
|
||||
SettingsState.SYSTEM_PACKAGE_NAME);
|
||||
}
|
||||
currentVersion = 139;
|
||||
}
|
||||
|
||||
if (currentVersion != newVersion) {
|
||||
Slog.wtf("SettingsProvider", "warning: upgrading settings database to version "
|
||||
+ newVersion + " left it at "
|
||||
|
||||
Reference in New Issue
Block a user