From d596024bef1e9dfd2cc3f93de585b6a6ff2b0a7c Mon Sep 17 00:00:00 2001 From: Henry Fang Date: Wed, 16 Feb 2022 12:07:08 -0800 Subject: add a method for non session bug: 215546861 Test: atest android.media.tv.cts.TvInputManagerTest Change-Id: I641b51ae28f0e4834644a8ee8d879b768fda0bd2 --- core/api/system-current.txt | 3 +- media/java/android/media/tv/TvInputManager.java | 43 +++++++++++++++++++++---- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 904aa7bf15f7..48698567f1ac 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -6789,7 +6789,8 @@ package android.media.tv { method @NonNull @RequiresPermission(android.Manifest.permission.TIS_EXTENSION_INTERFACE) public java.util.List getAvailableExtensionInterfaceNames(@NonNull String); method @RequiresPermission(android.Manifest.permission.CAPTURE_TV_INPUT) public java.util.List getAvailableTvStreamConfigList(String); method @RequiresPermission("android.permission.TUNER_RESOURCE_ACCESS") public int getClientPid(@NonNull String); - method @RequiresPermission("android.permission.TUNER_RESOURCE_ACCESS") public int getClientPriority(int, @Nullable String); + method @RequiresPermission("android.permission.TUNER_RESOURCE_ACCESS") public int getClientPriority(int, @NonNull String); + method @RequiresPermission("android.permission.TUNER_RESOURCE_ACCESS") public int getClientPriority(int); method @NonNull @RequiresPermission(android.Manifest.permission.ACCESS_TUNED_INFO) public java.util.List getCurrentTunedInfos(); method @NonNull @RequiresPermission("android.permission.DVB_DEVICE") public java.util.List getDvbDeviceList(); method @Nullable @RequiresPermission(android.Manifest.permission.TIS_EXTENSION_INTERFACE) public android.os.IBinder getExtensionInterface(@NonNull String, @NonNull String); diff --git a/media/java/android/media/tv/TvInputManager.java b/media/java/android/media/tv/TvInputManager.java index 96809bda7c31..69fe5ee49872 100644 --- a/media/java/android/media/tv/TvInputManager.java +++ b/media/java/android/media/tv/TvInputManager.java @@ -1863,12 +1863,9 @@ public final class TvInputManager { * Returns a priority for the given use case type and the client's foreground or background * status. * - * @param useCase the use case type of the client. When the given use case type is invalid, - * the default use case type will be used. {@see TvInputService#PriorityHintUseCaseType}. - * @param sessionId the unique id of the session owned by the client. When {@code null}, - * the caller will be used as a client. When the session is invalid, background status - * will be used as a client's status. Otherwise, TV app corresponding to the given - * session id will be used as a client. + * @param useCase the use case type of the client. + * {@see TvInputService#PriorityHintUseCaseType}. + * @param sessionId the unique id of the session owned by the client. * {@see TvInputService#onCreateSession(String, String)}. * * @return the use case priority value for the given use case type and the client's foreground @@ -1879,10 +1876,34 @@ public final class TvInputManager { @SystemApi @RequiresPermission(android.Manifest.permission.TUNER_RESOURCE_ACCESS) public int getClientPriority(@TvInputService.PriorityHintUseCaseType int useCase, - @Nullable String sessionId) { + @NonNull String sessionId) { + Preconditions.checkNotNull(sessionId); + if (!isValidUseCase(useCase)) { + throw new IllegalArgumentException("Invalid use case: " + useCase); + } return getClientPriorityInternal(useCase, sessionId); }; + /** + * Returns a priority for the given use case type and the caller's foreground or background + * status. + * + * @param useCase the use case type of the caller. + * {@see TvInputService#PriorityHintUseCaseType}. + * + * @return the use case priority value for the given use case type and the caller's foreground + * or background status. + * + * @hide + */ + @SystemApi + @RequiresPermission(android.Manifest.permission.TUNER_RESOURCE_ACCESS) + public int getClientPriority(@TvInputService.PriorityHintUseCaseType int useCase) { + if (!isValidUseCase(useCase)) { + throw new IllegalArgumentException("Invalid use case: " + useCase); + } + return getClientPriorityInternal(useCase, null); + }; /** * Creates a recording {@link Session} for a given TV input. * @@ -1935,6 +1956,14 @@ public final class TvInputManager { } } + private boolean isValidUseCase(int useCase) { + return useCase == TvInputService.PRIORITY_HINT_USE_CASE_TYPE_BACKGROUND + || useCase == TvInputService.PRIORITY_HINT_USE_CASE_TYPE_SCAN + || useCase == TvInputService.PRIORITY_HINT_USE_CASE_TYPE_PLAYBACK + || useCase == TvInputService.PRIORITY_HINT_USE_CASE_TYPE_LIVE + || useCase == TvInputService.PRIORITY_HINT_USE_CASE_TYPE_RECORD; + } + /** * Returns the TvStreamConfig list of the given TV input. * -- cgit v1.2.3-59-g8ed1b