diff options
Diffstat (limited to 'telecomm/java/android/telecom/TelecomManager.java')
-rw-r--r-- | telecomm/java/android/telecom/TelecomManager.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index b07b018f5a19..8b347ccdb9a8 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -14,6 +14,7 @@ package android.telecom; +import android.annotation.RequiresPermission; import android.annotation.SystemApi; import android.content.ComponentName; import android.content.Context; @@ -446,6 +447,8 @@ public class TelecomManager { private final Context mContext; + private final ITelecomService mTelecomServiceOverride; + /** * @hide */ @@ -457,12 +460,20 @@ public class TelecomManager { * @hide */ public TelecomManager(Context context) { + this(context, null); + } + + /** + * @hide + */ + public TelecomManager(Context context, ITelecomService telecomServiceImpl) { Context appContext = context.getApplicationContext(); if (appContext != null) { mContext = appContext; } else { mContext = context; } + mTelecomServiceOverride = telecomServiceImpl; } /** @@ -481,9 +492,12 @@ 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. */ + @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public PhoneAccountHandle getDefaultOutgoingPhoneAccount(String uriScheme) { try { if (isServiceConnected()) { @@ -615,9 +629,12 @@ 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. */ + @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public List<PhoneAccountHandle> getCallCapablePhoneAccounts() { return getCallCapablePhoneAccounts(false); } @@ -890,9 +907,12 @@ 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. */ + @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public boolean isVoiceMailNumber(PhoneAccountHandle accountHandle, String number) { try { if (isServiceConnected()) { @@ -908,10 +928,13 @@ 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. */ + @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getVoiceMailNumber(PhoneAccountHandle accountHandle) { try { if (isServiceConnected()) { @@ -927,9 +950,12 @@ public class TelecomManager { /** * Return the line 1 phone number for given phone account. * + * Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE} + * * @param accountHandle The handle for the account retrieve a number for. * @return A string representation of the line 1 phone number. */ + @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getLine1Number(PhoneAccountHandle accountHandle) { try { if (isServiceConnected()) { @@ -949,6 +975,7 @@ public class TelecomManager { * Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE} * </p> */ + @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public boolean isInCall() { try { if (isServiceConnected()) { @@ -1040,7 +1067,10 @@ public class TelecomManager { /** * Silences the ringer if a ringing call exists. + * + * Requires permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE} */ + @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void silenceRinger() { try { if (isServiceConnected()) { @@ -1145,9 +1175,12 @@ 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. */ + @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean handleMmi(String dialString) { ITelecomService service = getTelecomService(); if (service != null) { @@ -1168,10 +1201,13 @@ 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. */ + @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean handleMmi(String dialString, PhoneAccountHandle accountHandle) { ITelecomService service = getTelecomService(); if (service != null) { @@ -1186,11 +1222,14 @@ public class TelecomManager { } /** + * Requires permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE} + * * @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} * for the the content retrieve. */ + @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public Uri getAdnUriForPhoneAccount(PhoneAccountHandle accountHandle) { ITelecomService service = getTelecomService(); if (service != null && accountHandle != null) { @@ -1208,7 +1247,10 @@ 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() { ITelecomService service = getTelecomService(); if (service != null) { @@ -1230,6 +1272,7 @@ public class TelecomManager { * * @param showDialpad Brings up the in-call dialpad as part of showing the in-call screen. */ + @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public void showInCallScreen(boolean showDialpad) { ITelecomService service = getTelecomService(); if (service != null) { @@ -1271,6 +1314,7 @@ public class TelecomManager { * @param address The address to make the call to. * @param extras Bundle of extras to use with the call. */ + @RequiresPermission(android.Manifest.permission.CALL_PHONE) public void placeCall(Uri address, Bundle extras) { ITelecomService service = getTelecomService(); if (service != null) { @@ -1306,6 +1350,9 @@ public class TelecomManager { } private ITelecomService getTelecomService() { + if (mTelecomServiceOverride != null) { + return mTelecomServiceOverride; + } return ITelecomService.Stub.asInterface(ServiceManager.getService(Context.TELECOM_SERVICE)); } |