From bb50a67f884272f2cb4fd958b81e3753f82d3c51 Mon Sep 17 00:00:00 2001 From: shubang Date: Thu, 17 Mar 2022 00:09:31 -0700 Subject: [PATCH] TIAF API review: remove prepare() It's no longer necessary and can be confusing Bug: 219501014 Test: mmm Change-Id: Id54f20245bb4e44cdf28f8d93b9ed413e3326410 --- core/api/current.txt | 2 - .../interactive/ITvInteractiveAppManager.aidl | 1 - .../interactive/ITvInteractiveAppService.aidl | 1 - .../interactive/TvInteractiveAppManager.java | 20 ------- .../interactive/TvInteractiveAppService.java | 10 ---- .../TvInteractiveAppManagerService.java | 59 ------------------- 6 files changed, 93 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index 34b4acc361e14..0425bb27e1b55 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -26113,7 +26113,6 @@ package android.media.tv.interactive { public final class TvInteractiveAppManager { method @NonNull public java.util.List getTvInteractiveAppServiceList(); - method public void prepare(@NonNull String, int); method public void registerAppLinkInfo(@NonNull String, @NonNull android.media.tv.interactive.AppLinkInfo); method public void registerCallback(@NonNull java.util.concurrent.Executor, @NonNull android.media.tv.interactive.TvInteractiveAppManager.TvInteractiveAppCallback); method public void sendAppLinkCommand(@NonNull String, @NonNull android.os.Bundle); @@ -26165,7 +26164,6 @@ package android.media.tv.interactive { method public void onAppLinkCommand(@NonNull android.os.Bundle); method @Nullable public final android.os.IBinder onBind(@NonNull android.content.Intent); method @Nullable public abstract android.media.tv.interactive.TvInteractiveAppService.Session onCreateSession(@NonNull String, int); - method public abstract void onPrepare(int); method public void onRegisterAppLinkInfo(@NonNull android.media.tv.interactive.AppLinkInfo); method public void onUnregisterAppLinkInfo(@NonNull android.media.tv.interactive.AppLinkInfo); field public static final String COMMAND_PARAMETER_KEY_CHANGE_CHANNEL_QUIETLY = "command_change_channel_quietly"; diff --git a/media/java/android/media/tv/interactive/ITvInteractiveAppManager.aidl b/media/java/android/media/tv/interactive/ITvInteractiveAppManager.aidl index eb012721445c0..22773774e8a3c 100644 --- a/media/java/android/media/tv/interactive/ITvInteractiveAppManager.aidl +++ b/media/java/android/media/tv/interactive/ITvInteractiveAppManager.aidl @@ -34,7 +34,6 @@ import android.view.Surface; */ interface ITvInteractiveAppManager { List getTvInteractiveAppServiceList(int userId); - void prepare(String tiasId, int type, int userId); void registerAppLinkInfo(String tiasId, in AppLinkInfo info, int userId); void unregisterAppLinkInfo(String tiasId, in AppLinkInfo info, int userId); void sendAppLinkCommand(String tiasId, in Bundle command, int userId); diff --git a/media/java/android/media/tv/interactive/ITvInteractiveAppService.aidl b/media/java/android/media/tv/interactive/ITvInteractiveAppService.aidl index b6d518ff7242f..524d94f578ff9 100644 --- a/media/java/android/media/tv/interactive/ITvInteractiveAppService.aidl +++ b/media/java/android/media/tv/interactive/ITvInteractiveAppService.aidl @@ -32,7 +32,6 @@ oneway interface ITvInteractiveAppService { void unregisterCallback(in ITvInteractiveAppServiceCallback callback); void createSession(in InputChannel channel, in ITvInteractiveAppSessionCallback callback, in String iAppServiceId, int type); - void prepare(int type); void registerAppLinkInfo(in AppLinkInfo info); void unregisterAppLinkInfo(in AppLinkInfo info); void sendAppLinkCommand(in Bundle command); diff --git a/media/java/android/media/tv/interactive/TvInteractiveAppManager.java b/media/java/android/media/tv/interactive/TvInteractiveAppManager.java index 702832ccb3ca0..84ee1bde00d8c 100755 --- a/media/java/android/media/tv/interactive/TvInteractiveAppManager.java +++ b/media/java/android/media/tv/interactive/TvInteractiveAppManager.java @@ -30,7 +30,6 @@ import android.media.tv.BroadcastInfoResponse; import android.media.tv.TvContentRating; import android.media.tv.TvInputManager; import android.media.tv.TvTrackInfo; -import android.media.tv.interactive.TvInteractiveAppServiceInfo.InteractiveAppType; import android.net.Uri; import android.os.Bundle; import android.os.Handler; @@ -774,25 +773,6 @@ public final class TvInteractiveAppManager { } } - /** - * Prepares TV Interactive App service environment for the given type. - * - *

