summaryrefslogtreecommitdiff
path: root/telecomm/java/android/telecom/TelecomManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'telecomm/java/android/telecom/TelecomManager.java')
-rw-r--r--telecomm/java/android/telecom/TelecomManager.java86
1 files changed, 35 insertions, 51 deletions
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index 1f3740b76d1c..da2d4d82481b 100644
--- a/telecomm/java/android/telecom/TelecomManager.java
+++ b/telecomm/java/android/telecom/TelecomManager.java
@@ -25,7 +25,6 @@ import android.annotation.SuppressAutoDoc;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.annotation.SystemService;
-import android.annotation.TestApi;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.ComponentName;
import android.content.Context;
@@ -33,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;
@@ -693,7 +693,6 @@ public class TelecomManager {
*
* @hide
*/
- @TestApi
@SystemApi
public static final int TTY_MODE_OFF = 0;
@@ -703,7 +702,6 @@ public class TelecomManager {
*
* @hide
*/
- @TestApi
@SystemApi
public static final int TTY_MODE_FULL = 1;
@@ -714,7 +712,6 @@ public class TelecomManager {
*
* @hide
*/
- @TestApi
@SystemApi
public static final int TTY_MODE_HCO = 2;
@@ -725,7 +722,6 @@ public class TelecomManager {
*
* @hide
*/
- @TestApi
@SystemApi
public static final int TTY_MODE_VCO = 3;
@@ -736,7 +732,6 @@ public class TelecomManager {
* TTY mode.
* @hide
*/
- @TestApi
@SystemApi
public static final String ACTION_CURRENT_TTY_MODE_CHANGED =
"android.telecom.action.CURRENT_TTY_MODE_CHANGED";
@@ -759,7 +754,6 @@ public class TelecomManager {
* plugged into the device.
* @hide
*/
- @TestApi
@SystemApi
public static final String EXTRA_CURRENT_TTY_MODE =
"android.telecom.extra.CURRENT_TTY_MODE";
@@ -771,7 +765,6 @@ public class TelecomManager {
* preferred TTY mode.
* @hide
*/
- @TestApi
@SystemApi
public static final String ACTION_TTY_PREFERRED_MODE_CHANGED =
"android.telecom.action.TTY_PREFERRED_MODE_CHANGED";
@@ -790,7 +783,6 @@ public class TelecomManager {
* </ul>
* @hide
*/
- @TestApi
@SystemApi
public static final String EXTRA_TTY_PREFERRED_MODE =
"android.telecom.extra.TTY_PREFERRED_MODE";
@@ -992,8 +984,6 @@ public class TelecomManager {
* <p>
* If no {@link PhoneAccount} fits the criteria above, this method will return {@code null}.
*
- * Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE}
- *
* @param uriScheme The URI scheme.
* @return The {@link PhoneAccountHandle} corresponding to the account to be used.
*/
@@ -1045,7 +1035,6 @@ public class TelecomManager {
* @hide
*/
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
- @TestApi
@SystemApi
public void setUserSelectedOutgoingPhoneAccount(@Nullable PhoneAccountHandle accountHandle) {
try {
@@ -1171,8 +1160,6 @@ public class TelecomManager {
* calls. The returned list includes only those accounts which have been explicitly enabled
* by the user.
*
- * Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE}
- *
* @see #EXTRA_PHONE_ACCOUNT_HANDLE
* @return A list of {@code PhoneAccountHandle} objects.
*/
@@ -1219,7 +1206,6 @@ public class TelecomManager {
* @hide
*/
@SystemApi
- @TestApi
@RequiresPermission(READ_PRIVILEGED_PHONE_STATE)
public @NonNull List<PhoneAccountHandle> getCallCapablePhoneAccounts(
boolean includeDisabledAccounts) {
@@ -1242,7 +1228,7 @@ public class TelecomManager {
* @hide
*/
@SystemApi
- @SuppressLint("Doclava125")
+ @SuppressLint("RequiresPermission")
public List<PhoneAccountHandle> getPhoneAccountsForPackage() {
try {
if (isServiceConnected()) {
@@ -1370,7 +1356,7 @@ public class TelecomManager {
* @hide
*/
@SystemApi
- @SuppressLint("Doclava125")
+ @SuppressLint("RequiresPermission")
public void clearPhoneAccounts() {
clearAccounts();
}
@@ -1380,7 +1366,7 @@ public class TelecomManager {
* @hide
*/
@SystemApi
- @SuppressLint("Doclava125")
+ @SuppressLint("RequiresPermission")
public void clearAccounts() {
try {
if (isServiceConnected()) {
@@ -1412,7 +1398,7 @@ public class TelecomManager {
* @hide
*/
@SystemApi
- @SuppressLint("Doclava125")
+ @SuppressLint("RequiresPermission")
public ComponentName getDefaultPhoneApp() {
try {
if (isServiceConnected()) {
@@ -1450,7 +1436,6 @@ public class TelecomManager {
* @hide
*/
@SystemApi
- @TestApi
@RequiresPermission(READ_PRIVILEGED_PHONE_STATE)
public @Nullable String getDefaultDialerPackage(@NonNull UserHandle userHandle) {
try {
@@ -1474,9 +1459,6 @@ public class TelecomManager {
* the specified package does not correspond to an installed dialer, or is already
* the default dialer.
*
- * Requires permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE}
- * Requires permission: {@link android.Manifest.permission#WRITE_SECURE_SETTINGS}
- *
* @hide
* @deprecated Use
* {@link android.app.role.RoleManager#addRoleHolderAsUser(String, String, int, UserHandle,
@@ -1520,8 +1502,6 @@ public class TelecomManager {
* Return whether a given phone number is the configured voicemail number for a
* particular phone account.
*
- * Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE}
- *
* @param accountHandle The handle for the account to check the voicemail number against
* @param number The number to look up.
*/
@@ -1541,8 +1521,6 @@ public class TelecomManager {
/**
* Return the voicemail number for a given phone account.
*
- * Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE}
- *
* @param accountHandle The handle for the phone account.
* @return The voicemail number for the phone account, and {@code null} if one has not been
* configured.
@@ -1594,8 +1572,6 @@ public class TelecomManager {
/**
* Returns whether there is an ongoing phone call (can be in dialing, ringing, active or holding
* states) originating from either a manager or self-managed {@link ConnectionService}.
- * <p>
- * Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE}
*
* @return {@code true} if there is an ongoing call in either a managed or self-managed
* {@link ConnectionService}, {@code false} otherwise.
@@ -1614,14 +1590,36 @@ 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.
* <p>
* If you also need to know if there are ongoing self-managed calls, use {@link #isInCall()}
* instead.
- * <p>
- * Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE}
*
* @return {@code true} if there is an ongoing call in a managed {@link ConnectionService},
* {@code false} otherwise.
@@ -1674,7 +1672,6 @@ public class TelecomManager {
* @hide
*/
@SystemApi
- @TestApi
@RequiresPermission(anyOf = {
READ_PRIVILEGED_PHONE_STATE,
android.Manifest.permission.READ_PHONE_STATE
@@ -1696,8 +1693,6 @@ public class TelecomManager {
* If there is a ringing call, calling this method rejects the ringing call. Otherwise the
* foreground call is ended.
* <p>
- * Requires permission {@link android.Manifest.permission#ANSWER_PHONE_CALLS}.
- * <p>
* Note: this method CANNOT be used to end ongoing emergency calls and will return {@code false}
* if an attempt is made to end an emergency call.
*
@@ -1727,9 +1722,6 @@ public class TelecomManager {
* the incoming call requests. This means, for example, that an incoming call requesting
* {@link VideoProfile#STATE_BIDIRECTIONAL} will be answered, accepting that state.
*
- * Requires permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE} or
- * {@link android.Manifest.permission#ANSWER_PHONE_CALLS}
- *
* @deprecated Companion apps for wearable devices should use the {@link InCallService} API
* instead.
*/
@@ -1752,9 +1744,6 @@ public class TelecomManager {
* If there is a ringing incoming call, this method accepts the call on behalf of the user,
* with the specified video state.
*
- * Requires permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE} or
- * {@link android.Manifest.permission#ANSWER_PHONE_CALLS}
- *
* @param videoState The desired video state to answer the call with.
* @deprecated Companion apps for wearable devices should use the {@link InCallService} API
* instead.
@@ -1832,7 +1821,6 @@ public class TelecomManager {
* @hide
*/
@SystemApi
- @TestApi
@RequiresPermission(READ_PRIVILEGED_PHONE_STATE)
public @TtyMode int getCurrentTtyMode() {
try {
@@ -1967,8 +1955,6 @@ public class TelecomManager {
* Requires that the method-caller be set as the system dialer app.
* </p>
*
- * Requires permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE}
- *
* @param dialString The digits to dial.
* @return True if the digits were processed as an MMI code, false otherwise.
*/
@@ -1993,8 +1979,6 @@ public class TelecomManager {
* Requires that the method-caller be set as the system dialer app.
* </p>
*
- * Requires permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE}
- *
* @param accountHandle The handle for the account the MMI code should apply to.
* @param dialString The digits to dial.
* @return True if the digits were processed as an MMI code, false otherwise.
@@ -2014,8 +1998,8 @@ public class TelecomManager {
}
/**
- * Requires permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE}
- *
+ * Returns a URI (with the content:// scheme) specific to the specified {@link PhoneAccount}
+ * for ADN content retrieval.
* @param accountHandle The handle for the account to derive an adn query URI for or
* {@code null} to return a URI which will use the default account.
* @return The URI (with the content:// scheme) specific to the specified {@link PhoneAccount}
@@ -2039,8 +2023,6 @@ public class TelecomManager {
* <p>
* Requires that the method-caller be set as the system dialer app.
* </p>
- *
- * Requires permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE}
*/
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public void cancelMissedCallsNotification() {
@@ -2246,7 +2228,6 @@ public class TelecomManager {
* @hide
*/
@SystemApi
- @TestApi
@NonNull
public Intent createLaunchEmergencyDialerIntent(@Nullable String number) {
ITelecomService service = getTelecomService();
@@ -2399,7 +2380,6 @@ public class TelecomManager {
* @hide
*/
@SystemApi
- @TestApi
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public boolean isInEmergencyCall() {
try {
@@ -2429,6 +2409,10 @@ public class TelecomManager {
}
}
+ private boolean isSystemProcess() {
+ return Process.myUid() == Process.SYSTEM_UID;
+ }
+
private ITelecomService getTelecomService() {
if (mTelecomServiceOverride != null) {
return mTelecomServiceOverride;