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

Commit 725d9d5b authored by Liahav Eitan's avatar Liahav Eitan Committed by Android (Google) Code Review
Browse files

Merge "TestAPI to skip user confirmation dialog when launching cross-profile intents" into udc-dev

parents 6bdeb7af df340332
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -16,14 +16,17 @@

package com.android.internal.app;

import static android.Manifest.permission.INTERACT_ACROSS_USERS;
import static android.app.admin.DevicePolicyResources.Strings.Core.FORWARD_INTENT_TO_PERSONAL;
import static android.app.admin.DevicePolicyResources.Strings.Core.FORWARD_INTENT_TO_WORK;
import static android.content.pm.PackageManager.MATCH_DEFAULT_ONLY;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;

import static com.android.internal.app.ResolverActivity.EXTRA_CALLING_USER;
import static com.android.internal.app.ResolverActivity.EXTRA_SELECTED_PROFILE;

import android.annotation.Nullable;
import android.annotation.TestApi;
import android.app.Activity;
import android.app.ActivityThread;
import android.app.AppGlobals;
@@ -79,6 +82,10 @@ public class IntentForwarderActivity extends Activity {
    public static String FORWARD_INTENT_TO_MANAGED_PROFILE
            = "com.android.internal.app.ForwardIntentToManagedProfile";

    @TestApi
    public static final String EXTRA_SKIP_USER_CONFIRMATION =
            "com.android.internal.app.EXTRA_SKIP_USER_CONFIRMATION";

    private static final Set<String> ALLOWED_TEXT_MESSAGE_SCHEMES
            = new HashSet<>(Arrays.asList("sms", "smsto", "mms", "mmsto"));

@@ -181,6 +188,15 @@ public class IntentForwarderActivity extends Activity {
            return;
        }

        if (launchIntent.getBooleanExtra(EXTRA_SKIP_USER_CONFIRMATION, /* defaultValue= */ false)
                && getCallingPackage() != null
                && PERMISSION_GRANTED == getPackageManager().checkPermission(
                        INTERACT_ACROSS_USERS, getCallingPackage())) {
            startActivityAsCaller(launchIntent, targetUserId);
            finish();
            return;
        }

        int layoutId = R.layout.miniresolver;
        setContentView(layoutId);