diff options
| author | Dianne Hackborn <hackbod@google.com> | 2015-05-15 16:36:12 -0700 |
|---|---|---|
| committer | Dianne Hackborn <hackbod@google.com> | 2015-05-18 18:13:41 -0700 |
| commit | d23e0d6901935588f9472bd7073fea0009581e9b (patch) | |
| tree | 7ac9c5d0ddcb1fe5dbf8fc204f69dfcf0bf7f197 /core/java/android/util/SparseArray.java | |
| parent | d5538758af0f6fea0695d3682e9aad2613ab9192 (diff) | |
Update power manager to track uid state like netstats.
To follow the correct semantics for when restricts due to
device idle can be applied, power manager need to know about
uid process states like net policy so that it can allow
wake locks from apps that are in the foreground.
Since this is being added to a second place, I reworked things
so that the activity manager now keeps track of per-uid process
states and allows apps to register to listen to those, rather
than having to track lower-level process states and transform
them into an overall uid state. Both net policy and power
manager use this new facility.
Change-Id: I77359164c40d0f36fe1ef296dd9f9c3062431148
Diffstat (limited to 'core/java/android/util/SparseArray.java')
| -rw-r--r-- | core/java/android/util/SparseArray.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/core/java/android/util/SparseArray.java b/core/java/android/util/SparseArray.java index 92e874f8711c..dc965edd7fad 100644 --- a/core/java/android/util/SparseArray.java +++ b/core/java/android/util/SparseArray.java @@ -134,6 +134,24 @@ public class SparseArray<E> implements Cloneable { } /** + * @hide + * Removes the mapping from the specified key, if there was any, returning the old value. + */ + public E removeReturnOld(int key) { + int i = ContainerHelpers.binarySearch(mKeys, mSize, key); + + if (i >= 0) { + if (mValues[i] != DELETED) { + final E old = (E) mValues[i]; + mValues[i] = DELETED; + mGarbage = true; + return old; + } + } + return null; + } + + /** * Alias for {@link #delete(int)}. */ public void remove(int key) { |
