Loading services/core/java/com/android/server/timedetector/ServerFlags.java +11 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,9 @@ import java.lang.annotation.Target; import java.time.DateTimeException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; Loading Loading @@ -211,7 +213,11 @@ public final class ServerFlags { } private void handlePropertiesChanged(@NonNull DeviceConfig.Properties properties) { // Copy the listeners to notify under the "mListeners" lock but don't hold the lock while // delivering the notifications to avoid deadlocks. List<StateChangeListener> listenersToNotify; synchronized (mListeners) { listenersToNotify = new ArrayList<>(mListeners.size()); for (Map.Entry<StateChangeListener, HashSet<String>> listenerEntry : mListeners.entrySet()) { // It's unclear which set of the following two Sets is going to be larger in the Loading @@ -225,10 +231,14 @@ public final class ServerFlags { HashSet<String> monitoredKeys = listenerEntry.getValue(); Iterable<String> modifiedKeys = properties.getKeyset(); if (containsAny(monitoredKeys, modifiedKeys)) { listenerEntry.getKey().onChange(); listenersToNotify.add(listenerEntry.getKey()); } } } for (StateChangeListener listener : listenersToNotify) { listener.onChange(); } } private static boolean containsAny( Loading services/core/java/com/android/server/timedetector/ServiceConfigAccessorImpl.java +8 −2 Original line number Diff line number Diff line Loading @@ -166,8 +166,14 @@ final class ServiceConfigAccessorImpl implements ServiceConfigAccessor { } } private synchronized void handleConfigurationInternalChangeOnMainThread() { for (StateChangeListener changeListener : mConfigurationInternalListeners) { private void handleConfigurationInternalChangeOnMainThread() { // Copy the listeners holding the "this" lock but don't hold the lock while delivering the // notifications to avoid deadlocks. List<StateChangeListener> configurationInternalListeners; synchronized (this) { configurationInternalListeners = new ArrayList<>(this.mConfigurationInternalListeners); } for (StateChangeListener changeListener : configurationInternalListeners) { changeListener.onChange(); } } Loading services/core/java/com/android/server/timedetector/TimeDetectorService.java +2 −0 Original line number Diff line number Diff line Loading @@ -266,6 +266,8 @@ public final class TimeDetectorService extends ITimeDetectorService.Stub for (int listenerIndex = 0; listenerIndex < listenerCount; listenerIndex++) { ITimeDetectorListener listener = mListeners.valueAt(listenerIndex); try { // No need to surrender the mListeners lock while doing this: // ITimeDetectorListener is declared "oneway". listener.onChange(); } catch (RemoteException e) { Slog.w(TAG, "Unable to notify listener=" + listener, e); Loading services/core/java/com/android/server/timezonedetector/DeviceActivityMonitorImpl.java +8 −2 Original line number Diff line number Diff line Loading @@ -77,12 +77,18 @@ class DeviceActivityMonitorImpl implements DeviceActivityMonitor { mListeners.add(listener); } private synchronized void notifyFlightComplete() { private void notifyFlightComplete() { if (DBG) { Slog.d(LOG_TAG, "notifyFlightComplete"); } for (Listener listener : mListeners) { // Copy the listeners holding the "this" lock but don't hold the lock while delivering the // notifications to avoid deadlocks. List<Listener> listeners; synchronized (this) { listeners = new ArrayList<>(mListeners); } for (Listener listener : listeners) { listener.onFlightComplete(); } } Loading services/core/java/com/android/server/timezonedetector/ServiceConfigAccessorImpl.java +8 −2 Original line number Diff line number Diff line Loading @@ -205,8 +205,14 @@ public final class ServiceConfigAccessorImpl implements ServiceConfigAccessor { } } private synchronized void handleConfigurationInternalChangeOnMainThread() { for (StateChangeListener changeListener : mConfigurationInternalListeners) { private void handleConfigurationInternalChangeOnMainThread() { // Copy the listeners holding the "this" lock but don't hold the lock while delivering the // notifications to avoid deadlocks. List<StateChangeListener> configurationInternalListeners; synchronized (this) { configurationInternalListeners = new ArrayList<>(this.mConfigurationInternalListeners); } for (StateChangeListener changeListener : configurationInternalListeners) { changeListener.onChange(); } } Loading Loading
services/core/java/com/android/server/timedetector/ServerFlags.java +11 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,9 @@ import java.lang.annotation.Target; import java.time.DateTimeException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; Loading Loading @@ -211,7 +213,11 @@ public final class ServerFlags { } private void handlePropertiesChanged(@NonNull DeviceConfig.Properties properties) { // Copy the listeners to notify under the "mListeners" lock but don't hold the lock while // delivering the notifications to avoid deadlocks. List<StateChangeListener> listenersToNotify; synchronized (mListeners) { listenersToNotify = new ArrayList<>(mListeners.size()); for (Map.Entry<StateChangeListener, HashSet<String>> listenerEntry : mListeners.entrySet()) { // It's unclear which set of the following two Sets is going to be larger in the Loading @@ -225,10 +231,14 @@ public final class ServerFlags { HashSet<String> monitoredKeys = listenerEntry.getValue(); Iterable<String> modifiedKeys = properties.getKeyset(); if (containsAny(monitoredKeys, modifiedKeys)) { listenerEntry.getKey().onChange(); listenersToNotify.add(listenerEntry.getKey()); } } } for (StateChangeListener listener : listenersToNotify) { listener.onChange(); } } private static boolean containsAny( Loading
services/core/java/com/android/server/timedetector/ServiceConfigAccessorImpl.java +8 −2 Original line number Diff line number Diff line Loading @@ -166,8 +166,14 @@ final class ServiceConfigAccessorImpl implements ServiceConfigAccessor { } } private synchronized void handleConfigurationInternalChangeOnMainThread() { for (StateChangeListener changeListener : mConfigurationInternalListeners) { private void handleConfigurationInternalChangeOnMainThread() { // Copy the listeners holding the "this" lock but don't hold the lock while delivering the // notifications to avoid deadlocks. List<StateChangeListener> configurationInternalListeners; synchronized (this) { configurationInternalListeners = new ArrayList<>(this.mConfigurationInternalListeners); } for (StateChangeListener changeListener : configurationInternalListeners) { changeListener.onChange(); } } Loading
services/core/java/com/android/server/timedetector/TimeDetectorService.java +2 −0 Original line number Diff line number Diff line Loading @@ -266,6 +266,8 @@ public final class TimeDetectorService extends ITimeDetectorService.Stub for (int listenerIndex = 0; listenerIndex < listenerCount; listenerIndex++) { ITimeDetectorListener listener = mListeners.valueAt(listenerIndex); try { // No need to surrender the mListeners lock while doing this: // ITimeDetectorListener is declared "oneway". listener.onChange(); } catch (RemoteException e) { Slog.w(TAG, "Unable to notify listener=" + listener, e); Loading
services/core/java/com/android/server/timezonedetector/DeviceActivityMonitorImpl.java +8 −2 Original line number Diff line number Diff line Loading @@ -77,12 +77,18 @@ class DeviceActivityMonitorImpl implements DeviceActivityMonitor { mListeners.add(listener); } private synchronized void notifyFlightComplete() { private void notifyFlightComplete() { if (DBG) { Slog.d(LOG_TAG, "notifyFlightComplete"); } for (Listener listener : mListeners) { // Copy the listeners holding the "this" lock but don't hold the lock while delivering the // notifications to avoid deadlocks. List<Listener> listeners; synchronized (this) { listeners = new ArrayList<>(mListeners); } for (Listener listener : listeners) { listener.onFlightComplete(); } } Loading
services/core/java/com/android/server/timezonedetector/ServiceConfigAccessorImpl.java +8 −2 Original line number Diff line number Diff line Loading @@ -205,8 +205,14 @@ public final class ServiceConfigAccessorImpl implements ServiceConfigAccessor { } } private synchronized void handleConfigurationInternalChangeOnMainThread() { for (StateChangeListener changeListener : mConfigurationInternalListeners) { private void handleConfigurationInternalChangeOnMainThread() { // Copy the listeners holding the "this" lock but don't hold the lock while delivering the // notifications to avoid deadlocks. List<StateChangeListener> configurationInternalListeners; synchronized (this) { configurationInternalListeners = new ArrayList<>(this.mConfigurationInternalListeners); } for (StateChangeListener changeListener : configurationInternalListeners) { changeListener.onChange(); } } Loading