diff options
author | sqian <shuoq@google.com> | 2020-11-11 00:45:46 +0000 |
---|---|---|
committer | sqian <shuoq@google.com> | 2020-11-11 22:51:49 +0000 |
commit | dfb7ca01a8fb197da1a9fdf24b311a5680d08577 (patch) | |
tree | 682311b871f2465a4eb38383716911a19c6a1170 /telecomm/java/android/telecom/TelecomManager.java | |
parent | f50112039993a12754f3589eff70682b77b13fd1 (diff) |
Introduce hasCompanionInCallServiceAccess API
It retruns whether the caller has InCallService access for the companion
apps. A companion app is an app associated with a physical wearable
device via the {@link android.companion.CompanionDeviceManager} API.
Test: cts
Bug: 169595473
Change-Id: Id659bfae8556e965d3c31613848bde808f28a858
Merged-In: Id659bfae8556e965d3c31613848bde808f28a858
(cherry picked from commit 4d0652699a88ad60c2dfdbf7b59065ee684df6d6)
Diffstat (limited to 'telecomm/java/android/telecom/TelecomManager.java')
-rw-r--r-- | telecomm/java/android/telecom/TelecomManager.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index 724c17177f76..fbb1701dd52a 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -32,6 +32,7 @@ import android.content.Intent; import android.net.Uri; import android.os.Build; import android.os.Bundle; +import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; @@ -1589,6 +1590,30 @@ 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. + * + * @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( + mContext.getOpPackageName()); + } + } catch (RemoteException e) { + Log.e(TAG, "RemoteException calling hasCompanionInCallServiceAccess().", e); + if (!isSystemProcess()) { + e.rethrowAsRuntimeException(); + } + } + return false; + } + + /** * Returns whether there is an ongoing call originating from a managed * {@link ConnectionService}. An ongoing call can be in dialing, ringing, active or holding * states. @@ -2384,6 +2409,10 @@ public class TelecomManager { } } + private boolean isSystemProcess() { + return Process.myUid() == Process.SYSTEM_UID; + } + private ITelecomService getTelecomService() { if (mTelecomServiceOverride != null) { return mTelecomServiceOverride; |