Send broadcast when default dialer changes
Add hidden TelecomManager.setDefaultDialer for system apps
to set the default dialer and trigger the broadcast
Bug: 21846308
Change-Id: Ifdd30cd1323ab0157edf7fd966173b6c52df6ba0
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index 368e137..0cd8c19 100644
--- a/telecomm/java/android/telecom/TelecomManager.java
+++ b/telecomm/java/android/telecom/TelecomManager.java
@@ -124,6 +124,16 @@
"android.telecom.action.CHANGE_DEFAULT_DIALER";
/**
+ * Broadcast intent action indicating that the current default dialer has changed.
+ * The string extra {@link #EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME} will contain the
+ * name of the package that the default dialer was changed to.
+ *
+ * @see #EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME
+ */
+ public static final String ACTION_DEFAULT_DIALER_CHANGED =
+ "android.telecom.action.DEFAULT_DIALER_CHANGED";
+
+ /**
* Extra value used to provide the package name for {@link #ACTION_CHANGE_DEFAULT_DIALER}.
*/
public static final String EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME =
@@ -774,6 +784,31 @@
}
/**
+ * Used to set the default dialer package.
+ *
+ * @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
+ * the default dialer.
+ *
+ * Requires permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE}
+ * Requires permission: {@link android.Manifest.permission#WRITE_SECURE_SETTINGS}
+ *
+ * @hide
+ */
+ public boolean setDefaultDialer(String packageName) {
+ try {
+ if (isServiceConnected()) {
+ return getTelecomService().setDefaultDialer(packageName);
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "RemoteException attempting to set the default dialer.", e);
+ }
+ return false;
+ }
+
+ /**
* 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.