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

Commit ea86b1d1 authored by Yixiao Luo's avatar Yixiao Luo
Browse files

Add explicit error when called by sharee for related functions

List of functions:
tune()
cancelTuning()
scan()
cancelScanning()
getFrontendStatus()
getFrontendStatusReadiness()
connectFrontendToCiCam()
disconnectFrontendToCiCam()
getCurrentFrontendHardwareInfo()
removeOutputPid()
setMaxNumberOfFrontends()

Bug: 202983530
Test: cts
Change-Id: I5d1062c238829f5f00bab67415dc13f3afbc330a
parent b28e3246
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
@@ -1161,6 +1161,10 @@ public class Tuner implements AutoCloseable {
    public int tune(@NonNull FrontendSettings settings) {
        mFrontendLock.lock();
        try {
            if (mFeOwnerTuner != null) {
                Log.d(TAG, "Operation cannot be done by sharee of tuner");
                return RESULT_INVALID_STATE;
            }
            final int type = settings.getType();
            if (mFrontendHandle != null && type != mFrontendType) {
                Log.e(TAG, "Frontend was opened with type " + mFrontendType
@@ -1204,6 +1208,10 @@ public class Tuner implements AutoCloseable {
    public int cancelTuning() {
        mFrontendLock.lock();
        try {
            if (mFeOwnerTuner != null) {
                Log.d(TAG, "Operation cannot be done by sharee of tuner");
                return RESULT_INVALID_STATE;
            }
            return nativeStopTune();
        } finally {
            mFrontendLock.unlock();
@@ -1237,6 +1245,10 @@ public class Tuner implements AutoCloseable {

        mFrontendLock.lock();
        try {
            if (mFeOwnerTuner != null) {
                Log.d(TAG, "Operation cannot be done by sharee of tuner");
                return RESULT_INVALID_STATE;
            }
            synchronized (mScanCallbackLock) {
                // Scan can be called again for blink scan if scanCallback and executor are same as
                //before.
@@ -1287,6 +1299,10 @@ public class Tuner implements AutoCloseable {
    public int cancelScanning() {
        mFrontendLock.lock();
        try {
            if (mFeOwnerTuner != null) {
                Log.d(TAG, "Operation cannot be done by sharee of tuner");
                return RESULT_INVALID_STATE;
            }
            synchronized (mScanCallbackLock) {
                FrameworkStatsLog.write(FrameworkStatsLog.TV_TUNER_STATE_CHANGED, mUserId,
                        FrameworkStatsLog.TV_TUNER_STATE_CHANGED__STATE__SCAN_STOPPED);
@@ -1377,6 +1393,9 @@ public class Tuner implements AutoCloseable {
            if (mFrontend == null) {
                throw new IllegalStateException("frontend is not initialized");
            }
            if (mFeOwnerTuner != null) {
                throw new IllegalStateException("Operation cannot be done by sharee of tuner");
            }
            return nativeGetFrontendStatus(statusTypes);
        } finally {
            mFrontendLock.unlock();
@@ -1480,6 +1499,10 @@ public class Tuner implements AutoCloseable {
        mFrontendCiCamLock.lock();
        mFrontendLock.lock();
        try {
            if (mFeOwnerTuner != null) {
                Log.d(TAG, "Operation cannot be done by sharee of tuner");
                return RESULT_INVALID_STATE;
            }
            if (TunerVersionChecker.checkHigherOrEqualVersionTo(
                    TunerVersionChecker.TUNER_VERSION_1_1,
                    "linkFrontendToCiCam")) {
@@ -1543,6 +1566,10 @@ public class Tuner implements AutoCloseable {
    public int disconnectFrontendToCiCam(int ciCamId) {
        acquireTRMSLock("disconnectFrontendToCiCam()");
        try {
            if (mFeOwnerTuner != null) {
                Log.d(TAG, "Operation cannot be done by sharee of tuner");
                return RESULT_INVALID_STATE;
            }
            if (TunerVersionChecker.checkHigherOrEqualVersionTo(
                    TunerVersionChecker.TUNER_VERSION_1_1,
                    "unlinkFrontendToCiCam")) {
@@ -1591,6 +1618,10 @@ public class Tuner implements AutoCloseable {
            if (mFrontend == null) {
                throw new IllegalStateException("frontend is not initialized");
            }
            if (mFeOwnerTuner != null) {
                Log.d(TAG, "Operation cannot be done by sharee of tuner");
                return RESULT_INVALID_STATE;
            }
            return nativeRemoveOutputPid(pid);
        } finally {
            mFrontendLock.unlock();
@@ -1621,6 +1652,9 @@ public class Tuner implements AutoCloseable {
            if (mFrontend == null) {
                throw new IllegalStateException("frontend is not initialized");
            }
            if (mFeOwnerTuner != null) {
                throw new IllegalStateException("Operation cannot be done by sharee of tuner");
            }
            FrontendStatusReadiness[] readiness = nativeGetFrontendStatusReadiness(statusTypes);
            if (readiness == null) {
                return Collections.EMPTY_LIST;
@@ -1697,6 +1731,9 @@ public class Tuner implements AutoCloseable {
            if (mFrontend == null) {
                throw new IllegalStateException("frontend is not initialized");
            }
            if (mFeOwnerTuner != null) {
                throw new IllegalStateException("Operation cannot be done by sharee of tuner");
            }
            return nativeGetFrontendHardwareInfo();
        } finally {
            mFrontendLock.unlock();
@@ -1726,6 +1763,10 @@ public class Tuner implements AutoCloseable {
        if (maxNumber < 0) {
            return RESULT_INVALID_ARGUMENT;
        }
        if (mFeOwnerTuner != null) {
            Log.d(TAG, "Operation cannot be done by sharee of tuner");
            return RESULT_INVALID_STATE;
        }
        int res = nativeSetMaxNumberOfFrontends(frontendType, maxNumber);
        if (res == RESULT_SUCCESS) {
            if (!mTunerResourceManager.setMaxNumberOfFrontends(frontendType, maxNumber)) {