summaryrefslogtreecommitdiffstats
path: root/telecomm
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2015-05-04 17:07:32 -0700
committerYorke Lee <yorkelee@google.com>2015-05-04 17:11:46 -0700
commit6526f67e45fc810b8f4c7419eecf599d228f674f (patch)
treeede645ada38e24d8156d27dda08d35112d7cbd79 /telecomm
parentca030f8ed5fd52f2821d159b9c16d0c514dc0688 (diff)
downloadframeworks_base-6526f67e45fc810b8f4c7419eecf599d228f674f.zip
frameworks_base-6526f67e45fc810b8f4c7419eecf599d228f674f.tar.gz
frameworks_base-6526f67e45fc810b8f4c7419eecf599d228f674f.tar.bz2
Add hidden methods to set/get default dialer across users
First part of a set of changes to make the default dialer work across multiple users. This initial CL should not affect any user-facing behavior, just add new methods. Bug: 20696062 Change-Id: If1651240e185b4c09e960260c822c9265069fb9a
Diffstat (limited to 'telecomm')
-rw-r--r--telecomm/java/android/telecom/DefaultDialerManager.java51
1 files changed, 41 insertions, 10 deletions
diff --git a/telecomm/java/android/telecom/DefaultDialerManager.java b/telecomm/java/android/telecom/DefaultDialerManager.java
index b5d566a..fd0c06d 100644
--- a/telecomm/java/android/telecom/DefaultDialerManager.java
+++ b/telecomm/java/android/telecom/DefaultDialerManager.java
@@ -14,6 +14,7 @@
package android.telecom;
+import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
@@ -35,15 +36,27 @@ public class DefaultDialerManager {
private static final String TAG = "DefaultDialerManager";
/**
- * Sets the specified package name as the default dialer application. The caller of this method
- * needs to have permission to write to secure settings.
+ * Sets the specified package name as the default dialer application for the current user.
+ * The caller of this method needs to have permission to write to secure settings and
+ * manage users on the device.
*
* @hide
* */
public static void setDefaultDialerApplication(Context context, String packageName) {
+ setDefaultDialerApplication(context, packageName, ActivityManager.getCurrentUser());
+ }
+
+ /**
+ * Sets the specified package name as the default dialer application for the specified user.
+ * The caller of this method needs to have permission to write to secure settings and
+ * manage users on the device.
+ *
+ * @hide
+ * */
+ public static void setDefaultDialerApplication(Context context, String packageName, int user) {
// Get old package name
- String oldPackageName = Settings.Secure.getString(context.getContentResolver(),
- Settings.Secure.DIALER_DEFAULT_APPLICATION);
+ String oldPackageName = Settings.Secure.getStringForUser(context.getContentResolver(),
+ Settings.Secure.DIALER_DEFAULT_APPLICATION, user);
if (packageName != null && oldPackageName != null && packageName.equals(oldPackageName)) {
// No change
@@ -55,26 +68,44 @@ public class DefaultDialerManager {
if (packageNames.contains(packageName)) {
// Update the secure setting.
- Settings.Secure.putString(context.getContentResolver(),
- Settings.Secure.DIALER_DEFAULT_APPLICATION, packageName);
+ Settings.Secure.putStringForUser(context.getContentResolver(),
+ Settings.Secure.DIALER_DEFAULT_APPLICATION, packageName, user);
}
}
/**
- * Returns the installed dialer application that will be used to receive incoming calls, and is
- * allowed to make emergency calls.
+ * Returns the installed dialer application for the current user that will be used to receive
+ * incoming calls, and is allowed to make emergency calls.
*
* The application will be returned in order of preference:
* 1) User selected phone application (if still installed)
* 2) Pre-installed system dialer (if not disabled)
* 3) Null
*
+ * The caller of this method needs to have permission to manage users on the device.
+ *
* @hide
* */
public static String getDefaultDialerApplication(Context context) {
- String defaultPackageName = Settings.Secure.getString(context.getContentResolver(),
- Settings.Secure.DIALER_DEFAULT_APPLICATION);
+ return getDefaultDialerApplication(context, ActivityManager.getCurrentUser());
+ }
+ /**
+ * Returns the installed dialer application for the specified user that will be used to receive
+ * incoming calls, and is allowed to make emergency calls.
+ *
+ * The application will be returned in order of preference:
+ * 1) User selected phone application (if still installed)
+ * 2) Pre-installed system dialer (if not disabled)
+ * 3) Null
+ *
+ * The caller of this method needs to have permission to manage users on the device.
+ *
+ * @hide
+ * */
+ public static String getDefaultDialerApplication(Context context, int user) {
+ String defaultPackageName = Settings.Secure.getStringForUser(context.getContentResolver(),
+ Settings.Secure.DIALER_DEFAULT_APPLICATION, user);
final List<String> packageNames = getInstalledDialerApplications(context);