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
(cherry picked from commit b93d2ce0d3)
Bug: 278891267
Test: make
This commit is contained in:
Kathy Chen
2023-05-08 23:23:16 +00:00
parent 7981d137dc
commit b43fbe2aab

View File

@@ -60,6 +60,7 @@ 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.
@@ -595,7 +596,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(),