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

Commit 468a53b7 authored by Tomasz Wasilczyk's avatar Tomasz Wasilczyk
Browse files

Implement hasControl/isClosed call of ITuner.

Bug: b/36863239
Test: builds
Change-Id: Ia24a97b60ee5c0756dbe14b3b7c06c07313f4ac6
parent 2e5a23c8
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import android.hardware.radio.RadioManager;
interface ITuner {
    void close();

    boolean isClosed();

    /**
     * @throws IllegalArgumentException if config is not valid or null
     */
+6 −2
Original line number Diff line number Diff line
@@ -227,7 +227,11 @@ class TunerAdapter extends RadioTuner {

    @Override
    public boolean hasControl() {
        // TODO(b/36863239): forward to mTuner
        throw new RuntimeException("Not implemented");
        try {
            // don't rely on mIsClosed, as tuner might get closed internally
            return !mTuner.isClosed();
        } catch (RemoteException e) {
            return false;
        }
    }
}
+6 −1
Original line number Diff line number Diff line
@@ -92,13 +92,18 @@ class Tuner extends ITuner.Stub {
    public void close() {
        synchronized (mLock) {
            if (mIsClosed) return;
            mIsClosed = true;
            mTunerCallback.detach();
            mClientCallback.asBinder().unlinkToDeath(mDeathRecipient, 0);
            nativeClose(mNativeContext);
            mIsClosed = true;
        }
    }

    @Override
    public boolean isClosed() {
        return mIsClosed;
    }

    private void checkNotClosedLocked() {
        if (mIsClosed) {
            throw new IllegalStateException("Tuner is closed, no further operations are allowed");