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

Commit 6f445545 authored by Luke Huang's avatar Luke Huang Committed by Automerger Merge Worker
Browse files

Merge "Fix the comments from aosp/1717479." am: 33d67f0b am: 2d1ccbfd am: 2d92323d

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1730170

Change-Id: Iac7af6fd0b1f4896cdd715708c98c5c01e4fa94d
parents 17744ff0 2d92323d
Loading
Loading
Loading
Loading
+18 −15
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ public class NsdService extends INsdManager.Stub {
    private static final String MDNS_TAG = "mDnsConnector";

    private static final boolean DBG = true;
    private static final long CLEANUP_DELAY_MS = 3000;
    private static final long CLEANUP_DELAY_MS = 10000;

    private final Context mContext;
    private final NsdSettings mNsdSettings;
@@ -94,19 +94,25 @@ public class NsdService extends INsdManager.Stub {
            return NsdManager.nameOf(what);
        }

        void maybeStartDaemon() {
        private void maybeStartDaemon() {
            mDaemon.maybeStart();
            maybeScheduleStop();
        }

        void maybeScheduleStop() {
            if (!isAnyRequestActive()) {
                cancelStop();
        private boolean isAnyRequestActive() {
            return mIdToClientInfoMap.size() != 0;
        }

        private void scheduleStop() {
            sendMessageDelayed(NsdManager.DAEMON_CLEANUP, mCleanupDelayMs);
        }
        private void maybeScheduleStop() {
            if (!isAnyRequestActive()) {
                scheduleStop();
            }
        }

        void cancelStop() {
        private void cancelStop() {
            this.removeMessages(NsdManager.DAEMON_CLEANUP);
        }

@@ -164,11 +170,16 @@ public class NsdService extends INsdManager.Stub {
                                if (DBG) Slog.d(TAG, "Client connection lost with reason: " + msg.arg1);
                                break;
                        }

                        cInfo = mClients.get(msg.replyTo);
                        if (cInfo != null) {
                            cInfo.expungeAllRequests();
                            mClients.remove(msg.replyTo);
                        }
                        //Last client
                        if (mClients.size() == 0) {
                            scheduleStop();
                        }
                        break;
                    case AsyncChannel.CMD_CHANNEL_FULL_CONNECTION:
                        AsyncChannel ac = new AsyncChannel();
@@ -235,7 +246,7 @@ public class NsdService extends INsdManager.Stub {
            public void exit() {
                // TODO: it is incorrect to stop the daemon without expunging all requests
                // and sending error callbacks to clients.
                maybeScheduleStop();
                scheduleStop();
            }

            private boolean requestLimitReached(ClientInfo clientInfo) {
@@ -271,9 +282,6 @@ public class NsdService extends INsdManager.Stub {
                        return NOT_HANDLED;
                    case AsyncChannel.CMD_CHANNEL_DISCONNECTED:
                        return NOT_HANDLED;
                }

                switch (msg.what) {
                    case NsdManager.DISABLE:
                        //TODO: cleanup clients
                        transitionTo(mDisabledState);
@@ -531,10 +539,6 @@ public class NsdService extends INsdManager.Stub {
       }
    }

    private boolean isAnyRequestActive() {
        return mIdToClientInfoMap.size() != 0;
    }

    private String unescape(String s) {
        StringBuilder sb = new StringBuilder(s.length());
        for (int i = 0; i < s.length(); ++i) {
@@ -907,7 +911,6 @@ public class NsdService extends INsdManager.Stub {
            }
            mClientIds.clear();
            mClientRequests.clear();
            mNsdStateMachine.maybeScheduleStop();
        }

        // mClientIds is a sparse array of listener id -> mDnsClient id.  For a given mDnsClient id,