blob: d163a44410977c85d0eb78531ade2f046ac49e7b [file] [log] [blame]
Jeff Davidson6a4b2202014-04-16 17:29:40 -07001/**
2 * Copyright (c) 2014, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.net;
18
Jeff Davidson14f1ec02014-04-29 11:58:26 -070019import android.net.INetworkScoreCache;
Jeremy Joslinb2087a12016-12-13 16:11:51 -080020import android.net.NetworkKey;
Jeremy Joslinf621bc92017-02-16 11:11:57 -080021import android.net.NetworkScorerAppData;
Jeff Davidson6a4b2202014-04-16 17:29:40 -070022import android.net.ScoredNetwork;
23
24/**
25 * A service for updating network scores from a network scorer application.
26 * @hide
27 */
28interface INetworkScoreService
29{
30 /**
31 * Update scores.
32 * @return whether the update was successful.
33 * @throws SecurityException if the caller is not the current active scorer.
34 */
35 boolean updateScores(in ScoredNetwork[] networks);
36
37 /**
38 * Clear all scores.
39 * @return whether the clear was successful.
Jeff Davidson14f1ec02014-04-29 11:58:26 -070040 * @throws SecurityException if the caller is neither the current active scorer nor the system.
Jeff Davidson6a4b2202014-04-16 17:29:40 -070041 */
42 boolean clearScores();
43
44 /**
45 * Set the active scorer and clear existing scores.
46 * @param packageName the package name of the new scorer to use.
47 * @return true if the operation succeeded, or false if the new package is not a valid scorer.
Jeremy Joslina9f933e2017-04-28 13:08:17 -070048 * @throws SecurityException if the caller is not the system or a network scorer.
Jeff Davidson6a4b2202014-04-16 17:29:40 -070049 */
50 boolean setActiveScorer(in String packageName);
Jeff Davidson14f1ec02014-04-29 11:58:26 -070051
52 /**
Jeff Davidson26fd1432014-07-29 09:39:52 -070053 * Disable the current active scorer and clear existing scores.
54 * @throws SecurityException if the caller is not the current scorer or the system.
55 */
56 void disableScoring();
57
58 /**
Amin Shaikh972e2362016-12-07 14:08:09 -080059 * Register a cache to receive scoring updates.
Jeff Davidson14f1ec02014-04-29 11:58:26 -070060 *
Jeremy Joslinc5ac5872016-11-30 15:05:40 -080061 * @param networkType the type of network this cache can handle. See {@link NetworkKey#type}
62 * @param scoreCache implementation of {@link INetworkScoreCache} to store the scores
63 * @param filterType the {@link CacheUpdateFilter} to apply
64 * @throws SecurityException if the caller is not the system
65 * @throws IllegalArgumentException if a score cache is already registed for this type
Jeff Davidson14f1ec02014-04-29 11:58:26 -070066 * @hide
67 */
Jeremy Joslinc5ac5872016-11-30 15:05:40 -080068 void registerNetworkScoreCache(int networkType, INetworkScoreCache scoreCache, int filterType);
Jeff Davidson14f1ec02014-04-29 11:58:26 -070069
Jeremy Joslind1daf6d2016-11-28 17:47:35 -080070 /**
Amin Shaikh972e2362016-12-07 14:08:09 -080071 * Unregister a cache to receive scoring updates.
72 *
73 * @param networkType the type of network this cache can handle. See {@link NetworkKey#type}.
74 * @param scoreCache implementation of {@link INetworkScoreCache} to store the scores.
75 * @throws SecurityException if the caller is not the system.
76 * @hide
77 */
78 void unregisterNetworkScoreCache(int networkType, INetworkScoreCache scoreCache);
79
80 /**
Jeremy Joslinb2087a12016-12-13 16:11:51 -080081 * Request scoring for networks.
82 *
83 * Implementations should delegate to the registered network recommendation provider or
84 * fulfill the request locally if possible.
85 *
86 * @param networks an array of {@link NetworkKey}s to score
87 * @return true if the request was delegated or fulfilled locally, false otherwise
88 * @throws SecurityException if the caller is not the system
89 * @hide
90 */
91 boolean requestScores(in NetworkKey[] networks);
Jeremy Joslin134c9d32017-01-09 16:22:20 -080092
93 /**
94 * Determine whether the application with the given UID is the enabled scorer.
95 *
96 * @param callingUid the UID to check
97 * @return true if the provided UID is the active scorer, false otherwise.
98 * @hide
99 */
100 boolean isCallerActiveScorer(int callingUid);
Jeremy Joslin6c1ca282017-01-10 13:08:32 -0800101
102 /**
103 * Obtain the package name of the current active network scorer.
104 *
105 * @return the full package name of the current active scorer, or null if there is no active
106 * scorer.
107 */
108 String getActiveScorerPackage();
Jeremy Joslina5172f62017-02-02 14:27:05 -0800109
Jeremy Joslinf95c8652017-02-09 15:32:04 -0800110 /**
111 * Returns metadata about the active scorer or <code>null</code> if there is no active scorer.
112 */
Jeremy Joslinf621bc92017-02-16 11:11:57 -0800113 NetworkScorerAppData getActiveScorer();
Jeremy Joslinf95c8652017-02-09 15:32:04 -0800114
115 /**
116 * Returns the list of available scorer apps. The list will be empty if there are
117 * no valid scorers.
118 */
Jeremy Joslinf621bc92017-02-16 11:11:57 -0800119 List<NetworkScorerAppData> getAllValidScorers();
Jeff Davidson6a4b2202014-04-16 17:29:40 -0700120}