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

Commit 0907bd67 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Prevent INTERACT_ACROSS_USERS exception in DefaultDialerManager.

When TelecomManager methods perform a read phonestate check from a work
profile user, it is possible to get an INTERACT_ACROSS_USERS exception.
This is due to the fact that the filterByIntent method was not calling
queryIntentActivitiesAsUser.

Test: Manual
Bug: 31304557
Change-Id: I2a1869162e5a52aed986a99cc378a6c630af4a70
parent 70f7bc45
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -170,7 +170,7 @@ public class DefaultDialerManager {

        final Intent dialIntentWithTelScheme = new Intent(Intent.ACTION_DIAL);
        dialIntentWithTelScheme.setData(Uri.fromParts(PhoneAccount.SCHEME_TEL, "", null));
        return filterByIntent(context, packageNames, dialIntentWithTelScheme);
        return filterByIntent(context, packageNames, dialIntentWithTelScheme, userId);
    }

    public static List<String> getInstalledDialerApplications(Context context) {
@@ -204,17 +204,18 @@ public class DefaultDialerManager {
     *
     * @param context A valid context
     * @param packageNames List of package names to filter.
     * @param userId The UserId
     * @return The filtered list.
     */
    private static List<String> filterByIntent(Context context, List<String> packageNames,
            Intent intent) {
            Intent intent, int userId) {
        if (packageNames == null || packageNames.isEmpty()) {
            return new ArrayList<>();
        }

        final List<String> result = new ArrayList<>();
        final List<ResolveInfo> resolveInfoList = context.getPackageManager()
                .queryIntentActivities(intent, 0);
                .queryIntentActivitiesAsUser(intent, 0, userId);
        final int length = resolveInfoList.size();
        for (int i = 0; i < length; i++) {
            final ActivityInfo info = resolveInfoList.get(i).activityInfo;