Loading media/java/android/media/tv/interactive/ITvIAppManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ interface ITvIAppManager { List<TvIAppInfo> getTvIAppServiceList(int userId); void prepare(String tiasId, int type, int userId); void notifyAppLinkInfo(String tiasId, in Bundle info, int userId); void sendAppLinkCommand(String tiasId, in Bundle command, int userId); void startIApp(in IBinder sessionToken, int userId); void createSession( in ITvIAppClient client, in String iAppServiceId, int type, int seq, int userId); Loading media/java/android/media/tv/interactive/ITvIAppService.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -33,4 +33,5 @@ oneway interface ITvIAppService { in String iAppServiceId, int type); void prepare(int type); void notifyAppLinkInfo(in Bundle info); void sendAppLinkCommand(in Bundle command); } No newline at end of file media/java/android/media/tv/interactive/TvIAppManager.java +41 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,7 @@ public final class TvIAppManager { * <p>Type: String * * @see #notifyAppLinkInfo(String, Bundle) * @see #sendAppLinkCommand(String, Bundle) * @hide */ public static final String KEY_PACKAGE_NAME = "package_name"; Loading @@ -102,6 +103,7 @@ public final class TvIAppManager { * <p>Type: String * * @see #notifyAppLinkInfo(String, Bundle) * @see #sendAppLinkCommand(String, Bundle) * @hide */ public static final String KEY_CLASS_NAME = "class_name"; Loading Loading @@ -133,6 +135,33 @@ public final class TvIAppManager { */ public static final String KEY_URI_PREFIX = "uri_prefix"; /** * Key for command type in app link command. * <p>Type: String * * @see #sendAppLinkCommand(String, Bundle) * @hide */ public static final String KEY_COMMAND_TYPE = "command_type"; /** * Key for service ID in app link command. * <p>Type: String * * @see #sendAppLinkCommand(String, Bundle) * @hide */ public static final String KEY_SERVICE_ID = "service_id"; /** * Key for back URI in app link command. * <p>Type: String * * @see #sendAppLinkCommand(String, Bundle) * @hide */ public static final String KEY_BACK_URI = "back_uri"; private final ITvIAppManager mService; private final int mUserId; Loading Loading @@ -475,6 +504,18 @@ public final class TvIAppManager { } } /** * Sends app link command. * @hide */ public void sendAppLinkCommand(String tvIAppServiceId, Bundle command) { try { mService.sendAppLinkCommand(tvIAppServiceId, command, mUserId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Registers a {@link TvIAppManager.TvIAppCallback}. * Loading media/java/android/media/tv/interactive/TvIAppService.java +13 −0 Original line number Diff line number Diff line Loading @@ -129,6 +129,11 @@ public abstract class TvIAppService extends Service { public void notifyAppLinkInfo(Bundle appLinkInfo) { onAppLinkInfo(appLinkInfo); } @Override public void sendAppLinkCommand(Bundle command) { onAppLinkCommand(command); } }; return tvIAppServiceBinder; } Loading @@ -149,6 +154,14 @@ public abstract class TvIAppService extends Service { // TODO: make it abstract when unhide } /** * Sends App link info. * @hide */ public void onAppLinkCommand(Bundle command) { // TODO: make it abstract when unhide } /** * Returns a concrete implementation of {@link Session}. Loading services/core/java/com/android/server/tv/interactive/TvIAppManagerService.java +60 −3 Original line number Diff line number Diff line Loading @@ -634,6 +634,7 @@ public class TvIAppManagerService extends SystemService { @Override public void prepare(String tiasId, int type, int userId) { // TODO: bind service final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), Binder.getCallingUid(), userId, "prepare"); final long identity = Binder.clearCallingIdentity(); Loading Loading @@ -699,6 +700,40 @@ public class TvIAppManagerService extends SystemService { } } @Override public void sendAppLinkCommand(String tiasId, Bundle command, int userId) { final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), Binder.getCallingUid(), userId, "sendAppLinkCommand"); final long identity = Binder.clearCallingIdentity(); try { synchronized (mLock) { UserState userState = getOrCreateUserStateLocked(resolvedUserId); TvIAppState iAppState = userState.mIAppMap.get(tiasId); if (iAppState == null) { Slogf.e(TAG, "failed to sendAppLinkCommand - unknown TIAS id " + tiasId); return; } ComponentName componentName = iAppState.mInfo.getComponent(); ServiceState serviceState = userState.mServiceStateMap.get(componentName); if (serviceState == null) { serviceState = new ServiceState( componentName, tiasId, resolvedUserId); serviceState.addPendingAppLinkCommand(command); userState.mServiceStateMap.put(componentName, serviceState); } else if (serviceState.mService != null) { serviceState.mService.sendAppLinkCommand(command); } else { serviceState.addPendingAppLinkCommand(command); } } } catch (RemoteException e) { Slogf.e(TAG, "error in sendAppLinkCommand", e); } finally { Binder.restoreCallingIdentity(identity); } } @Override public void createSession(final ITvIAppClient client, final String iAppServiceId, int type, int seq, int userId) { Loading Loading @@ -1274,8 +1309,9 @@ public class TvIAppManagerService extends SystemService { private final List<IBinder> mSessionTokens = new ArrayList<>(); private final ServiceConnection mConnection; private final ComponentName mComponent; private final String mIAppSeriviceId; private final String mIAppServiceId; private final List<Bundle> mPendingAppLinkInfo = new ArrayList<>(); private final List<Bundle> mPendingAppLinkCommand = new ArrayList<>(); private boolean mPendingPrepare = false; private Integer mPendingPrepareType = null; Loading @@ -1294,12 +1330,16 @@ public class TvIAppManagerService extends SystemService { mPendingPrepare = pendingPrepare; mPendingPrepareType = prepareType; mConnection = new IAppServiceConnection(component, userId); mIAppSeriviceId = tias; mIAppServiceId = tias; } private void addPendingAppLink(Bundle info) { mPendingAppLinkInfo.add(info); } private void addPendingAppLinkCommand(Bundle command) { mPendingAppLinkCommand.add(command); } } private final class IAppServiceConnection implements ServiceConnection { Loading Loading @@ -1356,6 +1396,23 @@ public class TvIAppManagerService extends SystemService { } } if (!serviceState.mPendingAppLinkCommand.isEmpty()) { for (Iterator<Bundle> it = serviceState.mPendingAppLinkCommand.iterator(); it.hasNext(); ) { Bundle command = it.next(); final long identity = Binder.clearCallingIdentity(); try { serviceState.mService.sendAppLinkCommand(command); it.remove(); } catch (RemoteException e) { Slogf.e(TAG, "error in sendAppLinkCommand(" + command + ") when onServiceConnected", e); } finally { Binder.restoreCallingIdentity(identity); } } } List<IBinder> tokensToBeRemoved = new ArrayList<>(); // And create sessions, if any. Loading Loading @@ -1411,7 +1468,7 @@ public class TvIAppManagerService extends SystemService { try { synchronized (mLock) { ServiceState serviceState = getServiceStateLocked(mComponent, mUserId); String iAppServiceId = serviceState.mIAppSeriviceId; String iAppServiceId = serviceState.mIAppServiceId; UserState userState = getUserStateLocked(mUserId); notifyStateChangedLocked(userState, iAppServiceId, type, state); } Loading Loading
media/java/android/media/tv/interactive/ITvIAppManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ interface ITvIAppManager { List<TvIAppInfo> getTvIAppServiceList(int userId); void prepare(String tiasId, int type, int userId); void notifyAppLinkInfo(String tiasId, in Bundle info, int userId); void sendAppLinkCommand(String tiasId, in Bundle command, int userId); void startIApp(in IBinder sessionToken, int userId); void createSession( in ITvIAppClient client, in String iAppServiceId, int type, int seq, int userId); Loading
media/java/android/media/tv/interactive/ITvIAppService.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -33,4 +33,5 @@ oneway interface ITvIAppService { in String iAppServiceId, int type); void prepare(int type); void notifyAppLinkInfo(in Bundle info); void sendAppLinkCommand(in Bundle command); } No newline at end of file
media/java/android/media/tv/interactive/TvIAppManager.java +41 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,7 @@ public final class TvIAppManager { * <p>Type: String * * @see #notifyAppLinkInfo(String, Bundle) * @see #sendAppLinkCommand(String, Bundle) * @hide */ public static final String KEY_PACKAGE_NAME = "package_name"; Loading @@ -102,6 +103,7 @@ public final class TvIAppManager { * <p>Type: String * * @see #notifyAppLinkInfo(String, Bundle) * @see #sendAppLinkCommand(String, Bundle) * @hide */ public static final String KEY_CLASS_NAME = "class_name"; Loading Loading @@ -133,6 +135,33 @@ public final class TvIAppManager { */ public static final String KEY_URI_PREFIX = "uri_prefix"; /** * Key for command type in app link command. * <p>Type: String * * @see #sendAppLinkCommand(String, Bundle) * @hide */ public static final String KEY_COMMAND_TYPE = "command_type"; /** * Key for service ID in app link command. * <p>Type: String * * @see #sendAppLinkCommand(String, Bundle) * @hide */ public static final String KEY_SERVICE_ID = "service_id"; /** * Key for back URI in app link command. * <p>Type: String * * @see #sendAppLinkCommand(String, Bundle) * @hide */ public static final String KEY_BACK_URI = "back_uri"; private final ITvIAppManager mService; private final int mUserId; Loading Loading @@ -475,6 +504,18 @@ public final class TvIAppManager { } } /** * Sends app link command. * @hide */ public void sendAppLinkCommand(String tvIAppServiceId, Bundle command) { try { mService.sendAppLinkCommand(tvIAppServiceId, command, mUserId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Registers a {@link TvIAppManager.TvIAppCallback}. * Loading
media/java/android/media/tv/interactive/TvIAppService.java +13 −0 Original line number Diff line number Diff line Loading @@ -129,6 +129,11 @@ public abstract class TvIAppService extends Service { public void notifyAppLinkInfo(Bundle appLinkInfo) { onAppLinkInfo(appLinkInfo); } @Override public void sendAppLinkCommand(Bundle command) { onAppLinkCommand(command); } }; return tvIAppServiceBinder; } Loading @@ -149,6 +154,14 @@ public abstract class TvIAppService extends Service { // TODO: make it abstract when unhide } /** * Sends App link info. * @hide */ public void onAppLinkCommand(Bundle command) { // TODO: make it abstract when unhide } /** * Returns a concrete implementation of {@link Session}. Loading
services/core/java/com/android/server/tv/interactive/TvIAppManagerService.java +60 −3 Original line number Diff line number Diff line Loading @@ -634,6 +634,7 @@ public class TvIAppManagerService extends SystemService { @Override public void prepare(String tiasId, int type, int userId) { // TODO: bind service final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), Binder.getCallingUid(), userId, "prepare"); final long identity = Binder.clearCallingIdentity(); Loading Loading @@ -699,6 +700,40 @@ public class TvIAppManagerService extends SystemService { } } @Override public void sendAppLinkCommand(String tiasId, Bundle command, int userId) { final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), Binder.getCallingUid(), userId, "sendAppLinkCommand"); final long identity = Binder.clearCallingIdentity(); try { synchronized (mLock) { UserState userState = getOrCreateUserStateLocked(resolvedUserId); TvIAppState iAppState = userState.mIAppMap.get(tiasId); if (iAppState == null) { Slogf.e(TAG, "failed to sendAppLinkCommand - unknown TIAS id " + tiasId); return; } ComponentName componentName = iAppState.mInfo.getComponent(); ServiceState serviceState = userState.mServiceStateMap.get(componentName); if (serviceState == null) { serviceState = new ServiceState( componentName, tiasId, resolvedUserId); serviceState.addPendingAppLinkCommand(command); userState.mServiceStateMap.put(componentName, serviceState); } else if (serviceState.mService != null) { serviceState.mService.sendAppLinkCommand(command); } else { serviceState.addPendingAppLinkCommand(command); } } } catch (RemoteException e) { Slogf.e(TAG, "error in sendAppLinkCommand", e); } finally { Binder.restoreCallingIdentity(identity); } } @Override public void createSession(final ITvIAppClient client, final String iAppServiceId, int type, int seq, int userId) { Loading Loading @@ -1274,8 +1309,9 @@ public class TvIAppManagerService extends SystemService { private final List<IBinder> mSessionTokens = new ArrayList<>(); private final ServiceConnection mConnection; private final ComponentName mComponent; private final String mIAppSeriviceId; private final String mIAppServiceId; private final List<Bundle> mPendingAppLinkInfo = new ArrayList<>(); private final List<Bundle> mPendingAppLinkCommand = new ArrayList<>(); private boolean mPendingPrepare = false; private Integer mPendingPrepareType = null; Loading @@ -1294,12 +1330,16 @@ public class TvIAppManagerService extends SystemService { mPendingPrepare = pendingPrepare; mPendingPrepareType = prepareType; mConnection = new IAppServiceConnection(component, userId); mIAppSeriviceId = tias; mIAppServiceId = tias; } private void addPendingAppLink(Bundle info) { mPendingAppLinkInfo.add(info); } private void addPendingAppLinkCommand(Bundle command) { mPendingAppLinkCommand.add(command); } } private final class IAppServiceConnection implements ServiceConnection { Loading Loading @@ -1356,6 +1396,23 @@ public class TvIAppManagerService extends SystemService { } } if (!serviceState.mPendingAppLinkCommand.isEmpty()) { for (Iterator<Bundle> it = serviceState.mPendingAppLinkCommand.iterator(); it.hasNext(); ) { Bundle command = it.next(); final long identity = Binder.clearCallingIdentity(); try { serviceState.mService.sendAppLinkCommand(command); it.remove(); } catch (RemoteException e) { Slogf.e(TAG, "error in sendAppLinkCommand(" + command + ") when onServiceConnected", e); } finally { Binder.restoreCallingIdentity(identity); } } } List<IBinder> tokensToBeRemoved = new ArrayList<>(); // And create sessions, if any. Loading Loading @@ -1411,7 +1468,7 @@ public class TvIAppManagerService extends SystemService { try { synchronized (mLock) { ServiceState serviceState = getServiceStateLocked(mComponent, mUserId); String iAppServiceId = serviceState.mIAppSeriviceId; String iAppServiceId = serviceState.mIAppServiceId; UserState userState = getUserStateLocked(mUserId); notifyStateChangedLocked(userState, iAppServiceId, type, state); } Loading