Merge "Remove the DisabledState from NsdService" am: d65740346e

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2110094

Change-Id: I2762dcef06e9d0e54546f2d522febe9d17d5b4a6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Paul Hu
2022-06-01 09:46:05 +00:00
committed by Automerger Merge Worker
2 changed files with 4 additions and 35 deletions

View File

@@ -175,6 +175,7 @@ public final class NsdManager {
*
* @see #ACTION_NSD_STATE_CHANGED
*/
// TODO: Deprecate this since NSD service is never disabled.
public static final int NSD_STATE_DISABLED = 1;
/**
@@ -230,17 +231,12 @@ public final class NsdManager {
public static final int DAEMON_STARTUP = 19;
/** @hide */
public static final int ENABLE = 20;
/** @hide */
public static final int DISABLE = 21;
public static final int MDNS_SERVICE_EVENT = 20;
/** @hide */
public static final int MDNS_SERVICE_EVENT = 22;
public static final int REGISTER_CLIENT = 21;
/** @hide */
public static final int REGISTER_CLIENT = 23;
/** @hide */
public static final int UNREGISTER_CLIENT = 24;
public static final int UNREGISTER_CLIENT = 22;
/** Dns based service discovery protocol */
public static final int PROTOCOL_DNS_SD = 0x0001;
@@ -266,8 +262,6 @@ public final class NsdManager {
EVENT_NAMES.put(RESOLVE_SERVICE_SUCCEEDED, "RESOLVE_SERVICE_SUCCEEDED");
EVENT_NAMES.put(DAEMON_CLEANUP, "DAEMON_CLEANUP");
EVENT_NAMES.put(DAEMON_STARTUP, "DAEMON_STARTUP");
EVENT_NAMES.put(ENABLE, "ENABLE");
EVENT_NAMES.put(DISABLE, "DISABLE");
EVENT_NAMES.put(MDNS_SERVICE_EVENT, "MDNS_SERVICE_EVENT");
}

View File

@@ -101,7 +101,6 @@ public class NsdService extends INsdManager.Stub {
private class NsdStateMachine extends StateMachine {
private final DefaultState mDefaultState = new DefaultState();
private final DisabledState mDisabledState = new DisabledState();
private final EnabledState mEnabledState = new EnabledState();
@Override
@@ -152,7 +151,6 @@ public class NsdService extends INsdManager.Stub {
NsdStateMachine(String name, Handler handler) {
super(name, handler);
addState(mDefaultState);
addState(mDisabledState, mDefaultState);
addState(mEnabledState, mDefaultState);
State initialState = mEnabledState;
setInitialState(initialState);
@@ -250,25 +248,6 @@ public class NsdService extends INsdManager.Stub {
}
}
class DisabledState extends State {
@Override
public void enter() {
sendNsdStateChangeBroadcast(false);
}
@Override
public boolean processMessage(Message msg) {
switch (msg.what) {
case NsdManager.ENABLE:
transitionTo(mEnabledState);
break;
default:
return NOT_HANDLED;
}
return HANDLED;
}
}
class EnabledState extends State {
@Override
public void enter() {
@@ -312,10 +291,6 @@ public class NsdService extends INsdManager.Stub {
final int clientId = msg.arg2;
final ListenerArgs args;
switch (msg.what) {
case NsdManager.DISABLE:
//TODO: cleanup clients
transitionTo(mDisabledState);
break;
case NsdManager.DISCOVER_SERVICES:
if (DBG) Log.d(TAG, "Discover services");
args = (ListenerArgs) msg.obj;