Netd unsolicited event porting

Use another buffer to log unsolicited event.

Test: built, flashed, booted
Test: 1. manual test datacall/wifi work
      2. manual test tethering work
      3. run cts StrictModeTest pass
      4. manual test data alert work
      5. manual idletimer work

Change-Id: I1e4ed360b0c9d60c14bc7f0ffdf578fc557d3643
diff --git a/server/NetdNativeService.cpp b/server/NetdNativeService.cpp
index 63b8a24..83bd3a6 100644
--- a/server/NetdNativeService.cpp
+++ b/server/NetdNativeService.cpp
@@ -205,6 +205,19 @@
         dw.blankline();
     }
 
+    {
+        ScopedIndent indentLog(dw);
+        if (contains(args, String16(OPT_SHORT))) {
+            dw.println("UnsolicitedLog: <omitted>");
+        } else {
+            dw.println("UnsolicitedLog:");
+            ScopedIndent indentLogEntries(dw);
+            gUnsolicitedLog.forEachEntry(
+                    [&dw](const std::string& entry) mutable { dw.println(entry); });
+        }
+        dw.blankline();
+    }
+
     return NO_ERROR;
 }
 
@@ -1493,5 +1506,16 @@
     return binder::Status::ok();
 }
 
+binder::Status NetdNativeService::registerUnsolicitedEventListener(
+        const android::sp<android::net::INetdUnsolicitedEventListener>& listener) {
+    ENFORCE_PERMISSION(NETWORK_STACK);
+    pid_t pid = IPCThreadState::self()->getCallingPid();
+    auto entry = gLog.newEntry().prettyFunction(__PRETTY_FUNCTION__).arg(pid);
+
+    gCtls->eventReporter.registerUnsolEventListener(pid, listener);
+    gLog.log(entry.withAutomaticDuration());
+    return binder::Status::ok();
+}
+
 }  // namespace net
 }  // namespace android