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
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 @@
"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 @@
}
}
+
/**
+ * @deprecated - Use {@link TelecomManager#getDefaultDialerPackage} to directly access
+ * the default dialer's package name instead.
* @hide
*/
@SystemApi
@@ -705,6 +730,40 @@
}
/**
+ * 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.
*