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

Commit e1161ab7 authored by Himanshu Gupta's avatar Himanshu Gupta Committed by Android (Google) Code Review
Browse files

Merge "Enable telephony and SMS intents redirection to the main user" into main

parents 4a18b507 dcd4e2b6
Loading
Loading
Loading
Loading
+71 −0
Original line number Diff line number Diff line
@@ -655,4 +655,75 @@ public class DefaultCrossProfileIntentFiltersUtils {
                CLONE_TO_PARENT_ACTION_PICK_IMAGES_WITH_DATA_TYPES
        );
    }

    /** Dial intent with mime type can be handled by either private profile or its parent user. */
    private static final DefaultCrossProfileIntentFilter DIAL_MIME_PRIVATE_PROFILE =
            new DefaultCrossProfileIntentFilter.Builder(
                    DefaultCrossProfileIntentFilter.Direction.TO_PARENT,
                    ONLY_IF_NO_MATCH_FOUND,
                    /* letsPersonalDataIntoProfile= */ false)
                    .addAction(Intent.ACTION_DIAL)
                    .addAction(Intent.ACTION_VIEW)
                    .addCategory(Intent.CATEGORY_DEFAULT)
                    .addCategory(Intent.CATEGORY_BROWSABLE)
                    .addDataType("vnd.android.cursor.item/phone")
                    .addDataType("vnd.android.cursor.item/phone_v2")
                    .addDataType("vnd.android.cursor.item/person")
                    .addDataType("vnd.android.cursor.dir/calls")
                    .addDataType("vnd.android.cursor.item/calls")
                    .build();

    /** Dial intent with data scheme can be handled by either private profile or its parent user. */
    private static final DefaultCrossProfileIntentFilter DIAL_DATA_PRIVATE_PROFILE =
            new DefaultCrossProfileIntentFilter.Builder(
                    DefaultCrossProfileIntentFilter.Direction.TO_PARENT,
                    ONLY_IF_NO_MATCH_FOUND,
                    /* letsPersonalDataIntoProfile= */ false)
                    .addAction(Intent.ACTION_DIAL)
                    .addAction(Intent.ACTION_VIEW)
                    .addCategory(Intent.CATEGORY_DEFAULT)
                    .addCategory(Intent.CATEGORY_BROWSABLE)
                    .addDataScheme("tel")
                    .addDataScheme("sip")
                    .addDataScheme("voicemail")
                    .build();

    /**
     * Dial intent with no data scheme or type can be handled by either private profile or its
     * parent user.
     */
    private static final DefaultCrossProfileIntentFilter DIAL_RAW_PRIVATE_PROFILE =
            new DefaultCrossProfileIntentFilter.Builder(
                    DefaultCrossProfileIntentFilter.Direction.TO_PARENT,
                    ONLY_IF_NO_MATCH_FOUND,
                    /* letsPersonalDataIntoProfile= */ false)
                    .addAction(Intent.ACTION_DIAL)
                    .addCategory(Intent.CATEGORY_DEFAULT)
                    .addCategory(Intent.CATEGORY_BROWSABLE)
                    .build();

    /** SMS and MMS can be handled by the private profile or by the parent user. */
    private static final DefaultCrossProfileIntentFilter SMS_MMS_PRIVATE_PROFILE =
            new DefaultCrossProfileIntentFilter.Builder(
                    DefaultCrossProfileIntentFilter.Direction.TO_PARENT,
                    ONLY_IF_NO_MATCH_FOUND,
                    /* letsPersonalDataIntoProfile= */ false)
                    .addAction(Intent.ACTION_VIEW)
                    .addAction(Intent.ACTION_SENDTO)
                    .addCategory(Intent.CATEGORY_DEFAULT)
                    .addCategory(Intent.CATEGORY_BROWSABLE)
                    .addDataScheme("sms")
                    .addDataScheme("smsto")
                    .addDataScheme("mms")
                    .addDataScheme("mmsto")
                    .build();

    public static List<DefaultCrossProfileIntentFilter> getDefaultPrivateProfileFilters() {
        return Arrays.asList(
                DIAL_MIME_PRIVATE_PROFILE,
                DIAL_DATA_PRIVATE_PROFILE,
                DIAL_RAW_PRIVATE_PROFILE,
                SMS_MMS_PRIVATE_PROFILE
        );
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -306,6 +306,7 @@ public final class UserTypeFactory {
                .setDarkThemeBadgeColors(
                        R.color.white)
                .setDefaultRestrictions(getDefaultProfileRestrictions())
                .setDefaultCrossProfileIntentFilters(getDefaultPrivateCrossProfileIntentFilter())
                .setDefaultUserProperties(new UserProperties.Builder()
                        .setStartWithParent(true)
                        .setCredentialShareableWithParent(true)
@@ -446,6 +447,11 @@ public final class UserTypeFactory {
        return DefaultCrossProfileIntentFiltersUtils.getDefaultCloneProfileFilters();
    }

    private static List<DefaultCrossProfileIntentFilter> getDefaultPrivateCrossProfileIntentFilter()
    {
        return DefaultCrossProfileIntentFiltersUtils.getDefaultPrivateProfileFilters();
    }

    /** Gets a default bundle, keyed by Settings.Secure String names, for non-managed profiles. */
    private static Bundle getDefaultNonManagedProfileSecureSettings() {
        final Bundle settings = new Bundle();