Get rid of a race in NsdService in stopResolveService and getAddrInfo

Both requests are made using same id; and there is a chance that
stopResolve() is not fully completed when getAddrInfo() is issued. That
results getAddrInfo() failure, because both are using same requestId.

This change fixes this problem by creating a new unique id to call
getAddrInfo() with.

Bug: 11597153
Change-Id: I56bd78740e8a40bd31c52705dc797486aff53a50
diff --git a/services/java/com/android/server/ b/services/java/com/android/server/
index e0f415b..16d2468 100644
--- a/services/java/com/android/server/
+++ b/services/java/com/android/server/
@@ -483,10 +483,14 @@
-                        if (!getAddrInfo(id, cooked[3])) {
+                        removeRequestMap(clientId, id, clientInfo);
+                        int id2 = getUniqueId();
+                        if (getAddrInfo(id2, cooked[3])) {
+                            storeRequestMap(clientId, id2, clientInfo);
+                        } else {
                                     NsdManager.FAILURE_INTERNAL_ERROR, clientId);
-                            removeRequestMap(clientId, id, clientInfo);
                             clientInfo.mResolvedService = null;