Merge "Make getInstalledDialerApplications to query for specific user"

This commit is contained in:
Tony Mak
2016-01-19 23:08:30 +00:00
committed by Android (Google) Code Review

View File

@@ -21,6 +21,7 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Process;
import android.provider.Settings;
import android.text.TextUtils;
@@ -150,12 +151,13 @@ public class DefaultDialerManager {
*
* @hide
**/
public static List<String> getInstalledDialerApplications(Context context) {
public static List<String> getInstalledDialerApplications(Context context, int userId) {
PackageManager packageManager = context.getPackageManager();
// Get the list of apps registered for the DIAL intent with empty scheme
Intent intent = new Intent(Intent.ACTION_DIAL);
List<ResolveInfo> resolveInfoList = packageManager.queryIntentActivities(intent, 0);
List<ResolveInfo> resolveInfoList =
packageManager.queryIntentActivitiesAsUser(intent, 0, userId);
List<String> packageNames = new ArrayList<>();
@@ -171,6 +173,10 @@ public class DefaultDialerManager {
return filterByIntent(context, packageNames, dialIntentWithTelScheme);
}
public static List<String> getInstalledDialerApplications(Context context) {
return getInstalledDialerApplications(context, Process.myUserHandle().getIdentifier());
}
/**
* Determines if the package name belongs to the user-selected default dialer or the preloaded
* system dialer, and thus should be allowed to perform certain privileged operations.