Ringbuffer stops logging after wifi toggle

Fix ringbuffer not updating after wifi is toggled when "Wi-Fi scanning"
is turned on.

Bug: 161307741
Test: atest com.android.server.wifi
Test: manual test
Change-Id: I6b6d3d1b11aaaa407f1cbda4a45c3349805fe43d
Merged-In: I6b6d3d1b11aaaa407f1cbda4a45c3349805fe43d
(cherry picked from commit e05ba2e7cc29ba5c084401a2961a7a4aa93099e8)
diff --git a/service/java/com/android/server/wifi/WifiDiagnostics.java b/service/java/com/android/server/wifi/WifiDiagnostics.java
index 6fc75c6..3804562 100644
--- a/service/java/com/android/server/wifi/WifiDiagnostics.java
+++ b/service/java/com/android/server/wifi/WifiDiagnostics.java
@@ -226,6 +226,10 @@
         if (!mActiveInterfaces.isEmpty()) {
             return;
         }
+        if (mLogLevel != VERBOSE_NO_LOG) {
+            stopLoggingAllBuffers();
+            mRingBuffers = null;
+        }
         if (mIsLoggingEventHandlerRegistered) {
             if (!mWifiNative.resetLogHandler()) {
                 mLog.wC("Fail to reset log handler");
@@ -236,10 +240,6 @@
             // the log handler is in an indeterminate state.
             mIsLoggingEventHandlerRegistered = false;
         }
-        if (mLogLevel != VERBOSE_NO_LOG) {
-            stopLoggingAllBuffers();
-            mRingBuffers = null;
-        }
     }
 
     @Override