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
This commit is contained in:
Yorke Lee
2015-04-23 15:58:27 -07:00
parent 1ff1d3203f
commit 1011f4870c
5 changed files with 79 additions and 4 deletions

View File

@@ -109,6 +109,28 @@ public class TelecomManager {
public static final String ACTION_PHONE_ACCOUNT_REGISTERED =
"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
@@ -704,6 +729,40 @@ public class TelecomManager {
return null;
}
/**
* 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.