am 7c2ae217: Merge "TIF: verify the hardware input ID from getHardwareInputId()." into lmp-dev

* commit '7c2ae2177f1163a80822535adbf013edeb615ad2':
  TIF: verify the hardware input ID from getHardwareInputId().
This commit is contained in:
Dongwon Kang
2014-08-19 04:10:41 +00:00
committed by Android Git Automerger

View File

@@ -94,6 +94,8 @@ public abstract class TvInputService extends Service {
private final RemoteCallbackList<ITvInputServiceCallback> mCallbacks =
new RemoteCallbackList<ITvInputServiceCallback>();
private TvInputManager mTvInputManager;
@Override
public final IBinder onBind(Intent intent) {
return new ITvInputService.Stub() {
@@ -225,6 +227,17 @@ public abstract class TvInputService extends Service {
return null;
}
private boolean isPassthroughInput(String inputId) {
if (mTvInputManager == null) {
mTvInputManager = (TvInputManager) getSystemService(Context.TV_INPUT_SERVICE);
}
TvInputInfo info = mTvInputManager.getTvInputInfo(inputId);
if (info != null && info.isPassthroughInput()) {
return true;
}
return false;
}
/**
* Base class for derived classes to implement to provide a TV input session.
*/
@@ -1229,9 +1242,14 @@ public abstract class TvInputService extends Service {
HardwareSession proxySession =
((HardwareSession) sessionImpl);
String harewareInputId = proxySession.getHardwareInputId();
if (TextUtils.isEmpty(harewareInputId)) {
if (TextUtils.isEmpty(harewareInputId) ||
!isPassthroughInput(harewareInputId)) {
if (TextUtils.isEmpty(harewareInputId)) {
Log.w(TAG, "Hardware input id is not setup yet.");
} else {
Log.w(TAG, "Invalid hardware input id : " + harewareInputId);
}
sessionImpl.onRelease();
Log.w(TAG, "Hardware input id is not setup yet.");
try {
cb.onSessionCreated(null, null);
} catch (RemoteException e) {
@@ -1239,7 +1257,6 @@ public abstract class TvInputService extends Service {
}
return;
}
// TODO: check if the given ID is really hardware TV input.
proxySession.mProxySession = stub;
proxySession.mProxySessionCallback = cb;
proxySession.mServiceHandler = mServiceHandler;