Allow apps with SCORE_NETWORKS to set the active scorer.

This allows for a more streamlined UX in the current world, where
scorer apps are trusted (by virtue of being in /system/priv-app).
Trusted apps can continue to use the system dialog for consent, but
they may also set the scorer directly, under the assumption that they
are using their own consent UX to explain the feature to the user.

Bug: 16577529
Change-Id: I2a6edb7f1f688aaacf9b0152fa1da1a88636c3dc
diff --git a/services/core/java/com/android/server/NetworkScoreService.java b/services/core/java/com/android/server/NetworkScoreService.java
index bb91a14..738917f 100644
--- a/services/core/java/com/android/server/NetworkScoreService.java
+++ b/services/core/java/com/android/server/NetworkScoreService.java
@@ -130,7 +130,16 @@
 
     @Override
     public boolean setActiveScorer(String packageName) {
-        mContext.enforceCallingOrSelfPermission(permission.BROADCAST_NETWORK_PRIVILEGED, TAG);
+        // TODO: For now, since SCORE_NETWORKS requires an app to be privileged, we allow such apps
+        // to directly set the scorer app rather than having to use the consent dialog. The
+        // assumption is that anyone bundling a scorer app with the system is trusted by the OEM to
+        // do the right thing and not enable this feature without explaining it to the user.
+        // In the future, should this API be opened to 3p apps, we will need to lock this down and
+        // figure out another way to streamline the UX.
+
+        // mContext.enforceCallingOrSelfPermission(permission.BROADCAST_NETWORK_PRIVILEGED, TAG);
+        mContext.enforceCallingOrSelfPermission(permission.SCORE_NETWORKS, TAG);
+
         return setScorerInternal(packageName);
     }