summaryrefslogtreecommitdiffstats
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.java88
1 files changed, 67 insertions, 21 deletions
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index e87615e..4eac5ac 100644
--- a/telecomm/java/android/telecom/TelecomManager.java
+++ b/telecomm/java/android/telecom/TelecomManager.java
@@ -21,6 +21,7 @@ import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.telephony.TelephonyManager;
+import android.text.TextUtils;
import android.util.Log;
import com.android.internal.telecom.ITelecomService;
@@ -30,8 +31,17 @@ import java.util.Collections;
import java.util.List;
/**
- * Provides access to Telecom-related functionality.
- * TODO: Move this all into PhoneManager.
+ * Provides access to information about active calls and registration/call-management functionality.
+ * Apps can use methods in this class to determine the current call state. Apps can also register new
+ * {@link PhoneAccount}s and get a listing of existing {@link PhoneAccount}s.
+ * <p>
+ * Apps do not instantiate this class directly; instead, they retrieve a reference to an instance
+ * through {@link Context#getSystemService Context.getSystemService(Context.TELECOM_SERVICE)}.
+ * <p>
+ * Note that access to some telecom information is permission-protected. Your app cannot access the
+ * protected information or gain access to protected functionality unless it has the appropriate
+ * permissions declared in its manifest file. Where permissions apply, they are noted in the method
+ * descriptions.
*/
public class TelecomManager {
@@ -60,7 +70,6 @@ public class TelecomManager {
/**
* The {@link android.content.Intent} action used to configure a
* {@link android.telecom.ConnectionService}.
- * @hide
*/
public static final String ACTION_CONNECTION_SERVICE_CONFIGURE =
"android.telecom.action.CONNECTION_SERVICE_CONFIGURE";
@@ -74,7 +83,6 @@ public class TelecomManager {
/**
* The {@link android.content.Intent} action used to show the settings page used to configure
* {@link PhoneAccount} preferences.
- * @hide
*/
public static final String ACTION_CHANGE_PHONE_ACCOUNTS =
"android.telecom.action.CHANGE_PHONE_ACCOUNTS";
@@ -105,7 +113,6 @@ public class TelecomManager {
* {@link PhoneAccountHandle} to use when making the call.
* <p class="note">
* Retrieve with {@link android.content.Intent#getParcelableExtra(String)}.
- * @hide
*/
public static final String EXTRA_PHONE_ACCOUNT_HANDLE =
"android.telecom.extra.PHONE_ACCOUNT_HANDLE";
@@ -154,7 +161,6 @@ public class TelecomManager {
/**
* Optional extra for {@link android.telephony.TelephonyManager#ACTION_PHONE_STATE_CHANGED}
* containing the component name of the associated connection service.
- * @hide
*/
public static final String EXTRA_CONNECTION_SERVICE =
"android.telecom.extra.CONNECTION_SERVICE";
@@ -190,7 +196,6 @@ public class TelecomManager {
* {@link ConnectionService}s which interact with {@link RemoteConnection}s should only populate
* this if the {@link android.telephony.TelephonyManager#getLine1Number()} value, as that is the
* user's expected caller ID.
- * @hide
*/
public static final String EXTRA_CALL_BACK_NUMBER = "android.telecom.extra.CALL_BACK_NUMBER";
@@ -437,7 +442,6 @@ public class TelecomManager {
* {@code PhoneAccount}.
*
* @return The phone account handle of the current connection manager.
- * @hide
*/
public PhoneAccountHandle getConnectionManager() {
return getSimCallManager();
@@ -495,7 +499,6 @@ public class TelecomManager {
*
* @return {@code true} if the device has more than one account registered and {@code false}
* otherwise.
- * @hide
*/
public boolean hasMultipleCallCapableAccounts() {
return getCallCapablePhoneAccounts().size() > 1;
@@ -505,7 +508,6 @@ public class TelecomManager {
* Returns a list of all {@link PhoneAccount}s registered for the calling package.
*
* @return A list of {@code PhoneAccountHandle} objects.
- * @hide
*/
public List<PhoneAccountHandle> getPhoneAccountsForPackage() {
try {
@@ -524,7 +526,6 @@ public class TelecomManager {
*
* @param account The {@link PhoneAccountHandle}.
* @return The {@link PhoneAccount} object.
- * @hide
*/
public PhoneAccount getPhoneAccount(PhoneAccountHandle account) {
try {
@@ -592,12 +593,19 @@ public class TelecomManager {
}
/**
- * Register a {@link PhoneAccount} for use by the system.
+ * Register a {@link PhoneAccount} for use by the system. When registering
+ * {@link PhoneAccount}s, existing registrations will be overwritten if the
+ * {@link PhoneAccountHandle} matches that of a {@link PhoneAccount} which is already
+ * registered. Once registered, the {@link PhoneAccount} is listed to the user as an option
+ * when placing calls. The user may still need to enable the {@link PhoneAccount} within
+ * the phone app settings before the account is usable.
+ * <p>
+ * A {@link SecurityException} will be thrown if an app tries to register a
+ * {@link PhoneAccountHandle} where the package name specified within
+ * {@link PhoneAccountHandle#getComponentName()} does not match the package name of the app.
*
* @param account The complete {@link PhoneAccount}.
- * @hide
*/
- @SystemApi
public void registerPhoneAccount(PhoneAccount account) {
try {
if (isServiceConnected()) {
@@ -612,9 +620,7 @@ public class TelecomManager {
* Remove a {@link PhoneAccount} registration from the system.
*
* @param accountHandle A {@link PhoneAccountHandle} for the {@link PhoneAccount} to unregister.
- * @hide
*/
- @SystemApi
public void unregisterPhoneAccount(PhoneAccountHandle accountHandle) {
try {
if (isServiceConnected()) {
@@ -627,9 +633,7 @@ public class TelecomManager {
/**
* Remove all Accounts that belong to the calling package from the system.
- * @hide
*/
- @SystemApi
public void clearAccounts() {
try {
if (isServiceConnected()) {
@@ -641,6 +645,20 @@ public class TelecomManager {
}
/**
+ * Remove all Accounts that belong to the specified package from the system.
+ * @hide
+ */
+ public void clearAccountsForPackage(String packageName) {
+ try {
+ if (isServiceConnected() && !TextUtils.isEmpty(packageName)) {
+ getTelecomService().clearAccounts(packageName);
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelecomService#clearAccountsForPackage()", e);
+ }
+ }
+
+ /**
* @hide
*/
@SystemApi
@@ -683,7 +701,6 @@ public class TelecomManager {
* Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE}
* </p>
*/
- @SystemApi
public boolean isInCall() {
try {
if (isServiceConnected()) {
@@ -701,6 +718,11 @@ public class TelecomManager {
* {@link TelephonyManager#CALL_STATE_RINGING}
* {@link TelephonyManager#CALL_STATE_OFFHOOK}
* {@link TelephonyManager#CALL_STATE_IDLE}
+ *
+ * Note that this API does not require the
+ * {@link android.Manifest.permission#READ_PHONE_STATE} permission. This is intentional, to
+ * preserve the behavior of {@link TelephonyManager#getCallState()}, which also did not require
+ * the permission.
* @hide
*/
@SystemApi
@@ -834,9 +856,7 @@ public class TelecomManager {
* {@link #registerPhoneAccount}.
* @param extras A bundle that will be passed through to
* {@link ConnectionService#onCreateIncomingConnection}.
- * @hide
*/
- @SystemApi
public void addNewIncomingCall(PhoneAccountHandle phoneAccount, Bundle extras) {
try {
if (isServiceConnected()) {
@@ -875,6 +895,7 @@ public class TelecomManager {
* Processes the specified dial string as an MMI code.
* MMI codes are any sequence of characters entered into the dialpad that contain a "*" or "#".
* Some of these sequences launch special behavior through handled by Telephony.
+ * This method uses the default subscription.
* <p>
* Requires that the method-caller be set as the system dialer app.
* </p>
@@ -895,6 +916,31 @@ public class TelecomManager {
}
/**
+ * Processes the specified dial string as an MMI code.
+ * MMI codes are any sequence of characters entered into the dialpad that contain a "*" or "#".
+ * Some of these sequences launch special behavior through handled by Telephony.
+ * <p>
+ * Requires that the method-caller be set as the system dialer app.
+ * </p>
+ *
+ * @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.
+ *
+ */
+ public boolean handleMmi(PhoneAccountHandle accountHandle, String dialString) {
+ ITelecomService service = getTelecomService();
+ if (service != null) {
+ try {
+ return service.handlePinMmiForPhoneAccount(accountHandle, dialString);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelecomService#handlePinMmi", e);
+ }
+ }
+ return false;
+ }
+
+ /**
* Removes the missed-call notification if one is present.
* <p>
* Requires that the method-caller be set as the system dialer app.