Lock access to managed services.

Fixes: 35873807
Test: manual, set a notification to enqueue once a second for a few
minutes while also repeatedly granting and denying notification listener
access to a couple of apps in Settings and verifying
that nothing crashes and log is clean.

Change-Id: I15f429d61bf5f9ad639e524a94288a6d2db2cb56
This commit is contained in:
Julia Reynolds
2017-04-14 10:01:24 -04:00
parent 7c8ab2651b
commit 00314d97e9
3 changed files with 11 additions and 11 deletions

View File

@@ -251,7 +251,7 @@ public class ConditionProviders extends ManagedServices {
public IConditionProvider findConditionProvider(ComponentName component) {
if (component == null) return null;
for (ManagedServiceInfo service : mServices) {
for (ManagedServiceInfo service : getServices()) {
if (component.equals(service.component)) {
return provider(service);
}

View File

@@ -90,7 +90,7 @@ abstract public class ManagedServices {
// contains connections to all connected services, including app services
// and system services
protected final ArrayList<ManagedServiceInfo> mServices = new ArrayList<ManagedServiceInfo>();
private final ArrayList<ManagedServiceInfo> mServices = new ArrayList<ManagedServiceInfo>();
// things that will be put into mServices as soon as they're ready
private final ArrayList<String> mServicesBinding = new ArrayList<String>();
// lists the component names of all enabled (and therefore potentially connected)

View File

@@ -4783,7 +4783,7 @@ public class NotificationManagerService extends SystemService {
// There should be only one, but it's a list, so while we enforce
// singularity elsewhere, we keep it general here, to avoid surprises.
for (final ManagedServiceInfo info : NotificationAssistants.this.mServices) {
for (final ManagedServiceInfo info : NotificationAssistants.this.getServices()) {
boolean sbnVisible = isVisibleToListener(sbn, info);
if (!sbnVisible) {
continue;
@@ -4819,7 +4819,7 @@ public class NotificationManagerService extends SystemService {
public void notifyAssistantSnoozedLocked(final StatusBarNotification sbn,
final String snoozeCriterionId) {
TrimCache trimCache = new TrimCache(sbn);
for (final ManagedServiceInfo info : mServices) {
for (final ManagedServiceInfo info : getServices()) {
final StatusBarNotification sbnToPost = trimCache.ForListener(info);
mHandler.post(new Runnable() {
@Override
@@ -4840,7 +4840,7 @@ public class NotificationManagerService extends SystemService {
}
public boolean isEnabled() {
return !mServices.isEmpty();
return !getServices().isEmpty();
}
}
@@ -4920,7 +4920,7 @@ public class NotificationManagerService extends SystemService {
// Lazily initialized snapshots of the notification.
TrimCache trimCache = new TrimCache(sbn);
for (final ManagedServiceInfo info : mServices) {
for (final ManagedServiceInfo info : getServices()) {
boolean sbnVisible = isVisibleToListener(sbn, info);
boolean oldSbnVisible = oldSbn != null ? isVisibleToListener(oldSbn, info) : false;
// This notification hasn't been and still isn't visible -> ignore.
@@ -4959,7 +4959,7 @@ public class NotificationManagerService extends SystemService {
// NOTE: this copy is lightweight: it doesn't include heavyweight parts of the
// notification
final StatusBarNotification sbnLight = sbn.cloneLight();
for (final ManagedServiceInfo info : mServices) {
for (final ManagedServiceInfo info : getServices()) {
if (!isVisibleToListener(sbn, info)) {
continue;
}
@@ -4977,7 +4977,7 @@ public class NotificationManagerService extends SystemService {
* asynchronously notify all listeners about a reordering of notifications
*/
public void notifyRankingUpdateLocked() {
for (final ManagedServiceInfo serviceInfo : mServices) {
for (final ManagedServiceInfo serviceInfo : getServices()) {
if (!serviceInfo.isEnabledForCurrentProfiles()) {
continue;
}
@@ -4992,7 +4992,7 @@ public class NotificationManagerService extends SystemService {
}
public void notifyListenerHintsChangedLocked(final int hints) {
for (final ManagedServiceInfo serviceInfo : mServices) {
for (final ManagedServiceInfo serviceInfo : getServices()) {
if (!serviceInfo.isEnabledForCurrentProfiles()) {
continue;
}
@@ -5006,7 +5006,7 @@ public class NotificationManagerService extends SystemService {
}
public void notifyInterruptionFilterChanged(final int interruptionFilter) {
for (final ManagedServiceInfo serviceInfo : mServices) {
for (final ManagedServiceInfo serviceInfo : getServices()) {
if (!serviceInfo.isEnabledForCurrentProfiles()) {
continue;
}
@@ -5145,7 +5145,7 @@ public class NotificationManagerService extends SystemService {
}
// TODO: clean up locking object later
synchronized (mNotificationLock) {
for (final ManagedServiceInfo serviceInfo : mServices) {
for (final ManagedServiceInfo serviceInfo : getServices()) {
if (packageName.equals(serviceInfo.component.getPackageName())) {
return true;
}