summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2010-09-29 19:27:20 -0700
committerKenny Root <kroot@google.com>2010-09-30 17:24:53 -0700
commit27358a69b33eaa268ee75ef778ec824c8085adcc (patch)
treee12147b6763048166c954c0d2375b9daaecd9abc /services
parent38cf8867a8d3e8d5159abd0bd0e6a3b0b8348b94 (diff)
downloadframeworks_base-27358a69b33eaa268ee75ef778ec824c8085adcc.zip
frameworks_base-27358a69b33eaa268ee75ef778ec824c8085adcc.tar.gz
frameworks_base-27358a69b33eaa268ee75ef778ec824c8085adcc.tar.bz2
Only allow 8 OBBs to be mounted by a UID
Change-Id: I4f017c5408af903c6c9ba007a2cf7f488a7fcd27
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/MountService.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java
index ea280a5..62a9894 100644
--- a/services/java/com/android/server/MountService.java
+++ b/services/java/com/android/server/MountService.java
@@ -76,6 +76,8 @@ class MountService extends IMountService.Stub
private static final String VOLD_TAG = "VoldConnector";
+ protected static final int MAX_OBBS = 8;
+
/*
* Internal vold volume state constants
*/
@@ -154,6 +156,7 @@ class MountService extends IMountService.Stub
* Mounted OBB tracking information. Used to track the current state of all
* OBBs.
*/
+ final private Map<Integer, Integer> mObbUidUsage = new HashMap<Integer, Integer>();
final private Map<IObbActionListener, List<ObbState>> mObbMounts = new HashMap<IObbActionListener, List<ObbState>>();
final private Map<String, ObbState> mObbPathToStateMap = new HashMap<String, ObbState>();
@@ -1576,6 +1579,12 @@ class MountService extends IMountService.Stub
}
final int callerUid = Binder.getCallingUid();
+
+ final Integer uidUsage = mObbUidUsage.get(callerUid);
+ if (uidUsage != null && uidUsage > MAX_OBBS) {
+ throw new IllegalStateException("Maximum number of OBBs mounted!");
+ }
+
obbState = new ObbState(filename, token, callerUid);
addObbState(obbState);
}
@@ -1637,6 +1646,15 @@ class MountService extends IMountService.Stub
}
obbStates.add(obbState);
mObbPathToStateMap.put(obbState.filename, obbState);
+
+ // Track the number of OBBs used by this UID.
+ final int uid = obbState.callerUid;
+ final Integer uidUsage = mObbUidUsage.get(uid);
+ if (uidUsage == null) {
+ mObbUidUsage.put(uid, 1);
+ } else {
+ mObbUidUsage.put(uid, uidUsage + 1);
+ }
}
}
@@ -1650,6 +1668,20 @@ class MountService extends IMountService.Stub
mObbMounts.remove(obbState.token);
}
mObbPathToStateMap.remove(obbState.filename);
+
+ // Track the number of OBBs used by this UID.
+ final int uid = obbState.callerUid;
+ final Integer uidUsage = mObbUidUsage.get(uid);
+ if (uidUsage == null) {
+ Slog.e(TAG, "Called removeObbState for UID that isn't in map: " + uid);
+ } else {
+ final int newUsage = uidUsage - 1;
+ if (newUsage == 0) {
+ mObbUidUsage.remove(uid);
+ } else {
+ mObbUidUsage.put(uid, newUsage);
+ }
+ }
}
}