NsdService: minor cleanups
Minor cleanups in switches of processMessage and handleNativeEvent. Test: no functional changes Bug: 33074219 (cherry picked from commit 23dba85fff01a9f51beea8ce811fc98b582f8e71) Merged-In: I9ad4ce812c0d2c02a671a7a871ad427e4ce29b4a Change-Id: Ic029cc9fa007d8c485f64f4afcbd4dc10da1ae29
This commit is contained in:
@@ -253,20 +253,17 @@ public class NsdService extends INsdManager.Stub {
|
|||||||
public boolean processMessage(Message msg) {
|
public boolean processMessage(Message msg) {
|
||||||
ClientInfo clientInfo;
|
ClientInfo clientInfo;
|
||||||
NsdServiceInfo servInfo;
|
NsdServiceInfo servInfo;
|
||||||
boolean result = HANDLED;
|
|
||||||
int id;
|
int id;
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case AsyncChannel.CMD_CHANNEL_HALF_CONNECTED:
|
case AsyncChannel.CMD_CHANNEL_HALF_CONNECTED:
|
||||||
//First client
|
//First client
|
||||||
if (msg.arg1 == AsyncChannel.STATUS_SUCCESSFUL &&
|
if (msg.arg1 == AsyncChannel.STATUS_SUCCESSFUL &&
|
||||||
mClients.size() == 0) {
|
mClients.size() == 0) {
|
||||||
startMDnsDaemon();
|
startMDnsDaemon();
|
||||||
}
|
}
|
||||||
result = NOT_HANDLED;
|
return NOT_HANDLED;
|
||||||
break;
|
|
||||||
case AsyncChannel.CMD_CHANNEL_DISCONNECTED:
|
case AsyncChannel.CMD_CHANNEL_DISCONNECTED:
|
||||||
result = NOT_HANDLED;
|
return NOT_HANDLED;
|
||||||
break;
|
|
||||||
case NsdManager.DISABLE:
|
case NsdManager.DISABLE:
|
||||||
//TODO: cleanup clients
|
//TODO: cleanup clients
|
||||||
transitionTo(mDisabledState);
|
transitionTo(mDisabledState);
|
||||||
@@ -377,26 +374,23 @@ public class NsdService extends INsdManager.Stub {
|
|||||||
case NsdManager.NATIVE_DAEMON_EVENT:
|
case NsdManager.NATIVE_DAEMON_EVENT:
|
||||||
NativeEvent event = (NativeEvent) msg.obj;
|
NativeEvent event = (NativeEvent) msg.obj;
|
||||||
if (!handleNativeEvent(event.code, event.raw, event.cooked)) {
|
if (!handleNativeEvent(event.code, event.raw, event.cooked)) {
|
||||||
result = NOT_HANDLED;
|
return NOT_HANDLED;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
result = NOT_HANDLED;
|
return NOT_HANDLED;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return result;
|
return HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean handleNativeEvent(int code, String raw, String[] cooked) {
|
private boolean handleNativeEvent(int code, String raw, String[] cooked) {
|
||||||
boolean handled = true;
|
|
||||||
NsdServiceInfo servInfo;
|
NsdServiceInfo servInfo;
|
||||||
int id = Integer.parseInt(cooked[1]);
|
int id = Integer.parseInt(cooked[1]);
|
||||||
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));
|
Slog.e(TAG, String.format("id %d for %s has no client mapping", id, name));
|
||||||
handled = false;
|
return false;
|
||||||
return handled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This goes in response as msg.arg2 */
|
/* This goes in response as msg.arg2 */
|
||||||
@@ -409,8 +403,7 @@ public class NsdService extends INsdManager.Stub {
|
|||||||
Slog.d(TAG, String.format(
|
Slog.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));
|
||||||
handled = false;
|
return false;
|
||||||
return handled;
|
|
||||||
}
|
}
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
String name = NativeResponseCode.nameOf(code);
|
String name = NativeResponseCode.nameOf(code);
|
||||||
@@ -518,10 +511,9 @@ public class NsdService extends INsdManager.Stub {
|
|||||||
clientInfo.mResolvedService = null;
|
clientInfo.mResolvedService = null;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
handled = false;
|
return false;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return handled;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user