Merge "TIF: verify the hardware input ID from getHardwareInputId()." into lmp-dev
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user