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

Commit dcd4e2b6 authored by Olivier Nshimiye's avatar Olivier Nshimiye
Browse files

Enable telephony and SMS intents redirection to the main user

Bug: 325576602
Test: manual - Triggered messages intent with 'adb shell am start -a
android.intent.action.SENDTO -d sms:+440000000 --user 10' and telephony
with ' adb shell am start -a android.intent.action.DIAL --user 10'

Change-Id: I9dcca257676c40bd9d20b6a80fc52c7809bbf1b1
parent 8d2accbc
Loading
Loading
Loading
Loading
+71 −0
Original line number Diff line number Diff line
@@ -629,4 +629,75 @@ public class DefaultCrossProfileIntentFiltersUtils {
                CLONE_TO_PARENT_PHOTOPICKER_SELECTION
        );
    }

    /** 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();