Don't create sp<> to stack allocated mHwSvc

RefBase-derived objects should always be allocated in the heap.
They should also immediately become the target of an sp.

The original NetdHwService did not allow correct use. It privately
(and indirectly) inherited from RefBase, making it impossible to
generate an sp<> to it, as all clients should. We change the interface
to make this possible.

Bug: 138956784
Test: Booted with change.
Change-Id: Ia977f8a7f1a8bb554fc5e0bfcce056939c688812
diff --git a/server/NetdHwService.h b/server/NetdHwService.h
index 458c6fa..dd157de 100644
--- a/server/NetdHwService.h
+++ b/server/NetdHwService.h
@@ -27,7 +27,7 @@
 using INetdHw = android::system::net::netd::V1_1::INetd;
 using StatusCode = android::system::net::netd::V1_1::INetd::StatusCode;
 
-class NetdHwService : INetdHw {
+class NetdHwService : public INetdHw {
   public:
     // 1.0
     status_t start();
diff --git a/server/main.cpp b/server/main.cpp
index d8ed96f..cfbadee 100644
--- a/server/main.cpp
+++ b/server/main.cpp
@@ -51,6 +51,7 @@
 #include "netd_resolv/resolv_stub.h"
 
 using android::IPCThreadState;
+using android::sp;
 using android::status_t;
 using android::String16;
 using android::net::FwmarkServer;
@@ -189,10 +190,9 @@
 
     android::net::process::ScopedPidFile pidFile(PID_FILE_PATH);
 
-    // Now that netd is ready to process commands, advertise service
-    // availability for HAL clients.
-    NetdHwService mHwSvc;
-    if ((ret = mHwSvc.start()) != android::OK) {
+    // Now that netd is ready to process commands, advertise service availability for HAL clients.
+    sp<NetdHwService> mHwSvc(new NetdHwService());
+    if ((ret = mHwSvc->start()) != android::OK) {
         ALOGE("Unable to start NetdHwService: %d", ret);
         exit(1);
     }