summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorAmin Shaikh <ashaikh@google.com>2016-12-07 14:08:09 -0800
committerAmin Shaikh <ashaikh@google.com>2016-12-07 15:52:33 -0800
commit972e236e84fd4073f7ecc40f2de326b388203dfb (patch)
treea98da98cdb14bdc009993c6791f9ff049a562268 /core/java
parentfaf3aa697fc569180cc029c09affe08ade9c5e82 (diff)
Support multiple caches in NetworkScoreService.
- Use RemoteCallbackList for managing multiple callbacks - Add unregisterNetworkScoreCache to the service interface - Added NetworkScoreServiceTest Test: runtest frameworks-services Bug: 32913019 Change-Id: I16ca1682acca9cbe403812e520394688a026414b
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/net/INetworkScoreService.aidl13
-rw-r--r--core/java/android/net/NetworkScoreManager.java18
2 files changed, 29 insertions, 2 deletions
diff --git a/core/java/android/net/INetworkScoreService.aidl b/core/java/android/net/INetworkScoreService.aidl
index 59cbf6e93894..542a0a7d4040 100644
--- a/core/java/android/net/INetworkScoreService.aidl
+++ b/core/java/android/net/INetworkScoreService.aidl
@@ -56,17 +56,26 @@ interface INetworkScoreService
void disableScoring();
/**
- * Register a network subsystem for scoring.
+ * Register a cache to receive scoring updates.
*
* @param networkType the type of network this cache can handle. See {@link NetworkKey#type}.
* @param scoreCache implementation of {@link INetworkScoreCache} to store the scores.
* @throws SecurityException if the caller is not the system.
- * @throws IllegalArgumentException if a score cache is already registed for this type.
* @hide
*/
void registerNetworkScoreCache(int networkType, INetworkScoreCache scoreCache);
/**
+ * Unregister a cache to receive scoring updates.
+ *
+ * @param networkType the type of network this cache can handle. See {@link NetworkKey#type}.
+ * @param scoreCache implementation of {@link INetworkScoreCache} to store the scores.
+ * @throws SecurityException if the caller is not the system.
+ * @hide
+ */
+ void unregisterNetworkScoreCache(int networkType, INetworkScoreCache scoreCache);
+
+ /**
* Request a recommendation for the best network to connect to
* taking into account the inputs from the {@link RecommendationRequest}.
*
diff --git a/core/java/android/net/NetworkScoreManager.java b/core/java/android/net/NetworkScoreManager.java
index c301fe3b73fe..af21cefce7ed 100644
--- a/core/java/android/net/NetworkScoreManager.java
+++ b/core/java/android/net/NetworkScoreManager.java
@@ -279,6 +279,24 @@ public class NetworkScoreManager {
}
/**
+ * Unregister a network score cache.
+ *
+ * @param networkType the type of network this cache can handle. See {@link NetworkKey#type}.
+ * @param scoreCache implementation of {@link INetworkScoreCache} to store the scores.
+ * @throws SecurityException if the caller does not hold the
+ * {@link android.Manifest.permission#BROADCAST_NETWORK_PRIVILEGED} permission.
+ * @throws IllegalArgumentException if a score cache is already registered for this type.
+ * @hide
+ */
+ public void unregisterNetworkScoreCache(int networkType, INetworkScoreCache scoreCache) {
+ try {
+ mService.unregisterNetworkScoreCache(networkType, scoreCache);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* Request a recommendation for which network to connect to.
*
* @param request a {@link RecommendationRequest} instance containing additional