Fix stack-pointer constructed sp<>.
Seems like the hidl derived objects must be heap allocated.
Bug: 145662746
Test: Does not boot loop.
Change-Id: I55ff94c12d4eb5fcfd680370736db979ddd0b67c
diff --git a/broadcastradio/1.1/default/service.cpp b/broadcastradio/1.1/default/service.cpp
index f8af0b7..29dc76f 100644
--- a/broadcastradio/1.1/default/service.cpp
+++ b/broadcastradio/1.1/default/service.cpp
@@ -20,6 +20,7 @@
#include "BroadcastRadioFactory.h"
+using android::sp;
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
using android::hardware::broadcastradio::V1_1::implementation::BroadcastRadioFactory;
@@ -27,8 +28,8 @@
int main(int /* argc */, char** /* argv */) {
configureRpcThreadpool(4, true);
- BroadcastRadioFactory broadcastRadioFactory;
- auto status = broadcastRadioFactory.registerAsService();
+ sp<BroadcastRadioFactory> broadcastRadioFactory(new BroadcastRadioFactory());
+ auto status = broadcastRadioFactory->registerAsService();
CHECK_EQ(status, android::OK) << "Failed to register Broadcast Radio HAL implementation";
joinRpcThreadpool();