Synchronize reads of static members.
Bug: 27830968
Change-Id: I2308a8b90c57a25270fca185d6ac2a61e9def1ef
diff --git a/v4/java/android/support/v4/app/NotificationManagerCompat.java b/v4/java/android/support/v4/app/NotificationManagerCompat.java
index 8a6c639..de484e9 100644
--- a/v4/java/android/support/v4/app/NotificationManagerCompat.java
+++ b/v4/java/android/support/v4/app/NotificationManagerCompat.java
@@ -331,23 +331,23 @@
final String enabledNotificationListeners = Settings.Secure.getString(
context.getContentResolver(),
SETTING_ENABLED_NOTIFICATION_LISTENERS);
- // Parse the string again if it is different from the last time this method was called.
- if (enabledNotificationListeners != null
- && !enabledNotificationListeners.equals(sEnabledNotificationListeners)) {
- final String[] components = enabledNotificationListeners.split(":");
- Set<String> packageNames = new HashSet<String>(components.length);
- for (String component : components) {
- ComponentName componentName = ComponentName.unflattenFromString(component);
- if (componentName != null) {
- packageNames.add(componentName.getPackageName());
+ synchronized (sEnabledNotificationListenersLock) {
+ // Parse the string again if it is different from the last time this method was called.
+ if (enabledNotificationListeners != null
+ && !enabledNotificationListeners.equals(sEnabledNotificationListeners)) {
+ final String[] components = enabledNotificationListeners.split(":");
+ Set<String> packageNames = new HashSet<String>(components.length);
+ for (String component : components) {
+ ComponentName componentName = ComponentName.unflattenFromString(component);
+ if (componentName != null) {
+ packageNames.add(componentName.getPackageName());
+ }
}
- }
- synchronized (sEnabledNotificationListenersLock) {
sEnabledNotificationListenerPackages = packageNames;
sEnabledNotificationListeners = enabledNotificationListeners;
}
+ return sEnabledNotificationListenerPackages;
}
- return sEnabledNotificationListenerPackages;
}
/**
@@ -366,8 +366,8 @@
if (sSideChannelManager == null) {
sSideChannelManager = new SideChannelManager(mContext.getApplicationContext());
}
+ sSideChannelManager.queueTask(task);
}
- sSideChannelManager.queueTask(task);
}
/**