summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2017-08-09 19:24:16 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2017-08-09 19:24:16 +0000
commit33e014b9bc0b609a8b6498bccf36536f3e0c5557 (patch)
treefcb17b81562c8979c7fe9335c1576e89b211cc56
parentfc596b1cf69cd740337392b7bc8384302d3b58b0 (diff)
parentfb3ab2ac48ceb4aea40d3f9ddf1bf2db7034ecdc (diff)
Merge "Fix race condition in binder thread" into oc-dr1-dev
-rw-r--r--services/core/java/com/android/server/wallpaper/WallpaperManagerService.java52
1 files changed, 26 insertions, 26 deletions
diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
index af90eeae4fdb..e0ad8f5d1100 100644
--- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
+++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
@@ -115,6 +115,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
@@ -376,40 +377,39 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
private void notifyColorListeners(@NonNull WallpaperColors wallpaperColors, int which,
int userId) {
final IWallpaperManagerCallback keyguardListener;
- final RemoteCallbackList<IWallpaperManagerCallback> currentUserColorListeners;
- final RemoteCallbackList<IWallpaperManagerCallback> userAllColorListeners;
+ final ArrayList<IWallpaperManagerCallback> colorListeners = new ArrayList<>();
synchronized (mLock) {
- currentUserColorListeners = mColorsChangedListeners.get(userId);
- userAllColorListeners = mColorsChangedListeners.get(UserHandle.USER_ALL);
+ final RemoteCallbackList<IWallpaperManagerCallback> currentUserColorListeners =
+ mColorsChangedListeners.get(userId);
+ final RemoteCallbackList<IWallpaperManagerCallback> userAllColorListeners =
+ mColorsChangedListeners.get(UserHandle.USER_ALL);
keyguardListener = mKeyguardListener;
- }
- if (currentUserColorListeners != null) {
- int count = currentUserColorListeners.beginBroadcast();
- for (int i = 0; i < count; i++) {
- try {
- currentUserColorListeners.getBroadcastItem(i)
- .onWallpaperColorsChanged(wallpaperColors, which, userId);
- } catch (RemoteException e) {
- // Callback is gone, it's not necessary to unregister it since
- // RemoteCallbackList#getBroadcastItem will take care of it.
+ if (currentUserColorListeners != null) {
+ final int count = currentUserColorListeners.beginBroadcast();
+ for (int i = 0; i < count; i++) {
+ colorListeners.add(currentUserColorListeners.getBroadcastItem(i));
}
+ currentUserColorListeners.finishBroadcast();
}
- currentUserColorListeners.finishBroadcast();
- }
- if (userAllColorListeners != null) {
- int count = userAllColorListeners.beginBroadcast();
- for (int i = 0; i < count; i++) {
- try {
- userAllColorListeners.getBroadcastItem(i)
- .onWallpaperColorsChanged(wallpaperColors, which, userId);
- } catch (RemoteException e) {
- // Callback is gone, it's not necessary to unregister it since
- // RemoteCallbackList#getBroadcastItem will take care of it.
+ if (userAllColorListeners != null) {
+ final int count = userAllColorListeners.beginBroadcast();
+ for (int i = 0; i < count; i++) {
+ colorListeners.add(userAllColorListeners.getBroadcastItem(i));
}
+ userAllColorListeners.finishBroadcast();
+ }
+ }
+
+ final int count = colorListeners.size();
+ for (int i = 0; i < count; i++) {
+ try {
+ colorListeners.get(i).onWallpaperColorsChanged(wallpaperColors, which, userId);
+ } catch (RemoteException e) {
+ // Callback is gone, it's not necessary to unregister it since
+ // RemoteCallbackList#getBroadcastItem will take care of it.
}
- userAllColorListeners.finishBroadcast();
}
if (keyguardListener != null) {