Tuner: Clean up frontend sharee resource before sharing another resource

Before sharing another resource in shareFrontendFromTuner method Clean
up old frontend sharee.

Test: cts-tradefed run commandAndExit cts -m CtsTvTestCases -t
android.media.tv.tuner.cts.TunerTest
Bug: 284386302

Change-Id: I606de9f4a95923183d0e2e94a8e73f9c0ed5df43
This commit is contained in:
Sham Rathod
2023-08-02 15:39:27 +05:30
parent 60a6004712
commit 9296d15b2c

View File

@@ -443,6 +443,12 @@ public class Tuner implements AutoCloseable {
acquireTRMSLock("shareFrontendFromTuner()");
mFrontendLock.lock();
try {
if (mFeOwnerTuner != null) {
// unregister self from the Frontend callback
mFeOwnerTuner.unregisterFrontendCallbackListener(this);
mFeOwnerTuner = null;
nativeUnshareFrontend();
}
mTunerResourceManager.shareFrontend(mClientId, tuner.mClientId);
mFeOwnerTuner = tuner;
mFeOwnerTuner.registerFrontendCallbackListener(this);