Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 819de239 authored by Haofan Wang's avatar Haofan Wang
Browse files

[0002] Fix segfault from bad CiCam closure

Cleaning up of CiCam resources should not be conditional on nativeUnlinkCiCam success. Connect + disconnect fails for TunerHAL impl that does not support CiCam.

Bug: 356779633
Test: test on cuddlefish
Flag: EXEMPT bugfix
(cherry picked from https://android-review.googlesource.com/q/commit:172287dd6c8aedb56c73234e38f0cb37860154ed)
Merged-In: If05b33f6bc0c598195c83c15d512c249807228ec
Change-Id: If05b33f6bc0c598195c83c15d512c249807228ec
parent cdd46583
Loading
Loading
Loading
Loading
+8 −15
Original line number Diff line number Diff line
@@ -888,19 +888,14 @@ public class Tuner implements AutoCloseable {
        try {
            if (mFrontendCiCamHandle != null) {
                if (DEBUG) {
                    Log.d(TAG, "unlinking CiCam : " + mFrontendCiCamHandle + " for " +  mClientId);
                    Log.d(TAG, "releasing CiCam : " + mFrontendCiCamHandle + " for " +  mClientId);
                }
                int result = nativeUnlinkCiCam(mFrontendCiCamId);
                if (result == RESULT_SUCCESS) {
                nativeUnlinkCiCam(mFrontendCiCamId);
                mTunerResourceManager.releaseCiCam(mFrontendCiCamHandle, mClientId);
                replicateCiCamSettings(null);
                } else {
                    Log.e(TAG, "nativeUnlinkCiCam(" + mFrontendCiCamHandle + ") for mClientId:"
                            + mClientId + "failed with result:" + result);
                }
            } else {
                if (DEBUG) {
                    Log.d(TAG, "NOT unlinking CiCam : " + mClientId);
                    Log.d(TAG, "NOT releasing CiCam : " + mClientId);
                }
            }
        } finally {
@@ -1665,11 +1660,9 @@ public class Tuner implements AutoCloseable {
                if (mFrontendCiCamHandle != null && mFrontendCiCamId != null
                        && mFrontendCiCamId == ciCamId) {
                    int result = nativeUnlinkCiCam(ciCamId);
                    if (result == RESULT_SUCCESS) {
                    mTunerResourceManager.releaseCiCam(mFrontendCiCamHandle, mClientId);
                    mFrontendCiCamId = null;
                    mFrontendCiCamHandle = null;
                    }
                    return result;
                }
            }