Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b401a94d authored by Tony Mak's avatar Tony Mak
Browse files

Make getInstalledDialerApplications to query for specific user

BUG=26634502

Change-Id: I8fe5506589bae85e3babba1aaab3b737cd12543b
parent b73e7ccd
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -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.