summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2012-04-13 16:03:40 -0700
committerJeff Sharkey <jsharkey@android.com>2012-04-13 19:46:33 -0700
commit854b2b1670bda1eeb87a14b7ac3d222024f0aad6 (patch)
tree86991bce25cb49406daf069ea1d5c9496d532790 /core
parenta94afeb5b3c3c95c6d2cf0cd4d69587aba569cfb (diff)
downloadframeworks_base-854b2b1670bda1eeb87a14b7ac3d222024f0aad6.zip
frameworks_base-854b2b1670bda1eeb87a14b7ac3d222024f0aad6.tar.gz
frameworks_base-854b2b1670bda1eeb87a14b7ac3d222024f0aad6.tar.bz2
Surface list of apps with given network policy.
Bug: 6007276 Change-Id: I0f0e939ee6481496480c4afaa108c99eb158547c
Diffstat (limited to 'core')
-rw-r--r--core/java/android/net/INetworkPolicyManager.aidl1
-rw-r--r--core/java/android/net/NetworkPolicyManager.java8
-rw-r--r--core/java/com/android/internal/util/ArrayUtils.java36
3 files changed, 45 insertions, 0 deletions
diff --git a/core/java/android/net/INetworkPolicyManager.aidl b/core/java/android/net/INetworkPolicyManager.aidl
index 89c9c36..35e8e47 100644
--- a/core/java/android/net/INetworkPolicyManager.aidl
+++ b/core/java/android/net/INetworkPolicyManager.aidl
@@ -32,6 +32,7 @@ interface INetworkPolicyManager {
/** Control UID policies. */
void setAppPolicy(int appId, int policy);
int getAppPolicy(int appId);
+ int[] getAppsWithPolicy(int policy);
boolean isUidForeground(int uid);
diff --git a/core/java/android/net/NetworkPolicyManager.java b/core/java/android/net/NetworkPolicyManager.java
index 2b36131..07bfd4b 100644
--- a/core/java/android/net/NetworkPolicyManager.java
+++ b/core/java/android/net/NetworkPolicyManager.java
@@ -92,6 +92,14 @@ public class NetworkPolicyManager {
}
}
+ public int[] getAppsWithPolicy(int policy) {
+ try {
+ return mService.getAppsWithPolicy(policy);
+ } catch (RemoteException e) {
+ return new int[0];
+ }
+ }
+
public void registerListener(INetworkPolicyListener listener) {
try {
mService.registerListener(listener);
diff --git a/core/java/com/android/internal/util/ArrayUtils.java b/core/java/com/android/internal/util/ArrayUtils.java
index d1aa1ce..dbf6c8e 100644
--- a/core/java/com/android/internal/util/ArrayUtils.java
+++ b/core/java/com/android/internal/util/ArrayUtils.java
@@ -201,4 +201,40 @@ public class ArrayUtils
}
return array;
}
+
+ public static int[] appendInt(int[] cur, int val) {
+ if (cur == null) {
+ return new int[] { val };
+ }
+ final int N = cur.length;
+ for (int i = 0; i < N; i++) {
+ if (cur[i] == val) {
+ return cur;
+ }
+ }
+ int[] ret = new int[N + 1];
+ System.arraycopy(cur, 0, ret, 0, N);
+ ret[N] = val;
+ return ret;
+ }
+
+ public static int[] removeInt(int[] cur, int val) {
+ if (cur == null) {
+ return null;
+ }
+ final int N = cur.length;
+ for (int i = 0; i < N; i++) {
+ if (cur[i] == val) {
+ int[] ret = new int[N - 1];
+ if (i > 0) {
+ System.arraycopy(cur, 0, ret, 0, i);
+ }
+ if (i < (N - 1)) {
+ System.arraycopy(cur, i + 1, ret, i, N - i - 1);
+ }
+ return ret;
+ }
+ }
+ return cur;
+ }
}