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

Commit a7316fd6 authored by Himanshu Gupta's avatar Himanshu Gupta
Browse files

Redirecting PhotoPicker Intent for Clone Profile

Adding `MediaStore.ACTION_PICK_IMAGES` to redirect to main
user, when launched from clone profile, allowing
PhotoPicker to be launched from Apps in Clone Profile.

Work Profile already redirects the same intent.

Bug: 326031351
Test: Manual on device, with picker on clone profile
Flag: NA
Change-Id: Ie9d919e59ce857a03e204b81e075938084ca47a3
parent 8ba3cbca
Loading
Loading
Loading
Loading
+27 −1
Original line number Diff line number Diff line
@@ -20,6 +20,9 @@ import static android.content.pm.PackageManager.ONLY_IF_NO_MATCH_FOUND;
import static android.content.pm.PackageManager.SKIP_CURRENT_PROFILE;
import static android.speech.RecognizerIntent.ACTION_RECOGNIZE_SPEECH;

import static com.android.server.pm.CrossProfileIntentFilter.FLAG_ALLOW_CHAINED_RESOLUTION;
import static com.android.server.pm.CrossProfileIntentFilter.FLAG_IS_PACKAGE_FOR_FILTER;

import android.content.Intent;
import android.hardware.usb.UsbManager;
import android.provider.AlarmClock;
@@ -613,6 +616,27 @@ public class DefaultCrossProfileIntentFiltersUtils {
                    .addDataScheme("mmsto")
                    .build();

    private static final DefaultCrossProfileIntentFilter CLONE_TO_PARENT_ACTION_PICK_IMAGES =
            new DefaultCrossProfileIntentFilter.Builder(
                    DefaultCrossProfileIntentFilter.Direction.TO_PARENT,
                    /* flags= */ FLAG_IS_PACKAGE_FOR_FILTER | FLAG_ALLOW_CHAINED_RESOLUTION,
                    /* letsPersonalDataIntoProfile= */ false)
                    .addAction(MediaStore.ACTION_PICK_IMAGES)
                    .addCategory(Intent.CATEGORY_DEFAULT)
                    .build();

    private static final DefaultCrossProfileIntentFilter
            CLONE_TO_PARENT_ACTION_PICK_IMAGES_WITH_DATA_TYPES =
            new DefaultCrossProfileIntentFilter.Builder(
                    DefaultCrossProfileIntentFilter.Direction.TO_PARENT,
                    /* flags= */ FLAG_IS_PACKAGE_FOR_FILTER | FLAG_ALLOW_CHAINED_RESOLUTION,
                    /* letsPersonalDataIntoProfile= */ false)
                    .addAction(MediaStore.ACTION_PICK_IMAGES)
                    .addCategory(Intent.CATEGORY_DEFAULT)
                    .addDataType("image/*")
                    .addDataType("video/*")
                    .build();

    public static List<DefaultCrossProfileIntentFilter> getDefaultCloneProfileFilters() {
        return Arrays.asList(
                PARENT_TO_CLONE_SEND_ACTION,
@@ -626,7 +650,9 @@ public class DefaultCrossProfileIntentFiltersUtils {
                CLONE_TO_PARENT_PICK_INSERT_ACTION,
                CLONE_TO_PARENT_DIAL_DATA,
                CLONE_TO_PARENT_SMS_MMS,
                CLONE_TO_PARENT_PHOTOPICKER_SELECTION
                CLONE_TO_PARENT_PHOTOPICKER_SELECTION,
                CLONE_TO_PARENT_ACTION_PICK_IMAGES,
                CLONE_TO_PARENT_ACTION_PICK_IMAGES_WITH_DATA_TYPES
        );
    }
}