diff options
| -rwxr-xr-x | api/system-current.txt | 3 | ||||
| -rw-r--r-- | core/java/android/permission/PermissionManager.java | 68 | ||||
| -rw-r--r-- | telephony/common/com/android/internal/telephony/util/TelephonyUtils.java | 10 |
3 files changed, 81 insertions, 0 deletions
diff --git a/api/system-current.txt b/api/system-current.txt index 09684d8809e4..1dadc332d108 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -7714,7 +7714,10 @@ package android.permission { public final class PermissionManager { method @IntRange(from=0) @RequiresPermission(android.Manifest.permission.ADJUST_RUNTIME_PERMISSIONS_POLICY) public int getRuntimePermissionsVersion(); method @NonNull public java.util.List<android.permission.PermissionManager.SplitPermissionInfo> getSplitPermissions(); + method @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS_TO_TELEPHONY_DEFAULTS) public void grantDefaultPermissionsToEnabledImsServices(@NonNull String[], @NonNull android.os.UserHandle, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Boolean>); + method @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS_TO_TELEPHONY_DEFAULTS) public void grantDefaultPermissionsToEnabledTelephonyDataServices(@NonNull String[], @NonNull android.os.UserHandle, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Boolean>); method @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS_TO_TELEPHONY_DEFAULTS) public void grantDefaultPermissionsToLuiApp(@NonNull String, @NonNull android.os.UserHandle, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Boolean>); + method @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS_TO_TELEPHONY_DEFAULTS) public void revokeDefaultPermissionsFromDisabledTelephonyDataServices(@NonNull String[], @NonNull android.os.UserHandle, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Boolean>); method @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS_TO_TELEPHONY_DEFAULTS) public void revokeDefaultPermissionsFromLuiApps(@NonNull String[], @NonNull android.os.UserHandle, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Boolean>); method @RequiresPermission(android.Manifest.permission.ADJUST_RUNTIME_PERMISSIONS_POLICY) public void setRuntimePermissionsVersion(@IntRange(from=0) int); method @RequiresPermission(android.Manifest.permission.MANAGE_ONE_TIME_PERMISSION_SESSIONS) public void startOneTimePermissionSession(@NonNull String, long, int, int); diff --git a/core/java/android/permission/PermissionManager.java b/core/java/android/permission/PermissionManager.java index 258329203bdb..5a1ba7fe534c 100644 --- a/core/java/android/permission/PermissionManager.java +++ b/core/java/android/permission/PermissionManager.java @@ -160,6 +160,7 @@ public final class PermissionManager { * Grant default permissions to currently active LUI app * @param packageName The package name for the LUI app * @param user The user handle + * @param executor The executor for the callback * @param callback The callback provided by caller to be notified when grant completes * @hide */ @@ -181,6 +182,7 @@ public final class PermissionManager { * Revoke default permissions to currently active LUI app * @param packageNames The package names for the LUI apps * @param user The user handle + * @param executor The executor for the callback * @param callback The callback provided by caller to be notified when grant completes * @hide */ @@ -198,6 +200,72 @@ public final class PermissionManager { } } + /** + * Grant default permissions to currently active Ims services + * @param packageNames The package names for the Ims services + * @param user The user handle + * @param executor The executor for the callback + * @param callback The callback provided by caller to be notified when grant completes + * @hide + */ + @SystemApi + @RequiresPermission(Manifest.permission.GRANT_RUNTIME_PERMISSIONS_TO_TELEPHONY_DEFAULTS) + public void grantDefaultPermissionsToEnabledImsServices( + @NonNull String[] packageNames, @NonNull UserHandle user, + @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<Boolean> callback) { + try { + mPermissionManager.grantDefaultPermissionsToEnabledImsServices( + packageNames, user.getIdentifier()); + executor.execute(() -> callback.accept(true)); + } catch (RemoteException e) { + e.rethrowFromSystemServer(); + } + } + + /** + * Grant default permissions to currently enabled telephony data services + * @param packageNames The package name for the services + * @param user The user handle + * @param executor The executor for the callback + * @param callback The callback provided by caller to be notified when grant completes + * @hide + */ + @SystemApi + @RequiresPermission(Manifest.permission.GRANT_RUNTIME_PERMISSIONS_TO_TELEPHONY_DEFAULTS) + public void grantDefaultPermissionsToEnabledTelephonyDataServices( + @NonNull String[] packageNames, @NonNull UserHandle user, + @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<Boolean> callback) { + try { + mPermissionManager.grantDefaultPermissionsToEnabledTelephonyDataServices( + packageNames, user.getIdentifier()); + executor.execute(() -> callback.accept(true)); + } catch (RemoteException e) { + e.rethrowFromSystemServer(); + } + } + + /** + * Revoke default permissions to currently active telephony data services + * @param packageNames The package name for the services + * @param user The user handle + * @param executor The executor for the callback + * @param callback The callback provided by caller to be notified when revoke completes + * @hide + */ + @SystemApi + @RequiresPermission(Manifest.permission.GRANT_RUNTIME_PERMISSIONS_TO_TELEPHONY_DEFAULTS) + public void revokeDefaultPermissionsFromDisabledTelephonyDataServices( + @NonNull String[] packageNames, @NonNull UserHandle user, + @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<Boolean> callback) { + try { + mPermissionManager.revokeDefaultPermissionsFromDisabledTelephonyDataServices( + packageNames, user.getIdentifier()); + executor.execute(() -> callback.accept(true)); + } catch (RemoteException e) { + e.rethrowFromSystemServer(); + } + } + private List<SplitPermissionInfo> splitPermissionInfoListToNonParcelableList( List<SplitPermissionInfoParcelable> parcelableList) { final int size = parcelableList.size(); diff --git a/telephony/common/com/android/internal/telephony/util/TelephonyUtils.java b/telephony/common/com/android/internal/telephony/util/TelephonyUtils.java index 2abcc76fdccc..a7ad884ca107 100644 --- a/telephony/common/com/android/internal/telephony/util/TelephonyUtils.java +++ b/telephony/common/com/android/internal/telephony/util/TelephonyUtils.java @@ -28,6 +28,8 @@ import android.os.RemoteException; import android.os.SystemProperties; import java.io.PrintWriter; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import java.util.function.Supplier; /** @@ -137,4 +139,12 @@ public final class TelephonyUtils { } return ret; } + + /** Wait for latch to trigger */ + public static void waitUntilReady(CountDownLatch latch, long timeoutMs) { + try { + latch.await(timeoutMs, TimeUnit.MILLISECONDS); + } catch (InterruptedException ignored) { + } + } } |