Revert "Revert "[AC] Fix NPE. If the client sends multiple unregister requests at the same time, the client request could be null before the next request is processed.""

This reverts commit f470e292d8.

Reason for revert: Fixed warning from presubmit

Change-Id: I3e1ea17a2e149b548885666d9e8418647b96439e
This commit is contained in:
Kathy Chen
2023-05-08 23:23:16 +00:00
parent efa32a9b8f
commit b93d2ce0d3

View File

@@ -56,11 +56,11 @@ import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.concurrent.ConcurrentHashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
/**
* System service for managing {@link AmbientContextEvent}s.
@@ -602,7 +602,7 @@ public class AmbientContextManagerService extends
synchronized (mLock) {
for (ClientRequest cr : mExistingClientRequests) {
if (cr.getPackageName().equals(callingPackage)) {
if ((cr != null) && cr.getPackageName().equals(callingPackage)) {
AmbientContextManagerPerUserService service =
getAmbientContextManagerPerUserServiceForEventTypes(
UserHandle.getCallingUserId(),