diff options
author | Yorke Lee <yorkelee@google.com> | 2015-04-23 15:58:27 -0700 |
---|---|---|
committer | Yorke Lee <yorkelee@google.com> | 2015-04-24 11:12:34 -0700 |
commit | 1011f4870c24659c78050c4165ac9aa6983b7b06 (patch) | |
tree | 71956d4b8ece720c2bcf8ac6bdfbd70f88b07d9b /telecomm | |
parent | 1ff1d3203f858c17b18dd2d9708dcd5b1adfbe4c (diff) | |
download | frameworks_base-1011f4870c24659c78050c4165ac9aa6983b7b06.zip frameworks_base-1011f4870c24659c78050c4165ac9aa6983b7b06.tar.gz frameworks_base-1011f4870c24659c78050c4165ac9aa6983b7b06.tar.bz2 |
Add APIs to getDefaultDialerPackage and getSystemDialerPackage
getDefaultDialerPackage is a public API and will be used by
apps to determine if they are the default dialer.
getSystemDialerPackage is a hidden API and is only used by
system components.
Also add new public string constants to allow apps to show
a dialog requesting that the user change the current default
dialer.
Bug: 20304458
Change-Id: I121d36741474c1fe171c372fb766a6c128228c9c
Diffstat (limited to 'telecomm')
3 files changed, 72 insertions, 3 deletions
diff --git a/telecomm/java/android/telecom/DefaultDialerManager.java b/telecomm/java/android/telecom/DefaultDialerManager.java index eef72fb..bf8fac6 100644 --- a/telecomm/java/android/telecom/DefaultDialerManager.java +++ b/telecomm/java/android/telecom/DefaultDialerManager.java @@ -87,15 +87,15 @@ public class DefaultDialerManager { } // No user-set dialer found, fallback to system dialer - ComponentName systemDialer = getTelecomManager(context).getDefaultPhoneApp(); + String systemDialer = getTelecomManager(context).getSystemDialerPackage(); - if (systemDialer == null) { + if (TextUtils.isEmpty(systemDialer)) { // No system dialer configured at build time return null; } // Verify that the system dialer has not been disabled. - return getComponentName(componentNames, systemDialer.getPackageName()); + return getComponentName(componentNames, systemDialer); } /** diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index fd95327..8d6bda8 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -110,6 +110,28 @@ public class TelecomManager { "android.telecom.action.PHONE_ACCOUNT_REGISTERED"; /** + * Activity action: Shows a dialog asking the user whether or not they want to replace the + * current default Dialer with the one specified in + * {@link #EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME}. + * + * Usage example: + * <pre> + * Intent intent = new Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER); + * intent.putExtra(TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME, + * getActivity().getPackageName()); + * startActivity(intent); + * </pre> + */ + public static final String ACTION_CHANGE_DEFAULT_DIALER = + "android.telecom.action.CHANGE_DEFAULT_DIALER"; + + /** + * Extra value used to provide the package name for {@link #ACTION_CHANGE_DEFAULT_DIALER}. + */ + public static final String EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME = + "android.telecom.extra.CHANGE_DEFAULT_DIALER_PACKAGE_NAME"; + + /** * 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. */ @@ -689,7 +711,10 @@ public class TelecomManager { } } + /** + * @deprecated - Use {@link TelecomManager#getDefaultDialerPackage} to directly access + * the default dialer's package name instead. * @hide */ @SystemApi @@ -705,6 +730,40 @@ public class TelecomManager { } /** + * Used to determine the currently selected default dialer package. + * + * @return package name for the default dialer package or null if no package has been + * selected as the default dialer. + */ + public String getDefaultDialerPackage() { + try { + if (isServiceConnected()) { + return getTelecomService().getDefaultDialerPackage(); + } + } catch (RemoteException e) { + Log.e(TAG, "RemoteException attempting to get the default dialer package name.", e); + } + return null; + } + + /** + * Used to determine the dialer package that is preloaded on the system partition. + * + * @return package name for the system dialer package or null if no system dialer is preloaded. + * @hide + */ + public String getSystemDialerPackage() { + try { + if (isServiceConnected()) { + return getTelecomService().getSystemDialerPackage(); + } + } catch (RemoteException e) { + Log.e(TAG, "RemoteException attempting to get the system dialer package name.", e); + } + return null; + } + + /** * Return whether a given phone number is the configured voicemail number for a * particular phone account. * diff --git a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl index 45b2482..49f2aad 100644 --- a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl +++ b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl @@ -137,6 +137,16 @@ interface ITelecomService { */ ComponentName getDefaultPhoneApp(); + /** + * @see TelecomServiceImpl#getDefaultDialerPackage + */ + String getDefaultDialerPackage(); + + /** + * @see TelecomServiceImpl#getSystemDialerPackage + */ + String getSystemDialerPackage(); + // // Internal system apis relating to call management. // |