summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Henry Fang <quxiangfang@google.com> 2022-02-16 12:07:08 -0800
committer Henry Fang <quxiangfang@google.com> 2022-02-18 18:12:44 +0000
commitd596024bef1e9dfd2cc3f93de585b6a6ff2b0a7c (patch)
tree62e5f4179f9e6422078449ea63086208315e0ea5
parent5523b829f52fba8c83aaa57cd8ec2d5367bd724d (diff)
add a method for non session
bug: 215546861 Test: atest android.media.tv.cts.TvInputManagerTest Change-Id: I641b51ae28f0e4834644a8ee8d879b768fda0bd2
-rw-r--r--core/api/system-current.txt3
-rw-r--r--media/java/android/media/tv/TvInputManager.java43
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<java.lang.String> getAvailableExtensionInterfaceNames(@NonNull String);
method @RequiresPermission(android.Manifest.permission.CAPTURE_TV_INPUT) public java.util.List<android.media.tv.TvStreamConfig> 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<android.media.tv.TunedInfo> getCurrentTunedInfos();
method @NonNull @RequiresPermission("android.permission.DVB_DEVICE") public java.util.List<android.media.tv.DvbDeviceInfo> 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,11 +1876,35 @@ 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.
*
* <p>The number of sessions that can be created at the same time is limited by the capability
@@ -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.
*