Fix remaining instrumentation tests.
Bug: 69958777
Test: VTS, Instrumentation
Change-Id: I98956ea4b1d2953b9159fb7d53ce61e57f80a90f
diff --git a/broadcastradio/2.0/default/BroadcastRadio.cpp b/broadcastradio/2.0/default/BroadcastRadio.cpp
index aa5afad..0148fec 100644
--- a/broadcastradio/2.0/default/BroadcastRadio.cpp
+++ b/broadcastradio/2.0/default/BroadcastRadio.cpp
@@ -112,6 +112,12 @@
Return<void> BroadcastRadio::openSession(const sp<ITunerCallback>& callback,
openSession_cb _hidl_cb) {
ALOGV("%s", __func__);
+
+ /* For the needs of default implementation it's fine to instantiate new session object
+ * out of the lock scope. If your implementation needs it, use reentrant lock.
+ */
+ sp<TunerSession> newSession = new TunerSession(*this, callback);
+
lock_guard<mutex> lk(mMut);
auto oldSession = mSession.promote();
@@ -121,7 +127,6 @@
mSession = nullptr;
}
- sp<TunerSession> newSession = new TunerSession(*this, callback);
mSession = newSession;
_hidl_cb(Result::OK, newSession);