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

Commit 752ccc48 authored by Achim Thesmann's avatar Achim Thesmann
Browse files

Fix DragAndDropPolicy to use API

Use the ActivityOptions API instead of accessing the underlying Bundle.

The Bundle representing the ActivityOptions is internal and may change,
so accessing it directly should be avoided where possible.

Test: atest DragAndDropPolicyTest
Bug: 341140181
Flag: EXEMPT bugfix

Change-Id: I5962fdc8c33e692a992fd9c10e4bbb0465888186
parent 61e25300
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -16,10 +16,9 @@

package com.android.wm.shell.draganddrop;

import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED;
import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_DENIED;
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.app.ComponentOptions.KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED;
import static android.app.ComponentOptions.KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED_BY_PERMISSION;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.content.ClipDescription.EXTRA_ACTIVITY_OPTIONS;
@@ -47,7 +46,6 @@ import android.app.ActivityOptions;
import android.app.ActivityTaskManager;
import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.ClipDescription;
import android.content.Context;
import android.content.Intent;
@@ -265,13 +263,14 @@ public class DragAndDropPolicy {
        final boolean isShortcut = description.hasMimeType(MIMETYPE_APPLICATION_SHORTCUT);
        final ActivityOptions baseActivityOpts = ActivityOptions.makeBasic();
        baseActivityOpts.setDisallowEnterPictureInPictureWhileLaunching(true);
        // Put BAL flags to avoid activity start aborted.
        baseActivityOpts.setPendingIntentBackgroundActivityStartMode(
                MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
        baseActivityOpts.setPendingIntentBackgroundActivityLaunchAllowedByPermission(true);
        final Bundle opts = baseActivityOpts.toBundle();
        if (session.appData.hasExtra(EXTRA_ACTIVITY_OPTIONS)) {
            opts.putAll(session.appData.getBundleExtra(EXTRA_ACTIVITY_OPTIONS));
        }
        // Put BAL flags to avoid activity start aborted.
        opts.putBoolean(KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED, true);
        opts.putBoolean(KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED_BY_PERMISSION, true);
        final UserHandle user = session.appData.getParcelableExtra(EXTRA_USER);

        if (isTask) {