This method brings up the corresponding {@link TvInteractiveAppService} and prepare needed - * resources. It's used to set up the resources in advance, or handle non-session operations. - * - * @param tvIAppServiceId The ID of TV interactive service to prepare the resources. The - * ID can be found in {@link TvInteractiveAppServiceInfo#getId()}. - * - * @see TvInteractiveAppService.Session - */ - public void prepare(@NonNull String tvIAppServiceId, @InteractiveAppType int type) { - try { - mService.prepare(tvIAppServiceId, type, mUserId); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); - } - } - /** * Registers an Android application link info record which can be used to launch the specific * Android application by TV interactive App RTE. diff --git a/media/java/android/media/tv/interactive/TvInteractiveAppService.java b/media/java/android/media/tv/interactive/TvInteractiveAppService.java index 15144f82e52c6..d45e63b7aec41 100755 --- a/media/java/android/media/tv/interactive/TvInteractiveAppService.java +++ b/media/java/android/media/tv/interactive/TvInteractiveAppService.java @@ -217,11 +217,6 @@ public abstract class TvInteractiveAppService extends Service { .sendToTarget(); } - @Override - public void prepare(int type) { - onPrepare(type); - } - @Override public void registerAppLinkInfo(AppLinkInfo appLinkInfo) { onRegisterAppLinkInfo(appLinkInfo); @@ -240,11 +235,6 @@ public abstract class TvInteractiveAppService extends Service { return tvIAppServiceBinder; } - /** - * Prepares TV Interactive App service for the given type. - */ - public abstract void onPrepare(@TvInteractiveAppServiceInfo.InteractiveAppType int type); - /** * Called when a request to register an Android application link info record is received. */ diff --git a/services/core/java/com/android/server/tv/interactive/TvInteractiveAppManagerService.java b/services/core/java/com/android/server/tv/interactive/TvInteractiveAppManagerService.java index c252043028c98..672458bef4a7f 100644 --- a/services/core/java/com/android/server/tv/interactive/TvInteractiveAppManagerService.java +++ b/services/core/java/com/android/server/tv/interactive/TvInteractiveAppManagerService.java @@ -664,42 +664,6 @@ public class TvInteractiveAppManagerService 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(); - try { - synchronized (mLock) { - UserState userState = getOrCreateUserStateLocked(resolvedUserId); - TvInteractiveAppState iAppState = userState.mIAppMap.get(tiasId); - if (iAppState == null) { - Slogf.e(TAG, "failed to prepare TIAS - 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, true, type); - userState.mServiceStateMap.put(componentName, serviceState); - updateServiceConnectionLocked(componentName, resolvedUserId); - } else if (serviceState.mService != null) { - serviceState.mService.prepare(type); - } else { - serviceState.mPendingPrepare = true; - serviceState.mPendingPrepareType = type; - updateServiceConnectionLocked(componentName, resolvedUserId); - } - } - } catch (RemoteException e) { - Slogf.e(TAG, "error in prepare", e); - } finally { - Binder.restoreCallingIdentity(identity); - } - } - @Override public void registerAppLinkInfo(String tiasId, AppLinkInfo appLinkInfo, int userId) { final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), @@ -1705,7 +1669,6 @@ public class TvInteractiveAppManagerService extends SystemService { } boolean shouldBind = (!serviceState.mSessionTokens.isEmpty()) - || (serviceState.mPendingPrepare) || (!serviceState.mPendingAppLinkInfo.isEmpty()) || (!serviceState.mPendingAppLinkCommand.isEmpty()); @@ -1857,22 +1820,13 @@ public class TvInteractiveAppManagerService extends SystemService { private final List> mPendingAppLinkInfo = new ArrayList<>(); private final List mPendingAppLinkCommand = new ArrayList<>(); - private boolean mPendingPrepare = false; - private Integer mPendingPrepareType = null; private ITvInteractiveAppService mService; private ServiceCallback mCallback; private boolean mBound; private boolean mReconnecting; private ServiceState(ComponentName component, String tias, int userId) { - this(component, tias, userId, false, null); - } - - private ServiceState(ComponentName component, String tias, int userId, - boolean pendingPrepare, Integer prepareType) { mComponent = component; - mPendingPrepare = pendingPrepare; - mPendingPrepareType = prepareType; mConnection = new InteractiveAppServiceConnection(component, userId); mIAppServiceId = tias; } @@ -1920,19 +1874,6 @@ public class TvInteractiveAppManagerService extends SystemService { } } - if (serviceState.mPendingPrepare) { - final long identity = Binder.clearCallingIdentity(); - try { - serviceState.mService.prepare(serviceState.mPendingPrepareType); - serviceState.mPendingPrepare = false; - serviceState.mPendingPrepareType = null; - } catch (RemoteException e) { - Slogf.e(TAG, "error in prepare when onServiceConnected", e); - } finally { - Binder.restoreCallingIdentity(identity); - } - } - if (!serviceState.mPendingAppLinkInfo.isEmpty()) { for (Iterator> it = serviceState.mPendingAppLinkInfo.iterator();