Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 23dba85f authored by Hugo Benichi's avatar Hugo Benichi
Browse files

NsdService: minor cleanups

Minor cleanups in switches of processMessage and handleNativeEvent.

Test: no functional changes
Bug: 33074219
Change-Id: I9ad4ce812c0d2c02a671a7a871ad427e4ce29b4a
parent 2183ba9b
Loading
Loading
Loading
Loading
+10 −18
Original line number Original line Diff line number Diff line
@@ -252,7 +252,6 @@ 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:
@@ -261,11 +260,9 @@ public class NsdService extends INsdManager.Stub {
                                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);
@@ -376,26 +373,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 */
@@ -408,8 +402,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);
@@ -517,10 +510,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;
            }
            }
       }
       }
    }
    }