From 27bf43460a324af01c086c9b2afcc2118dd849f2 Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Fri, 25 Mar 2022 14:17:52 -0700 Subject: Add new TelecomManager method to check if a self-mgd app is in a call. Adding a new method which NotificationManager will use to check if a VOIP app is currently engaged in any self-managed calls. Structured to accept a package name and userhandle rather than a PhoneAccountHandle so that NotificationManager doesn't need to query all phone account handles to find the right one to pass in. NotificationMgr is part of the system service, so this @hide method is sufficient. We can consider making this a system API in the future when we mainline Telecom. Test: Manual test with Telecom test app to validate method behavior. Test: Added new unit test to exercise backing functionality for new method. Bug: 226959797 Change-Id: I74c0568ad2ec308fe50cada7315e3a677363cccc --- telecomm/java/android/telecom/TelecomManager.java | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'telecomm/java/android') diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index df114dbabe5b..e0f5b2095190 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -2600,6 +2600,33 @@ public class TelecomManager { return false; } + /** + * Determines whether there are any ongoing {@link PhoneAccount#CAPABILITY_SELF_MANAGED} + * calls for a given {@code packageName} and {@code userHandle}. + * + * @param packageName the package name of the app to check calls for. + * @param userHandle the user handle on which to check for calls. + * @return {@code true} if there are ongoing calls, {@code false} otherwise. + * @hide + */ + @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) + public boolean isInSelfManagedCall(@NonNull String packageName, + @NonNull UserHandle userHandle) { + ITelecomService service = getTelecomService(); + if (service != null) { + try { + return service.isInSelfManagedCall(packageName, userHandle, + mContext.getOpPackageName()); + } catch (RemoteException e) { + Log.e(TAG, "RemoteException isInSelfManagedCall: " + e); + e.rethrowFromSystemServer(); + return false; + } + } else { + throw new IllegalStateException("Telecom service is not present"); + } + } + /** * Handles {@link Intent#ACTION_CALL} intents trampolined from UserCallActivity. * @param intent The {@link Intent#ACTION_CALL} intent to handle. -- cgit v1.2.3-59-g8ed1b