diff options
| author | 2019-11-04 00:13:53 -0800 | |
|---|---|---|
| committer | 2019-11-04 00:13:53 -0800 | |
| commit | d4d27b403cde9f85942fbecc0de2b7cdb4caa53d (patch) | |
| tree | ef43283a381b06454507a168399a7177b9ba6e6f | |
| parent | 23c8673670bc1146f96de3acb152865c05cd5731 (diff) | |
| parent | ef6fe13c77fc95b3b284c19ba4090a6cdf038c67 (diff) | |
Merge "Don't hold sProxyLock while retrieving interface descriptors."
am: ef6fe13c77
Change-Id: Ie54978b2f19e42c47992e04c2f41c55d8c61df5b
| -rw-r--r-- | core/java/android/os/BinderProxy.java | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/core/java/android/os/BinderProxy.java b/core/java/android/os/BinderProxy.java index 97c0a13e7a2b..c35b05f10498 100644 --- a/core/java/android/os/BinderProxy.java +++ b/core/java/android/os/BinderProxy.java @@ -241,31 +241,36 @@ public final class BinderProxy implements IBinder { } Map<String, Integer> counts = new HashMap<>(); - for (ArrayList<WeakReference<BinderProxy>> a : mMainIndexValues) { - if (a != null) { - for (WeakReference<BinderProxy> weakRef : a) { - BinderProxy bp = weakRef.get(); - String key; - if (bp == null) { - key = "<cleared weak-ref>"; - } else { - try { - key = bp.getInterfaceDescriptor(); - if ((key == null || key.isEmpty()) && !bp.isBinderAlive()) { - key = "<proxy to dead node>"; - } - } catch (Throwable t) { - key = "<exception during getDescriptor>"; - } - } - Integer i = counts.get(key); - if (i == null) { - counts.put(key, 1); - } else { - counts.put(key, i + 1); + final ArrayList<WeakReference<BinderProxy>> proxiesToQuery = + new ArrayList<WeakReference<BinderProxy>>(); + synchronized (sProxyMap) { + for (ArrayList<WeakReference<BinderProxy>> a : mMainIndexValues) { + if (a != null) { + proxiesToQuery.addAll(a); + } + } + } + for (WeakReference<BinderProxy> weakRef : proxiesToQuery) { + BinderProxy bp = weakRef.get(); + String key; + if (bp == null) { + key = "<cleared weak-ref>"; + } else { + try { + key = bp.getInterfaceDescriptor(); + if ((key == null || key.isEmpty()) && !bp.isBinderAlive()) { + key = "<proxy to dead node>"; } + } catch (Throwable t) { + key = "<exception during getDescriptor>"; } } + Integer i = counts.get(key); + if (i == null) { + counts.put(key, 1); + } else { + counts.put(key, i + 1); + } } Map.Entry<String, Integer>[] sorted = counts.entrySet().toArray( new Map.Entry[counts.size()]); @@ -354,9 +359,7 @@ public final class BinderProxy implements IBinder { * @hide */ public static InterfaceCount[] getSortedInterfaceCounts(int num) { - synchronized (sProxyMap) { - return sProxyMap.getSortedInterfaceCounts(num); - } + return sProxyMap.getSortedInterfaceCounts(num); } /** @@ -376,10 +379,8 @@ public final class BinderProxy implements IBinder { */ public static void dumpProxyDebugInfo() { if (Build.IS_DEBUGGABLE) { - synchronized (sProxyMap) { - sProxyMap.dumpProxyInterfaceCounts(); - sProxyMap.dumpPerUidProxyCounts(); - } + sProxyMap.dumpProxyInterfaceCounts(); + sProxyMap.dumpPerUidProxyCounts(); } } |