diff options
author | 2024-03-04 07:14:26 +0000 | |
---|---|---|
committer | 2024-03-04 07:14:26 +0000 | |
commit | dbb2887d541074af8e8539366e11810241618892 (patch) | |
tree | bc9f255f7fca9832367ca91618ba51e35ccb31ad | |
parent | fe843f87e792a9e19f42a0e705d2a12f2c4a4392 (diff) |
TelecomManager consolidate isInSelfManagedCall.
As per API feedback, consolidate TelecomManager#isInSelfManagedCall into
a single API which only takes a UserHandle and disregard the
hasCrossUserAccess parameter. Instead, the caller can specify
UserHandle.ALL in order to indicate that self managed calls across all
users should be checked.
Bug: 327029478
Bug: 311773409
Test: atest SelfManagedConnectionServiceTest
Change-Id: Icbffaf8d2a507f519eb2fda34106a359f1bddaf4
5 files changed, 8 insertions, 41 deletions
diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 2922dd9ef5ae..eae5fbc458ca 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -14199,7 +14199,6 @@ package android.telecom { method @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public java.util.List<android.telecom.PhoneAccountHandle> getPhoneAccountsSupportingScheme(String); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean isInEmergencyCall(); method @FlaggedApi("com.android.server.telecom.flags.telecom_resolve_hidden_dependencies") @RequiresPermission(allOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.INTERACT_ACROSS_USERS}, conditional=true) public boolean isInSelfManagedCall(@NonNull String, @NonNull android.os.UserHandle); - method @FlaggedApi("com.android.server.telecom.flags.telecom_resolve_hidden_dependencies") @RequiresPermission(allOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.INTERACT_ACROSS_USERS}, conditional=true) public boolean isInSelfManagedCall(@NonNull String, boolean); method @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public boolean isRinging(); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setUserSelectedOutgoingPhoneAccount(@Nullable android.telecom.PhoneAccountHandle); field public static final String ACTION_CURRENT_TTY_MODE_CHANGED = "android.telecom.action.CURRENT_TTY_MODE_CHANGED"; diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index 3a7ac0bd659d..c607d9775be9 100755 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -8206,7 +8206,7 @@ public class NotificationManagerService extends SystemService { try { return mTelecomManager.isInManagedCall() || mTelecomManager.isInSelfManagedCall(pkg, - /* hasCrossUserAccess */ true); + UserHandle.ALL); } catch (IllegalStateException ise) { // Telecom is not ready (this is likely early boot), so there are no calls. return false; diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java index e3ea55a67e71..cf05f4106e38 100755 --- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java @@ -12008,7 +12008,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { // style + self managed call - bypasses block when(mTelecomManager.isInSelfManagedCall( - r.getSbn().getPackageName(), true)).thenReturn(true); + r.getSbn().getPackageName(), UserHandle.ALL)).thenReturn(true); assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(), r.getSbn().getId(), r.getSbn().getTag(), r, false, false)).isTrue(); @@ -12091,7 +12091,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { // style + self managed call - bypasses block mService.clearNotifications(); reset(mUsageStats); - when(mTelecomManager.isInSelfManagedCall(r.getSbn().getPackageName(), true)) + when(mTelecomManager.isInSelfManagedCall(r.getSbn().getPackageName(), UserHandle.ALL)) .thenReturn(true); mService.addEnqueuedNotification(r); diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index 9792cdd80a00..744b48ae39ea 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -2794,7 +2794,9 @@ public class TelecomManager { /** * Determines whether there are any ongoing {@link PhoneAccount#CAPABILITY_SELF_MANAGED} - * calls for a given {@code packageName} and {@code userHandle}. + * calls for a given {@code packageName} and {@code userHandle}. If UserHandle.ALL or a user + * that isn't the calling user is passed in, the caller will need to have granted the ability + * to interact across users. * * @param packageName the package name of the app to check calls for. * @param userHandle the user handle to check calls for. @@ -2813,41 +2815,7 @@ public class TelecomManager { if (service != null) { try { return service.isInSelfManagedCall(packageName, userHandle, - mContext.getOpPackageName(), false); - } catch (RemoteException e) { - Log.e(TAG, "RemoteException isInSelfManagedCall: " + e); - e.rethrowFromSystemServer(); - return false; - } - } else { - throw new IllegalStateException("Telecom service is not present"); - } - } - - /** - * Determines whether there are any ongoing {@link PhoneAccount#CAPABILITY_SELF_MANAGED} - * calls for a given {@code packageName} amongst all users, given that detectForAllUsers is true - * and the caller has the ability to interact across users. If detectForAllUsers isn't enabled, - * the calls will be checked against the caller. - * - * @param packageName the package name of the app to check calls for. - * @param detectForAllUsers indicates if calls should be detected across all users. - * @return {@code true} if there are ongoing calls, {@code false} otherwise. - * @throws SecurityException if detectForAllUsers is true and the caller does not grant the - * ability to interact across users. - * @hide - */ - @SystemApi - @FlaggedApi(Flags.FLAG_TELECOM_RESOLVE_HIDDEN_DEPENDENCIES) - @RequiresPermission(allOf = {Manifest.permission.READ_PRIVILEGED_PHONE_STATE, - Manifest.permission.INTERACT_ACROSS_USERS}, conditional = true) - public boolean isInSelfManagedCall(@NonNull String packageName, - boolean detectForAllUsers) { - ITelecomService service = getTelecomService(); - if (service != null) { - try { - return service.isInSelfManagedCall(packageName, null, - mContext.getOpPackageName(), detectForAllUsers); + mContext.getOpPackageName()); } catch (RemoteException e) { Log.e(TAG, "RemoteException isInSelfManagedCall: " + e); e.rethrowFromSystemServer(); diff --git a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl index 302a472b77e4..112471b2af57 100644 --- a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl +++ b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl @@ -401,7 +401,7 @@ interface ITelecomService { * @see TelecomServiceImpl#isInSelfManagedCall */ boolean isInSelfManagedCall(String packageName, in UserHandle userHandle, - String callingPackage, boolean detectForAllUsers); + String callingPackage); /** * @see TelecomServiceImpl#addCall |