Merge "Add some missing synchronization"

This commit is contained in:
Julia Reynolds
2018-08-30 13:29:12 +00:00
committed by Android (Google) Code Review
2 changed files with 26 additions and 18 deletions

View File

@@ -279,11 +279,13 @@ public class ConditionProviders extends ManagedServices {
public void ensureRecordExists(ComponentName component, Uri conditionId,
IConditionProvider provider) {
// constructed by convention, make sure the record exists...
final ConditionRecord r = getRecordLocked(conditionId, component, true /*create*/);
if (r.info == null) {
// ... and is associated with the in-process service
r.info = checkServiceTokenLocked(provider);
synchronized (mMutex) {
// constructed by convention, make sure the record exists...
final ConditionRecord r = getRecordLocked(conditionId, component, true /*create*/);
if (r.info == null) {
// ... and is associated with the in-process service
r.info = checkServiceTokenLocked(provider);
}
}
}

View File

@@ -216,12 +216,14 @@ abstract public class ManagedServices {
}
pw.println(" Live " + getCaption() + "s (" + mServices.size() + "):");
for (ManagedServiceInfo info : mServices) {
if (filter != null && !filter.matches(info.component)) continue;
pw.println(" " + info.component
+ " (user " + info.userid + "): " + info.service
+ (info.isSystem?" SYSTEM":"")
+ (info.isGuest(this)?" GUEST":""));
synchronized (mMutex) {
for (ManagedServiceInfo info : mServices) {
if (filter != null && !filter.matches(info.component)) continue;
pw.println(" " + info.component
+ " (user " + info.userid + "): " + info.service
+ (info.isSystem ? " SYSTEM" : "")
+ (info.isGuest(this) ? " GUEST" : ""));
}
}
pw.println(" Snoozed " + getCaption() + "s (" +
@@ -260,9 +262,11 @@ abstract public class ManagedServices {
cmpt.writeToProto(proto, ManagedServicesProto.ENABLED);
}
for (ManagedServiceInfo info : mServices) {
if (filter != null && !filter.matches(info.component)) continue;
info.writeToProto(proto, ManagedServicesProto.LIVE_SERVICES, this);
synchronized (mMutex) {
for (ManagedServiceInfo info : mServices) {
if (filter != null && !filter.matches(info.component)) continue;
info.writeToProto(proto, ManagedServicesProto.LIVE_SERVICES, this);
}
}
for (ComponentName name : mSnoozingForCurrentProfiles) {
@@ -631,11 +635,13 @@ abstract public class ManagedServices {
public boolean isSameUser(IInterface service, int userId) {
checkNotNull(service);
ManagedServiceInfo info = getServiceFromTokenLocked(service);
if (info != null) {
return info.isSameUser(userId);
synchronized (mMutex) {
ManagedServiceInfo info = getServiceFromTokenLocked(service);
if (info != null) {
return info.isSameUser(userId);
}
return false;
}
return false;
}
public void unregisterService(IInterface service, int userid) {