diff options
| author | 2014-08-15 21:56:24 +0000 | |
|---|---|---|
| committer | 2014-08-15 21:23:40 +0000 | |
| commit | cab3eb0c0b29d8c4b58652c40687a5a4309f94ef (patch) | |
| tree | b35125fce5f29f35212057dc3c37b03099031f9b | |
| parent | a69adf7535d6a7cbe49ac7aad4322524425200e9 (diff) | |
| parent | 56f9f73a5aad38aa777ec9a42c859e687f2d2af1 (diff) | |
Merge "Fix default scorer provisioning." into lmp-dev
| -rw-r--r-- | core/java/android/provider/Settings.java | 8 | ||||
| -rw-r--r-- | services/core/java/com/android/server/NetworkScoreService.java | 12 |
2 files changed, 13 insertions, 7 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index c2a3012b18e9..e075d8b38cb4 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -6470,6 +6470,14 @@ public final class Settings { public static final String GUEST_USER_ENABLED = "guest_user_enabled"; /** + * Whether the NetworkScoringService has been first initialized. + * <p> + * Type: int (0 for false, 1 for true) + * @hide + */ + public static final String NETWORK_SCORING_PROVISIONED = "network_scoring_provisioned"; + + /** * Settings to backup. This is here so that it's in the same place as the settings * keys and easy to update. * diff --git a/services/core/java/com/android/server/NetworkScoreService.java b/services/core/java/com/android/server/NetworkScoreService.java index ab4d4dca06d4..395e365c421d 100644 --- a/services/core/java/com/android/server/NetworkScoreService.java +++ b/services/core/java/com/android/server/NetworkScoreService.java @@ -17,9 +17,9 @@ package com.android.server; import android.Manifest.permission; +import android.content.ContentResolver; import android.content.Context; import android.content.Intent; -import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.net.INetworkScoreCache; import android.net.INetworkScoreService; @@ -30,6 +30,7 @@ import android.net.ScoredNetwork; import android.os.Binder; import android.os.RemoteException; import android.os.UserHandle; +import android.provider.Settings; import android.text.TextUtils; import android.util.Log; @@ -51,9 +52,6 @@ import java.util.Set; public class NetworkScoreService extends INetworkScoreService.Stub { private static final String TAG = "NetworkScoreService"; - /** SharedPreference bit set to true after the service is first initialized. */ - private static final String PREF_SCORING_PROVISIONED = "is_provisioned"; - private final Context mContext; private final Map<Integer, INetworkScoreCache> mScoreCaches; @@ -65,8 +63,8 @@ public class NetworkScoreService extends INetworkScoreService.Stub { /** Called when the system is ready to run third-party code but before it actually does so. */ void systemReady() { - SharedPreferences prefs = mContext.getSharedPreferences(TAG, Context.MODE_PRIVATE); - if (!prefs.getBoolean(PREF_SCORING_PROVISIONED, false)) { + ContentResolver cr = mContext.getContentResolver(); + if (Settings.Global.getInt(cr, Settings.Global.NETWORK_SCORING_PROVISIONED, 0) == 0) { // On first run, we try to initialize the scorer to the one configured at build time. // This will be a no-op if the scorer isn't actually valid. String defaultPackage = mContext.getResources().getString( @@ -74,7 +72,7 @@ public class NetworkScoreService extends INetworkScoreService.Stub { if (!TextUtils.isEmpty(defaultPackage)) { NetworkScorerAppManager.setActiveScorer(mContext, defaultPackage); } - prefs.edit().putBoolean(PREF_SCORING_PROVISIONED, true).apply(); + Settings.Global.putInt(cr, Settings.Global.NETWORK_SCORING_PROVISIONED, 1); } } |