Merge "Implement hasControl/isClosed call of ITuner."
This commit is contained in:
committed by
Android (Google) Code Review
commit
68f25c19b8
@@ -22,6 +22,8 @@ import android.hardware.radio.RadioManager;
|
||||
interface ITuner {
|
||||
void close();
|
||||
|
||||
boolean isClosed();
|
||||
|
||||
/**
|
||||
* @throws IllegalArgumentException if config is not valid or null
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user