diff --git a/api/current.txt b/api/current.txt index 814fd31ad2d43..3894c21dcff9e 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24976,6 +24976,7 @@ package android.media.tv { } public final class TvInputManager { + method public java.util.List getBlockedRatings(); method public int getInputState(java.lang.String); method public android.media.tv.TvInputInfo getTvInputInfo(java.lang.String); method public java.util.List getTvInputList(); diff --git a/api/test-current.txt b/api/test-current.txt index ca3793ed9f914..33f64f0f53325 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -25112,6 +25112,7 @@ package android.media.tv { } public final class TvInputManager { + method public java.util.List getBlockedRatings(); method public int getInputState(java.lang.String); method public android.media.tv.TvInputInfo getTvInputInfo(java.lang.String); method public java.util.List getTvInputList(); diff --git a/media/java/android/media/tv/TvInputManager.java b/media/java/android/media/tv/TvInputManager.java index 28fd338aabc72..d7a9edefa3f22 100644 --- a/media/java/android/media/tv/TvInputManager.java +++ b/media/java/android/media/tv/TvInputManager.java @@ -1329,9 +1329,7 @@ public final class TvInputManager { * Returns the list of blocked content ratings. * * @return the list of content ratings blocked by the user. - * @hide */ - @SystemApi public List getBlockedRatings() { try { List ratings = new ArrayList<>(); @@ -1387,6 +1385,7 @@ public final class TvInputManager { * @hide */ @SystemApi + @RequiresPermission(android.Manifest.permission.READ_CONTENT_RATING_SYSTEMS) public List getTvContentRatingSystemList() { try { return mService.getTvContentRatingSystemList(mUserId); @@ -1551,6 +1550,7 @@ public final class TvInputManager { * @hide */ @SystemApi + @RequiresPermission(android.Manifest.permission.CAPTURE_TV_INPUT) public boolean isSingleSessionActive() { try { return mService.isSingleSessionActive(mUserId); diff --git a/services/core/java/com/android/server/tv/TvInputManagerService.java b/services/core/java/com/android/server/tv/TvInputManagerService.java index 1afde550f0271..d5e59c8dfd6af 100644 --- a/services/core/java/com/android/server/tv/TvInputManagerService.java +++ b/services/core/java/com/android/server/tv/TvInputManagerService.java @@ -928,6 +928,12 @@ public final class TvInputManagerService extends SystemService { @Override public List getTvContentRatingSystemList(int userId) { + if (mContext.checkCallingPermission( + android.Manifest.permission.READ_CONTENT_RATING_SYSTEMS) + != PackageManager.PERMISSION_GRANTED) { + throw new SecurityException( + "The caller does not have permission to read content rating systems"); + } final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), Binder.getCallingUid(), userId, "getTvContentRatingSystemList"); final long identity = Binder.clearCallingIdentity(); @@ -1875,11 +1881,7 @@ public final class TvInputManagerService extends SystemService { @Override public List getAvailableTvStreamConfigList(String inputId, int userId) throws RemoteException { - if (mContext.checkCallingPermission( - android.Manifest.permission.CAPTURE_TV_INPUT) - != PackageManager.PERMISSION_GRANTED) { - throw new SecurityException("Requires CAPTURE_TV_INPUT permission"); - } + ensureCaptureTvInputPermission(); final long identity = Binder.clearCallingIdentity(); final int callingUid = Binder.getCallingUid(); @@ -1897,11 +1899,7 @@ public final class TvInputManagerService extends SystemService { public boolean captureFrame(String inputId, Surface surface, TvStreamConfig config, int userId) throws RemoteException { - if (mContext.checkCallingPermission( - android.Manifest.permission.CAPTURE_TV_INPUT) - != PackageManager.PERMISSION_GRANTED) { - throw new SecurityException("Requires CAPTURE_TV_INPUT permission"); - } + ensureCaptureTvInputPermission(); final long identity = Binder.clearCallingIdentity(); final int callingUid = Binder.getCallingUid(); @@ -1934,6 +1932,7 @@ public final class TvInputManagerService extends SystemService { @Override public boolean isSingleSessionActive(int userId) throws RemoteException { + ensureCaptureTvInputPermission(); final long identity = Binder.clearCallingIdentity(); final int callingUid = Binder.getCallingUid(); final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid, @@ -1959,6 +1958,14 @@ public final class TvInputManagerService extends SystemService { } } + private void ensureCaptureTvInputPermission() { + if (mContext.checkCallingPermission( + android.Manifest.permission.CAPTURE_TV_INPUT) + != PackageManager.PERMISSION_GRANTED) { + throw new SecurityException("Requires CAPTURE_TV_INPUT permission"); + } + } + @Override public void requestChannelBrowsable(Uri channelUri, int userId) throws RemoteException {