Replace @hide APIs

NSD associated files are going to move into connectivity
mainline module in T, so need convert all hidden APIs to formal
API surfaces.

- Replace Slog with Log
- Remove useless implements Watchdog.Monitor
- Replace Build.IS_DEBUGGABLE with Build.isDebuggable()
- Replace Preconditions.checkState90 by checking null directly.
- Replace Lists.newArrayList() by new ArrayList<>()
- Replace DumpUtils.checkDumpPermission() by checking DUMP
  permission directly.

Bug: 206702844
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I6bc478b852c10591959d9e0615af63e675532abe
This commit is contained in:
paulhu
2021-11-17 09:35:33 +08:00
parent 73a8203a9d
commit b222570f37
3 changed files with 59 additions and 59 deletions

View File

@@ -26,12 +26,10 @@ import android.os.PowerManager;
import android.os.SystemClock; import android.os.SystemClock;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.util.LocalLog; import android.util.LocalLog;
import android.util.Slog; import android.util.Log;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.Preconditions;
import com.android.server.power.ShutdownThread; import com.android.server.power.ShutdownThread;
import com.google.android.collect.Lists;
import java.io.FileDescriptor; import java.io.FileDescriptor;
import java.io.IOException; import java.io.IOException;
@@ -40,19 +38,19 @@ import java.io.OutputStream;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicInteger; import java.util.LinkedList;
import java.util.Objects;
import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue; import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.LinkedList; import java.util.concurrent.atomic.AtomicInteger;
import java.util.Objects;
/** /**
* Generic connector class for interfacing with a native daemon which uses the * Generic connector class for interfacing with a native daemon which uses the
* {@code libsysutils} FrameworkListener protocol. * {@code libsysutils} FrameworkListener protocol.
*/ */
final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdog.Monitor { final class NativeDaemonConnector implements Runnable, Handler.Callback {
private final static boolean VDBG = false; private final static boolean VDBG = false;
private final String TAG; private final String TAG;
@@ -107,7 +105,7 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
/** /**
* Enable Set debugging mode, which causes messages to also be written to both * Enable Set debugging mode, which causes messages to also be written to both
* {@link Slog} in addition to internal log. * {@link Log} in addition to internal log.
*/ */
public void setDebug(boolean debug) { public void setDebug(boolean debug) {
mDebug = debug; mDebug = debug;
@@ -126,7 +124,9 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
* calls while holding a lock on the given object. * calls while holding a lock on the given object.
*/ */
public void setWarnIfHeld(Object warnIfHeld) { public void setWarnIfHeld(Object warnIfHeld) {
Preconditions.checkState(mWarnIfHeld == null); if (mWarnIfHeld != null) {
throw new IllegalStateException("warnIfHeld is already set.");
}
mWarnIfHeld = Objects.requireNonNull(warnIfHeld); mWarnIfHeld = Objects.requireNonNull(warnIfHeld);
} }
@@ -183,7 +183,7 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
// In order to ensure that unprivileged apps aren't able to impersonate native daemons on // In order to ensure that unprivileged apps aren't able to impersonate native daemons on
// production devices, even if said native daemons ill-advisedly pick a socket name that // production devices, even if said native daemons ill-advisedly pick a socket name that
// starts with __test__, only allow this on debug builds. // starts with __test__, only allow this on debug builds.
if (mSocket.startsWith("__test__") && Build.IS_DEBUGGABLE) { if (mSocket.startsWith("__test__") && Build.isDebuggable()) {
return new LocalSocketAddress(mSocket); return new LocalSocketAddress(mSocket);
} else { } else {
return new LocalSocketAddress(mSocket, LocalSocketAddress.Namespace.RESERVED); return new LocalSocketAddress(mSocket, LocalSocketAddress.Namespace.RESERVED);
@@ -375,7 +375,7 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
try { try {
latch.await(); latch.await();
} catch (InterruptedException e) { } catch (InterruptedException e) {
Slog.wtf(TAG, "Interrupted while waiting for unsolicited response handling", e); Log.wtf(TAG, "Interrupted while waiting for unsolicited response handling", e);
} }
} }
@@ -462,13 +462,13 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
public NativeDaemonEvent[] executeForList(long timeoutMs, String cmd, Object... args) public NativeDaemonEvent[] executeForList(long timeoutMs, String cmd, Object... args)
throws NativeDaemonConnectorException { throws NativeDaemonConnectorException {
if (mWarnIfHeld != null && Thread.holdsLock(mWarnIfHeld)) { if (mWarnIfHeld != null && Thread.holdsLock(mWarnIfHeld)) {
Slog.wtf(TAG, "Calling thread " + Thread.currentThread().getName() + " is holding 0x" Log.wtf(TAG, "Calling thread " + Thread.currentThread().getName() + " is holding 0x"
+ Integer.toHexString(System.identityHashCode(mWarnIfHeld)), new Throwable()); + Integer.toHexString(System.identityHashCode(mWarnIfHeld)), new Throwable());
} }
final long startTime = SystemClock.elapsedRealtime(); final long startTime = SystemClock.elapsedRealtime();
final ArrayList<NativeDaemonEvent> events = Lists.newArrayList(); final ArrayList<NativeDaemonEvent> events = new ArrayList<>();
final StringBuilder rawBuilder = new StringBuilder(); final StringBuilder rawBuilder = new StringBuilder();
final StringBuilder logBuilder = new StringBuilder(); final StringBuilder logBuilder = new StringBuilder();
@@ -571,7 +571,7 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
*/ */
public static class Command { public static class Command {
private String mCmd; private String mCmd;
private ArrayList<Object> mArguments = Lists.newArrayList(); private ArrayList<Object> mArguments = new ArrayList<>();
public Command(String cmd, Object... args) { public Command(String cmd, Object... args) {
mCmd = cmd; mCmd = cmd;
@@ -586,11 +586,6 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
} }
} }
/** {@inheritDoc} */
public void monitor() {
synchronized (mDaemonLock) { }
}
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
mLocalLog.dump(fd, pw, args); mLocalLog.dump(fd, pw, args);
pw.println(); pw.println();
@@ -598,12 +593,12 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
} }
private void log(String logstring) { private void log(String logstring) {
if (mDebug) Slog.d(TAG, logstring); if (mDebug) Log.d(TAG, logstring);
mLocalLog.log(logstring); mLocalLog.log(logstring);
} }
private void loge(String logstring) { private void loge(String logstring) {
Slog.e(TAG, logstring); Log.e(TAG, logstring);
mLocalLog.log(logstring); mLocalLog.log(logstring);
} }
@@ -659,12 +654,12 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
if (found == null) { if (found == null) {
// didn't find it - make sure our queue isn't too big before adding // didn't find it - make sure our queue isn't too big before adding
while (mPendingCmds.size() >= mMaxCount) { while (mPendingCmds.size() >= mMaxCount) {
Slog.e("NativeDaemonConnector.ResponseQueue", Log.e("NativeDaemonConnector.ResponseQueue",
"more buffered than allowed: " + mPendingCmds.size() + "more buffered than allowed: " + mPendingCmds.size() +
" >= " + mMaxCount); " >= " + mMaxCount);
// let any waiter timeout waiting for this // let any waiter timeout waiting for this
PendingCmd pendingCmd = mPendingCmds.remove(); PendingCmd pendingCmd = mPendingCmds.remove();
Slog.e("NativeDaemonConnector.ResponseQueue", Log.e("NativeDaemonConnector.ResponseQueue",
"Removing request: " + pendingCmd.logCmd + " (" + "Removing request: " + pendingCmd.logCmd + " (" +
pendingCmd.cmdNum + ")"); pendingCmd.cmdNum + ")");
} }
@@ -706,7 +701,7 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
result = found.responses.poll(timeoutMs, TimeUnit.MILLISECONDS); result = found.responses.poll(timeoutMs, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {} } catch (InterruptedException e) {}
if (result == null) { if (result == null) {
Slog.e("NativeDaemonConnector.ResponseQueue", "Timeout waiting for response"); Log.e("NativeDaemonConnector.ResponseQueue", "Timeout waiting for response");
} }
return result; return result;
} }

View File

@@ -16,8 +16,7 @@
package com.android.server; package com.android.server;
import android.util.Slog; import android.util.Log;
import com.google.android.collect.Lists;
import java.io.FileDescriptor; import java.io.FileDescriptor;
import java.util.ArrayList; import java.util.ArrayList;
@@ -179,7 +178,7 @@ public class NativeDaemonEvent {
* {@link #getMessage()} for any events matching the requested code. * {@link #getMessage()} for any events matching the requested code.
*/ */
public static String[] filterMessageList(NativeDaemonEvent[] events, int matchCode) { public static String[] filterMessageList(NativeDaemonEvent[] events, int matchCode) {
final ArrayList<String> result = Lists.newArrayList(); final ArrayList<String> result = new ArrayList<>();
for (NativeDaemonEvent event : events) { for (NativeDaemonEvent event : events) {
if (event.getCode() == matchCode) { if (event.getCode() == matchCode) {
result.add(event.getMessage()); result.add(event.getMessage());
@@ -212,7 +211,7 @@ public class NativeDaemonEvent {
int wordEnd = -1; int wordEnd = -1;
boolean quoted = false; boolean quoted = false;
if (DEBUG_ROUTINE) Slog.e(LOGTAG, "parsing '" + rawEvent + "'"); if (DEBUG_ROUTINE) Log.e(LOGTAG, "parsing '" + rawEvent + "'");
if (rawEvent.charAt(current) == '\"') { if (rawEvent.charAt(current) == '\"') {
quoted = true; quoted = true;
current++; current++;
@@ -240,14 +239,14 @@ public class NativeDaemonEvent {
word = word.replace("\\\\", "\\"); word = word.replace("\\\\", "\\");
word = word.replace("\\\"", "\""); word = word.replace("\\\"", "\"");
if (DEBUG_ROUTINE) Slog.e(LOGTAG, "found '" + word + "'"); if (DEBUG_ROUTINE) Log.e(LOGTAG, "found '" + word + "'");
parsed.add(word); parsed.add(word);
// find the beginning of the next word - either of these options // find the beginning of the next word - either of these options
int nextSpace = rawEvent.indexOf(' ', current); int nextSpace = rawEvent.indexOf(' ', current);
int nextQuote = rawEvent.indexOf(" \"", current); int nextQuote = rawEvent.indexOf(" \"", current);
if (DEBUG_ROUTINE) { if (DEBUG_ROUTINE) {
Slog.e(LOGTAG, "nextSpace=" + nextSpace + ", nextQuote=" + nextQuote); Log.e(LOGTAG, "nextSpace=" + nextSpace + ", nextQuote=" + nextQuote);
} }
if (nextQuote > -1 && nextQuote <= nextSpace) { if (nextQuote > -1 && nextQuote <= nextSpace) {
quoted = true; quoted = true;
@@ -259,8 +258,8 @@ public class NativeDaemonEvent {
} }
} // else we just start the next word after the current and read til the end } // else we just start the next word after the current and read til the end
if (DEBUG_ROUTINE) { if (DEBUG_ROUTINE) {
Slog.e(LOGTAG, "next loop - current=" + current + Log.e(LOGTAG, "next loop - current=" + current
", length=" + length + ", quoted=" + quoted); + ", length=" + length + ", quoted=" + quoted);
} }
} }
return parsed.toArray(new String[parsed.size()]); return parsed.toArray(new String[parsed.size()]);

View File

@@ -19,6 +19,7 @@ package com.android.server;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.ContentObserver; import android.database.ContentObserver;
import android.net.Uri; import android.net.Uri;
import android.net.nsd.INsdManager; import android.net.nsd.INsdManager;
@@ -36,12 +37,10 @@ import android.provider.Settings;
import android.util.Base64; import android.util.Base64;
import android.util.Log; import android.util.Log;
import android.util.Pair; import android.util.Pair;
import android.util.Slog;
import android.util.SparseArray; import android.util.SparseArray;
import android.util.SparseIntArray; import android.util.SparseIntArray;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.DumpUtils;
import com.android.internal.util.State; import com.android.internal.util.State;
import com.android.internal.util.StateMachine; import com.android.internal.util.StateMachine;
import com.android.net.module.util.DnsSdTxtRecord; import com.android.net.module.util.DnsSdTxtRecord;
@@ -228,7 +227,7 @@ public class NsdService extends INsdManager.Stub {
break; break;
case NsdManager.NATIVE_DAEMON_EVENT: case NsdManager.NATIVE_DAEMON_EVENT:
default: default:
Slog.e(TAG, "Unhandled " + msg); Log.e(TAG, "Unhandled " + msg);
return NOT_HANDLED; return NOT_HANDLED;
} }
return HANDLED; return HANDLED;
@@ -274,7 +273,7 @@ public class NsdService extends INsdManager.Stub {
private boolean requestLimitReached(ClientInfo clientInfo) { private boolean requestLimitReached(ClientInfo clientInfo) {
if (clientInfo.mClientIds.size() >= ClientInfo.MAX_LIMIT) { if (clientInfo.mClientIds.size() >= ClientInfo.MAX_LIMIT) {
if (DBG) Slog.d(TAG, "Exceeded max outstanding requests " + clientInfo); if (DBG) Log.d(TAG, "Exceeded max outstanding requests " + clientInfo);
return true; return true;
} }
return false; return false;
@@ -307,7 +306,7 @@ public class NsdService extends INsdManager.Stub {
transitionTo(mDisabledState); transitionTo(mDisabledState);
break; break;
case NsdManager.DISCOVER_SERVICES: case NsdManager.DISCOVER_SERVICES:
if (DBG) Slog.d(TAG, "Discover services"); if (DBG) Log.d(TAG, "Discover services");
args = (ListenerArgs) msg.obj; args = (ListenerArgs) msg.obj;
clientInfo = mClients.get(args.connector); clientInfo = mClients.get(args.connector);
@@ -321,8 +320,8 @@ public class NsdService extends INsdManager.Stub {
id = getUniqueId(); id = getUniqueId();
if (discoverServices(id, args.serviceInfo.getServiceType())) { if (discoverServices(id, args.serviceInfo.getServiceType())) {
if (DBG) { if (DBG) {
Slog.d(TAG, "Discover " + msg.arg2 + " " + id + Log.d(TAG, "Discover " + msg.arg2 + " " + id
args.serviceInfo.getServiceType()); + args.serviceInfo.getServiceType());
} }
storeRequestMap(clientId, id, clientInfo, msg.what); storeRequestMap(clientId, id, clientInfo, msg.what);
clientInfo.onDiscoverServicesStarted(clientId, args.serviceInfo); clientInfo.onDiscoverServicesStarted(clientId, args.serviceInfo);
@@ -333,7 +332,7 @@ public class NsdService extends INsdManager.Stub {
} }
break; break;
case NsdManager.STOP_DISCOVERY: case NsdManager.STOP_DISCOVERY:
if (DBG) Slog.d(TAG, "Stop service discovery"); if (DBG) Log.d(TAG, "Stop service discovery");
args = (ListenerArgs) msg.obj; args = (ListenerArgs) msg.obj;
clientInfo = mClients.get(args.connector); clientInfo = mClients.get(args.connector);
@@ -353,7 +352,7 @@ public class NsdService extends INsdManager.Stub {
} }
break; break;
case NsdManager.REGISTER_SERVICE: case NsdManager.REGISTER_SERVICE:
if (DBG) Slog.d(TAG, "Register service"); if (DBG) Log.d(TAG, "Register service");
args = (ListenerArgs) msg.obj; args = (ListenerArgs) msg.obj;
clientInfo = mClients.get(args.connector); clientInfo = mClients.get(args.connector);
if (requestLimitReached(clientInfo)) { if (requestLimitReached(clientInfo)) {
@@ -365,7 +364,7 @@ public class NsdService extends INsdManager.Stub {
maybeStartDaemon(); maybeStartDaemon();
id = getUniqueId(); id = getUniqueId();
if (registerService(id, args.serviceInfo)) { if (registerService(id, args.serviceInfo)) {
if (DBG) Slog.d(TAG, "Register " + clientId + " " + id); if (DBG) Log.d(TAG, "Register " + clientId + " " + id);
storeRequestMap(clientId, id, clientInfo, msg.what); storeRequestMap(clientId, id, clientInfo, msg.what);
// Return success after mDns reports success // Return success after mDns reports success
} else { } else {
@@ -375,11 +374,11 @@ public class NsdService extends INsdManager.Stub {
} }
break; break;
case NsdManager.UNREGISTER_SERVICE: case NsdManager.UNREGISTER_SERVICE:
if (DBG) Slog.d(TAG, "unregister service"); if (DBG) Log.d(TAG, "unregister service");
args = (ListenerArgs) msg.obj; args = (ListenerArgs) msg.obj;
clientInfo = mClients.get(args.connector); clientInfo = mClients.get(args.connector);
if (clientInfo == null) { if (clientInfo == null) {
Slog.e(TAG, "Unknown connector in unregistration"); Log.e(TAG, "Unknown connector in unregistration");
break; break;
} }
id = clientInfo.mClientIds.get(clientId); id = clientInfo.mClientIds.get(clientId);
@@ -392,7 +391,7 @@ public class NsdService extends INsdManager.Stub {
} }
break; break;
case NsdManager.RESOLVE_SERVICE: case NsdManager.RESOLVE_SERVICE:
if (DBG) Slog.d(TAG, "Resolve service"); if (DBG) Log.d(TAG, "Resolve service");
args = (ListenerArgs) msg.obj; args = (ListenerArgs) msg.obj;
clientInfo = mClients.get(args.connector); clientInfo = mClients.get(args.connector);
@@ -430,7 +429,7 @@ public class NsdService extends INsdManager.Stub {
ClientInfo clientInfo = mIdToClientInfoMap.get(id); ClientInfo clientInfo = mIdToClientInfoMap.get(id);
if (clientInfo == null) { if (clientInfo == null) {
String name = NativeResponseCode.nameOf(code); String name = NativeResponseCode.nameOf(code);
Slog.e(TAG, String.format("id %d for %s has no client mapping", id, name)); Log.e(TAG, String.format("id %d for %s has no client mapping", id, name));
return false; return false;
} }
@@ -441,14 +440,14 @@ public class NsdService extends INsdManager.Stub {
// SERVICE_FOUND may race with STOP_SERVICE_DISCOVERY, // SERVICE_FOUND may race with STOP_SERVICE_DISCOVERY,
// and we may get in this situation. // and we may get in this situation.
String name = NativeResponseCode.nameOf(code); String name = NativeResponseCode.nameOf(code);
Slog.d(TAG, String.format( Log.d(TAG, String.format(
"Notification %s for listener id %d that is no longer active", "Notification %s for listener id %d that is no longer active",
name, id)); name, id));
return false; return false;
} }
if (DBG) { if (DBG) {
String name = NativeResponseCode.nameOf(code); String name = NativeResponseCode.nameOf(code);
Slog.d(TAG, String.format("Native daemon message %s: %s", name, raw)); Log.d(TAG, String.format("Native daemon message %s: %s", name, raw));
} }
switch (code) { switch (code) {
case NativeResponseCode.SERVICE_FOUND: case NativeResponseCode.SERVICE_FOUND:
@@ -492,7 +491,7 @@ public class NsdService extends INsdManager.Stub {
++index; ++index;
} }
if (index >= cooked[2].length()) { if (index >= cooked[2].length()) {
Slog.e(TAG, "Invalid service found " + raw); Log.e(TAG, "Invalid service found " + raw);
break; break;
} }
String name = cooked[2].substring(0, index); String name = cooked[2].substring(0, index);
@@ -562,13 +561,13 @@ public class NsdService extends INsdManager.Stub {
char c = s.charAt(i); char c = s.charAt(i);
if (c == '\\') { if (c == '\\') {
if (++i >= s.length()) { if (++i >= s.length()) {
Slog.e(TAG, "Unexpected end of escape sequence in: " + s); Log.e(TAG, "Unexpected end of escape sequence in: " + s);
break; break;
} }
c = s.charAt(i); c = s.charAt(i);
if (c != '.' && c != '\\') { if (c != '.' && c != '\\') {
if (i + 2 >= s.length()) { if (i + 2 >= s.length()) {
Slog.e(TAG, "Unexpected end of escape sequence in: " + s); Log.e(TAG, "Unexpected end of escape sequence in: " + s);
break; break;
} }
c = (char) ((c-'0') * 100 + (s.charAt(i+1)-'0') * 10 + (s.charAt(i+2)-'0')); c = (char) ((c-'0') * 100 + (s.charAt(i+1)-'0') * 10 + (s.charAt(i+2)-'0'));
@@ -685,7 +684,7 @@ public class NsdService extends INsdManager.Stub {
private boolean isNsdEnabled() { private boolean isNsdEnabled() {
boolean ret = mNsdSettings.isEnabled(); boolean ret = mNsdSettings.isEnabled();
if (DBG) { if (DBG) {
Slog.d(TAG, "Network service discovery is " + (ret ? "enabled" : "disabled")); Log.d(TAG, "Network service discovery is " + (ret ? "enabled" : "disabled"));
} }
return ret; return ret;
} }
@@ -795,12 +794,12 @@ public class NsdService extends INsdManager.Stub {
*/ */
public boolean execute(Object... args) { public boolean execute(Object... args) {
if (DBG) { if (DBG) {
Slog.d(TAG, "mdnssd " + Arrays.toString(args)); Log.d(TAG, "mdnssd " + Arrays.toString(args));
} }
try { try {
mNativeConnector.execute("mdnssd", args); mNativeConnector.execute("mdnssd", args);
} catch (NativeDaemonConnectorException e) { } catch (NativeDaemonConnectorException e) {
Slog.e(TAG, "Failed to execute mdnssd " + Arrays.toString(args), e); Log.e(TAG, "Failed to execute mdnssd " + Arrays.toString(args), e);
return false; return false;
} }
return true; return true;
@@ -831,7 +830,7 @@ public class NsdService extends INsdManager.Stub {
private boolean registerService(int regId, NsdServiceInfo service) { private boolean registerService(int regId, NsdServiceInfo service) {
if (DBG) { if (DBG) {
Slog.d(TAG, "registerService: " + regId + " " + service); Log.d(TAG, "registerService: " + regId + " " + service);
} }
String name = service.getServiceName(); String name = service.getServiceName();
String type = service.getServiceType(); String type = service.getServiceType();
@@ -880,7 +879,12 @@ public class NsdService extends INsdManager.Stub {
@Override @Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return; if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
!= PackageManager.PERMISSION_GRANTED) {
pw.println("Permission Denial: can't dump " + TAG
+ " due to missing android.permission.DUMP permission");
return;
}
for (ClientInfo client : mClients.values()) { for (ClientInfo client : mClients.values()) {
pw.println("Client Info"); pw.println("Client Info");
@@ -909,7 +913,7 @@ public class NsdService extends INsdManager.Stub {
private ClientInfo(INsdManagerCallback cb) { private ClientInfo(INsdManagerCallback cb) {
mCb = cb; mCb = cb;
if (DBG) Slog.d(TAG, "New client"); if (DBG) Log.d(TAG, "New client");
} }
@Override @Override
@@ -943,8 +947,10 @@ public class NsdService extends INsdManager.Stub {
clientId = mClientIds.keyAt(i); clientId = mClientIds.keyAt(i);
globalId = mClientIds.valueAt(i); globalId = mClientIds.valueAt(i);
mIdToClientInfoMap.remove(globalId); mIdToClientInfoMap.remove(globalId);
if (DBG) Slog.d(TAG, "Terminating client-ID " + clientId + if (DBG) {
" global-ID " + globalId + " type " + mClientRequests.get(clientId)); Log.d(TAG, "Terminating client-ID " + clientId
+ " global-ID " + globalId + " type " + mClientRequests.get(clientId));
}
switch (mClientRequests.get(clientId)) { switch (mClientRequests.get(clientId)) {
case NsdManager.DISCOVER_SERVICES: case NsdManager.DISCOVER_SERVICES:
stopServiceDiscovery(globalId); stopServiceDiscovery(globalId);