Merge "Implement hasControl/isClosed call of ITuner."

This commit is contained in:
Tomasz Wasilczyk
2017-06-21 22:24:21 +00:00
committed by Android (Google) Code Review
3 changed files with 14 additions and 3 deletions

View File

@@ -22,6 +22,8 @@ import android.hardware.radio.RadioManager;
interface ITuner {
void close();
boolean isClosed();
/**
* @throws IllegalArgumentException if config is not valid or null
*/

View File

@@ -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;
}
}
}

View File

@@ -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");