Loading media/java/android/media/tv/ITvInputServiceCallback.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -27,4 +27,5 @@ oneway interface ITvInputServiceCallback { void addHardwareTvInput(in int deviceID, in TvInputInfo inputInfo); void addHdmiCecTvInput(in int logicalAddress, in TvInputInfo inputInfo); void removeTvInput(in String inputId); void setWrappedInputId(in String inputId, in String wrappedInputId); } media/java/android/media/tv/TvInputPassthroughWrapperService.java +1 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ public abstract class TvInputPassthroughWrapperService extends TvInputService { if (!session.connect(passthroughInputId)) { throw new IllegalStateException("WrapperSession cannot be reused."); } notifyWrappedInputId(inputId, passthroughInputId); return session; } Loading media/java/android/media/tv/TvInputService.java +38 −3 Original line number Diff line number Diff line Loading @@ -216,6 +216,21 @@ public abstract class TvInputService extends Service { return null; } /** * Notify wrapped TV input ID of current input to TV input framework manager * * @param inputId The TV input ID of {@link TvInputPassthroughWrapperService} * @param wrappedInputId The ID of the wrapped TV input such as external pass-though TV input * @hide */ public final void notifyWrappedInputId(String inputId, String wrappedInputId) { SomeArgs args = SomeArgs.obtain(); args.arg1 = inputId; args.arg2 = wrappedInputId; mHandler.obtainMessage(TvInputService.ServiceHandler.DO_SET_WRAPPED_TV_INPUT_ID, args).sendToTarget(); } /** * Base class for derived classes to implement to provide a TV input session. */ Loading Loading @@ -943,6 +958,7 @@ public abstract class TvInputService extends Service { private static final int DO_REMOVE_HARDWARE_TV_INPUT = 3; private static final int DO_ADD_HDMI_CEC_TV_INPUT = 4; private static final int DO_REMOVE_HDMI_CEC_TV_INPUT = 5; private static final int DO_SET_WRAPPED_TV_INPUT_ID = 6; private void broadcastAddHardwareTvInput(int deviceId, TvInputInfo inputInfo) { int n = mCallbacks.beginBroadcast(); Loading @@ -950,7 +966,7 @@ public abstract class TvInputService extends Service { try { mCallbacks.getBroadcastItem(i).addHardwareTvInput(deviceId, inputInfo); } catch (RemoteException e) { Log.e(TAG, "Error while broadcasting: " + e); Log.e(TAG, "Error while broadcasting.", e); } } mCallbacks.finishBroadcast(); Loading @@ -963,7 +979,7 @@ public abstract class TvInputService extends Service { try { mCallbacks.getBroadcastItem(i).addHdmiCecTvInput(logicalAddress, inputInfo); } catch (RemoteException e) { Log.e(TAG, "Error while broadcasting: " + e); Log.e(TAG, "Error while broadcasting.", e); } } mCallbacks.finishBroadcast(); Loading @@ -975,7 +991,19 @@ public abstract class TvInputService extends Service { try { mCallbacks.getBroadcastItem(i).removeTvInput(inputId); } catch (RemoteException e) { Log.e(TAG, "Error while broadcasting: " + e); Log.e(TAG, "Error while broadcasting.", e); } } mCallbacks.finishBroadcast(); } private void broadcastSetWrappedTvInputId(String inputId, String wrappedInputId) { int n = mCallbacks.beginBroadcast(); for (int i = 0; i < n; ++i) { try { mCallbacks.getBroadcastItem(i).setWrappedInputId(inputId, wrappedInputId); } catch (RemoteException e) { Log.e(TAG, "Error while broadcasting.", e); } } mCallbacks.finishBroadcast(); Loading Loading @@ -1038,6 +1066,13 @@ public abstract class TvInputService extends Service { } return; } case DO_SET_WRAPPED_TV_INPUT_ID: { SomeArgs args = (SomeArgs) msg.obj; String inputId = (String) args.arg1; String wrappedInputId = (String) args.arg2; broadcastSetWrappedTvInputId(inputId, wrappedInputId); return; } default: { Log.w(TAG, "Unhandled message code: " + msg.what); return; Loading services/core/java/com/android/server/tv/TvInputManagerService.java +34 −2 Original line number Diff line number Diff line Loading @@ -1293,8 +1293,14 @@ public final class TvInputManagerService extends SystemService { final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid, userId, "captureFrame"); try { final String wrappedInputId; synchronized (mLock) { UserState userState = getUserStateLocked(resolvedUserId); wrappedInputId = userState.wrappedInputMap.get(inputId); } return mTvInputHardwareManager.captureFrame( inputId, surface, config, callingUid, resolvedUserId); (wrappedInputId != null) ? wrappedInputId : inputId, surface, config, callingUid, resolvedUserId); } finally { Binder.restoreCallingIdentity(identity); } Loading Loading @@ -1470,6 +1476,9 @@ public final class TvInputManagerService extends SystemService { // A set of callbacks. private final Set<ITvInputManagerCallback> callbackSet = new HashSet<ITvInputManagerCallback>(); // A mapping from the TV input id to wrapped input id. private final Map<String, String> wrappedInputMap = new HashMap<String, String>(); } private final class ClientState implements IBinder.DeathRecipient { Loading Loading @@ -1662,8 +1671,10 @@ public final class TvInputManagerService extends SystemService { for (TvInputState inputState : userState.inputMap.values()) { if (inputState.mInfo.getComponent().equals(name)) { notifyInputStateChangedLocked(userState, inputState.mInfo.getId(), String inputId = inputState.mInfo.getId(); notifyInputStateChangedLocked(userState, inputId, INPUT_STATE_DISCONNECTED, null); userState.wrappedInputMap.remove(inputId); } } updateServiceConnectionLocked(mName, mUserId); Loading Loading @@ -1742,6 +1753,27 @@ public final class TvInputManagerService extends SystemService { } } } @Override public void setWrappedInputId(String inputId, String wrappedInputId) { synchronized (mLock) { if (!hasInputIdLocked(inputId)) { return; } UserState userState = getUserStateLocked(mUserId); userState.wrappedInputMap.put(inputId, wrappedInputId); } } private boolean hasInputIdLocked(String inputId) { ServiceState serviceState = getServiceStateLocked(mName, mUserId); for (TvInputInfo inputInfo : serviceState.mInputList) { if (inputInfo.getId().equals(inputId)) { return true; } } return false; } } private final class LogHandler extends Handler { Loading Loading
media/java/android/media/tv/ITvInputServiceCallback.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -27,4 +27,5 @@ oneway interface ITvInputServiceCallback { void addHardwareTvInput(in int deviceID, in TvInputInfo inputInfo); void addHdmiCecTvInput(in int logicalAddress, in TvInputInfo inputInfo); void removeTvInput(in String inputId); void setWrappedInputId(in String inputId, in String wrappedInputId); }
media/java/android/media/tv/TvInputPassthroughWrapperService.java +1 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ public abstract class TvInputPassthroughWrapperService extends TvInputService { if (!session.connect(passthroughInputId)) { throw new IllegalStateException("WrapperSession cannot be reused."); } notifyWrappedInputId(inputId, passthroughInputId); return session; } Loading
media/java/android/media/tv/TvInputService.java +38 −3 Original line number Diff line number Diff line Loading @@ -216,6 +216,21 @@ public abstract class TvInputService extends Service { return null; } /** * Notify wrapped TV input ID of current input to TV input framework manager * * @param inputId The TV input ID of {@link TvInputPassthroughWrapperService} * @param wrappedInputId The ID of the wrapped TV input such as external pass-though TV input * @hide */ public final void notifyWrappedInputId(String inputId, String wrappedInputId) { SomeArgs args = SomeArgs.obtain(); args.arg1 = inputId; args.arg2 = wrappedInputId; mHandler.obtainMessage(TvInputService.ServiceHandler.DO_SET_WRAPPED_TV_INPUT_ID, args).sendToTarget(); } /** * Base class for derived classes to implement to provide a TV input session. */ Loading Loading @@ -943,6 +958,7 @@ public abstract class TvInputService extends Service { private static final int DO_REMOVE_HARDWARE_TV_INPUT = 3; private static final int DO_ADD_HDMI_CEC_TV_INPUT = 4; private static final int DO_REMOVE_HDMI_CEC_TV_INPUT = 5; private static final int DO_SET_WRAPPED_TV_INPUT_ID = 6; private void broadcastAddHardwareTvInput(int deviceId, TvInputInfo inputInfo) { int n = mCallbacks.beginBroadcast(); Loading @@ -950,7 +966,7 @@ public abstract class TvInputService extends Service { try { mCallbacks.getBroadcastItem(i).addHardwareTvInput(deviceId, inputInfo); } catch (RemoteException e) { Log.e(TAG, "Error while broadcasting: " + e); Log.e(TAG, "Error while broadcasting.", e); } } mCallbacks.finishBroadcast(); Loading @@ -963,7 +979,7 @@ public abstract class TvInputService extends Service { try { mCallbacks.getBroadcastItem(i).addHdmiCecTvInput(logicalAddress, inputInfo); } catch (RemoteException e) { Log.e(TAG, "Error while broadcasting: " + e); Log.e(TAG, "Error while broadcasting.", e); } } mCallbacks.finishBroadcast(); Loading @@ -975,7 +991,19 @@ public abstract class TvInputService extends Service { try { mCallbacks.getBroadcastItem(i).removeTvInput(inputId); } catch (RemoteException e) { Log.e(TAG, "Error while broadcasting: " + e); Log.e(TAG, "Error while broadcasting.", e); } } mCallbacks.finishBroadcast(); } private void broadcastSetWrappedTvInputId(String inputId, String wrappedInputId) { int n = mCallbacks.beginBroadcast(); for (int i = 0; i < n; ++i) { try { mCallbacks.getBroadcastItem(i).setWrappedInputId(inputId, wrappedInputId); } catch (RemoteException e) { Log.e(TAG, "Error while broadcasting.", e); } } mCallbacks.finishBroadcast(); Loading Loading @@ -1038,6 +1066,13 @@ public abstract class TvInputService extends Service { } return; } case DO_SET_WRAPPED_TV_INPUT_ID: { SomeArgs args = (SomeArgs) msg.obj; String inputId = (String) args.arg1; String wrappedInputId = (String) args.arg2; broadcastSetWrappedTvInputId(inputId, wrappedInputId); return; } default: { Log.w(TAG, "Unhandled message code: " + msg.what); return; Loading
services/core/java/com/android/server/tv/TvInputManagerService.java +34 −2 Original line number Diff line number Diff line Loading @@ -1293,8 +1293,14 @@ public final class TvInputManagerService extends SystemService { final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid, userId, "captureFrame"); try { final String wrappedInputId; synchronized (mLock) { UserState userState = getUserStateLocked(resolvedUserId); wrappedInputId = userState.wrappedInputMap.get(inputId); } return mTvInputHardwareManager.captureFrame( inputId, surface, config, callingUid, resolvedUserId); (wrappedInputId != null) ? wrappedInputId : inputId, surface, config, callingUid, resolvedUserId); } finally { Binder.restoreCallingIdentity(identity); } Loading Loading @@ -1470,6 +1476,9 @@ public final class TvInputManagerService extends SystemService { // A set of callbacks. private final Set<ITvInputManagerCallback> callbackSet = new HashSet<ITvInputManagerCallback>(); // A mapping from the TV input id to wrapped input id. private final Map<String, String> wrappedInputMap = new HashMap<String, String>(); } private final class ClientState implements IBinder.DeathRecipient { Loading Loading @@ -1662,8 +1671,10 @@ public final class TvInputManagerService extends SystemService { for (TvInputState inputState : userState.inputMap.values()) { if (inputState.mInfo.getComponent().equals(name)) { notifyInputStateChangedLocked(userState, inputState.mInfo.getId(), String inputId = inputState.mInfo.getId(); notifyInputStateChangedLocked(userState, inputId, INPUT_STATE_DISCONNECTED, null); userState.wrappedInputMap.remove(inputId); } } updateServiceConnectionLocked(mName, mUserId); Loading Loading @@ -1742,6 +1753,27 @@ public final class TvInputManagerService extends SystemService { } } } @Override public void setWrappedInputId(String inputId, String wrappedInputId) { synchronized (mLock) { if (!hasInputIdLocked(inputId)) { return; } UserState userState = getUserStateLocked(mUserId); userState.wrappedInputMap.put(inputId, wrappedInputId); } } private boolean hasInputIdLocked(String inputId) { ServiceState serviceState = getServiceStateLocked(mName, mUserId); for (TvInputInfo inputInfo : serviceState.mInputList) { if (inputInfo.getId().equals(inputId)) { return true; } } return false; } } private final class LogHandler extends Handler { Loading