diff options
Diffstat (limited to 'telecomm/java/android/telecom/TelecomManager.java')
-rw-r--r-- | telecomm/java/android/telecom/TelecomManager.java | 146 |
1 files changed, 134 insertions, 12 deletions
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index 47f5acbecaa3..8b5915ea0ae9 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -15,6 +15,8 @@ package android.telecom; import android.Manifest; +import android.annotation.IntDef; +import android.annotation.NonNull; import android.annotation.RequiresPermission; import android.annotation.SuppressAutoDoc; import android.annotation.SuppressLint; @@ -35,6 +37,8 @@ import android.util.Log; import com.android.internal.telecom.ITelecomService; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -186,6 +190,33 @@ public class TelecomManager { "android.telecom.extra.CHANGE_DEFAULT_DIALER_PACKAGE_NAME"; /** + * Broadcast intent action indicating that the current default call screening app has changed. + * + * The string extra {@link #EXTRA_DEFAULT_CALL_SCREENING_APP_COMPONENT_NAME} will contain the + * name of the Component of the previous or the new call screening app. + * + * The boolean extra {@link #EXTRA_IS_DEFAULT_CALL_SCREENING_APP} will indicate the component + * name in the String extra {@link #EXTRA_DEFAULT_CALL_SCREENING_APP_COMPONENT_NAME} is default + * call screening app or not. + */ + public static final String ACTION_DEFAULT_CALL_SCREENING_APP_CHANGED = + "android.telecom.action.DEFAULT_CALL_SCREENING_APP_CHANGED"; + + /** + * Extra value used with {@link #ACTION_DEFAULT_CALL_SCREENING_APP_CHANGED} broadcast to + * indicate the ComponentName of the call screening app which has changed. + */ + public static final String EXTRA_DEFAULT_CALL_SCREENING_APP_COMPONENT_NAME = + "android.telecom.extra.DEFAULT_CALL_SCREENING_APP_COMPONENT_NAME"; + + /** + * Extra value used with {@link #ACTION_DEFAULT_CALL_SCREENING_APP_CHANGED} broadcast to + * indicate whether an app is the default call screening app. + */ + public static final String EXTRA_IS_DEFAULT_CALL_SCREENING_APP = + "android.telecom.extra.IS_DEFAULT_CALL_SCREENING_APP"; + + /** * Optional extra for {@link android.content.Intent#ACTION_CALL} containing a boolean that * determines whether the speakerphone should be automatically turned on for an outgoing call. */ @@ -403,8 +434,10 @@ public class TelecomManager { * <p> * The phone number of the call used by Telecom to determine which call should be handed over. * @hide + * @deprecated Use the public handover APIs. See + * {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} for more information. */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 119305590) public static final String EXTRA_IS_HANDOVER = "android.telecom.extra.IS_HANDOVER"; /** @@ -518,11 +551,19 @@ public class TelecomManager { public static final char DTMF_CHARACTER_WAIT = ';'; /** + * @hide + */ + @IntDef(prefix = { "TTY_MODE_" }, + value = {TTY_MODE_OFF, TTY_MODE_FULL, TTY_MODE_HCO, TTY_MODE_VCO}) + @Retention(RetentionPolicy.SOURCE) + public @interface TtyMode {} + + /** * TTY (teletypewriter) mode is off. * * @hide */ - @UnsupportedAppUsage + @SystemApi public static final int TTY_MODE_OFF = 0; /** @@ -531,6 +572,7 @@ public class TelecomManager { * * @hide */ + @SystemApi public static final int TTY_MODE_FULL = 1; /** @@ -540,6 +582,7 @@ public class TelecomManager { * * @hide */ + @SystemApi public static final int TTY_MODE_HCO = 2; /** @@ -549,6 +592,7 @@ public class TelecomManager { * * @hide */ + @SystemApi public static final int TTY_MODE_VCO = 3; /** @@ -694,7 +738,7 @@ public class TelecomManager { /** * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public static TelecomManager from(Context context) { return (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); } @@ -817,8 +861,9 @@ public class TelecomManager { * @return The phone account handle of the current sim call manager. * * @hide + * @deprecated Use {@link #getSimCallManager()}. */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 119305590) public PhoneAccountHandle getSimCallManager(int userId) { try { if (isServiceConnected()) { @@ -919,10 +964,12 @@ public class TelecomManager { * Returns a list of {@link PhoneAccountHandle}s including those which have not been enabled * by the user. * + * @param includeDisabledAccounts When {@code true}, disabled phone accounts will be included, + * when {@code false}, only * @return A list of {@code PhoneAccountHandle} objects. * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 119305590) public List<PhoneAccountHandle> getCallCapablePhoneAccounts(boolean includeDisabledAccounts) { try { if (isServiceConnected()) { @@ -1145,7 +1192,7 @@ public class TelecomManager { /** * Used to set the default dialer package. * - * @param packageName to set the default dialer to.. + * @param packageName to set the default dialer to. * * @result {@code true} if the default dialer was successfully changed, {@code false} if * the specified package does not correspond to an installed dialer, or is already @@ -1156,7 +1203,10 @@ public class TelecomManager { * * @hide */ - @UnsupportedAppUsage + @SystemApi + @RequiresPermission(allOf = { + android.Manifest.permission.MODIFY_PHONE_STATE, + android.Manifest.permission.WRITE_SECURE_SETTINGS}) public boolean setDefaultDialer(String packageName) { try { if (isServiceConnected()) { @@ -1169,12 +1219,10 @@ public class TelecomManager { } /** - * Used to determine the dialer package that is preloaded on the system partition. + * Determines the package name of the system-provided default phone app. * * @return package name for the system dialer package or null if no system dialer is preloaded. - * @hide */ - @UnsupportedAppUsage public String getSystemDialerPackage() { try { if (isServiceConnected()) { @@ -1187,6 +1235,79 @@ public class TelecomManager { } /** + * Used to trigger display of the ChangeDefaultCallScreeningApp activity to prompt the user to + * change the call screening app. + * + * A {@link SecurityException} will be thrown if calling package name doesn't match the package + * of the passed {@link ComponentName} + * + * @param componentName to verify that the calling package name matches the package of the + * passed ComponentName. + */ + public void requestChangeDefaultCallScreeningApp(@NonNull ComponentName componentName) { + try { + if (isServiceConnected()) { + getTelecomService().requestChangeDefaultCallScreeningApp(componentName, mContext + .getOpPackageName()); + } + } catch (RemoteException e) { + Log.e(TAG, + "RemoteException calling ITelecomService#requestChangeDefaultCallScreeningApp.", + e); + } + } + + /** + * Used to verify that the passed ComponentName is default call screening app. + * + * @param componentName to verify that the package of the passed ComponentName matched the default + * call screening packageName. + * + * @return {@code true} if the passed componentName matches the default call screening's, {@code + * false} if the passed componentName is null, or it doesn't match default call screening's. + */ + public boolean isDefaultCallScreeningApp(ComponentName componentName) { + try { + if (isServiceConnected()) { + return getTelecomService().isDefaultCallScreeningApp(componentName); + } + } catch (RemoteException e) { + Log.e(TAG, + "RemoteException calling ITelecomService#isDefaultCallScreeningApp.", + e); + } + return false; + } + + /** + * Used to set the default call screening package. + * + * Requires permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE} Requires + * permission: {@link android.Manifest.permission#WRITE_SECURE_SETTINGS} + * + * A {@link IllegalArgumentException} will be thrown if the specified package and component name + * of {@link ComponentName} does't exist, or the specified component of {@link ComponentName} + * does't have {@link android.Manifest.permission#BIND_SCREENING_SERVICE}. + * + * @param componentName to set the default call screening to. + * @hide + */ + @RequiresPermission(anyOf = { + android.Manifest.permission.MODIFY_PHONE_STATE, + android.Manifest.permission.WRITE_SECURE_SETTINGS + }) + public void setDefaultCallScreeningApp(ComponentName componentName) { + try { + if (isServiceConnected()) { + getTelecomService().setDefaultCallScreeningApp(componentName); + } + } catch (RemoteException e) { + Log.e(TAG, + "RemoteException calling ITelecomService#setDefaultCallScreeningApp.", e); + } + } + + /** * Return whether a given phone number is the configured voicemail number for a * particular phone account. * @@ -1462,8 +1583,9 @@ public class TelecomManager { * - {@link TelecomManager#TTY_MODE_VCO} * @hide */ - @UnsupportedAppUsage - public int getCurrentTtyMode() { + @SystemApi + @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) + public @TtyMode int getCurrentTtyMode() { try { if (isServiceConnected()) { return getTelecomService().getCurrentTtyMode(mContext.getOpPackageName()); |