From 7a2b711b0036bfef45fab07bd15eba5f869393e2 Mon Sep 17 00:00:00 2001 From: sqian Date: Thu, 25 Feb 2021 20:40:12 +0000 Subject: Companion InCallService API review Test: atest; make docs Bug: 179116441 Change-Id: Id75e727f6c3fc42132a80f7258bf790be79acf19 Merged-In: Id75e727f6c3fc42132a80f7258bf790be79acf19 (cherry picked from commit d30bd60beb6e098b279ccb4a839c7ad89a1b6c64) --- telecomm/java/android/telecom/InCallService.java | 18 +++++++++++++++ telecomm/java/android/telecom/TelecomManager.java | 27 +++++++++++----------- .../android/internal/telecom/ITelecomService.aidl | 4 ++-- 3 files changed, 34 insertions(+), 15 deletions(-) (limited to 'telecomm') diff --git a/telecomm/java/android/telecom/InCallService.java b/telecomm/java/android/telecom/InCallService.java index 07de61759d59..0ff288b1ac63 100644 --- a/telecomm/java/android/telecom/InCallService.java +++ b/telecomm/java/android/telecom/InCallService.java @@ -138,6 +138,24 @@ import java.util.List; * } * } * } + * + * + *

+ *

Access to InCallService for Wearable Devices

+ *
    + * If your app is a third-party companion app and wants to access InCallService APIs, what your + * app could do are: + *

    + *

      + *
    1. Declare MANAGE_ONGOING_CALLS permission in your manifest + *
    2. Associate with a physical wearable device via the + * {@link android.companion.CompanionDeviceManager} API as a companion app. See: + * https://developer.android.com/guide/topics/connectivity/companion-device-pairing + *
    3. Implement this InCallService with BIND_INCALL_SERVICE permission + *
    + *
+ *

+ * * *

*

Showing the Incoming Call Notification

diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index 3f8b68305914..b0b5ba7a1d78 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -1649,24 +1649,25 @@ public class TelecomManager { } /** - * Returns whether the caller has {@link InCallService} access for companion apps. - * - * A companion app is an app associated with a physical wearable device via the - * {@link android.companion.CompanionDeviceManager} API. + * Returns whether the caller has {@link android.Manifest.permission#MANAGE_ONGOING_CALLS} + * permission. The permission can be obtained by associating with a physical wearable device + * via the {@link android.companion.CompanionDeviceManager} API as a companion app. If the + * caller app has the permission, it has {@link InCallService} access to manage ongoing calls. * * @return {@code true} if the caller has {@link InCallService} access for * companion app; {@code false} otherwise. */ - public boolean hasCompanionInCallServiceAccess() { - try { - if (isServiceConnected()) { - return getTelecomService().hasCompanionInCallServiceAccess( + public boolean hasManageOngoingCallsPermission() { + ITelecomService service = getTelecomService(); + if (service != null) { + try { + return service.hasManageOngoingCallsPermission( mContext.getOpPackageName()); - } - } catch (RemoteException e) { - Log.e(TAG, "RemoteException calling hasCompanionInCallServiceAccess().", e); - if (!isSystemProcess()) { - e.rethrowAsRuntimeException(); + } catch (RemoteException e) { + Log.e(TAG, "RemoteException calling hasManageOngoingCallsPermission().", e); + if (!isSystemProcess()) { + e.rethrowAsRuntimeException(); + } } } return false; diff --git a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl index 6dc096daf4ea..5afac2ec239a 100644 --- a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl +++ b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl @@ -179,9 +179,9 @@ interface ITelecomService { boolean isInCall(String callingPackage, String callingFeatureId); /** - * @see TelecomServiceImpl#hasCompanionInCallServiceAccess + * @see TelecomServiceImpl#hasManageOngoingCallsPermission */ - boolean hasCompanionInCallServiceAccess(String callingPackage); + boolean hasManageOngoingCallsPermission(String callingPackage); /** * @see TelecomServiceImpl#isInManagedCall -- cgit v1.2.3