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

Commit e64a7d3f authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of ['googleplex-android-review.googlesource.com/23845784',...

Merge cherrypicks of ['googleplex-android-review.googlesource.com/23845784', 'googleplex-android-review.googlesource.com/23694643', 'googleplex-android-review.googlesource.com/23833763', 'googleplex-android-review.googlesource.com/23822674', 'googleplex-android-review.googlesource.com/23841140', 'googleplex-android-review.googlesource.com/23846528', 'googleplex-android-review.googlesource.com/23824651', 'googleplex-android-review.googlesource.com/23846298', 'googleplex-android-review.googlesource.com/23761845', 'googleplex-android-review.googlesource.com/23831344', 'googleplex-android-review.googlesource.com/23589157', 'googleplex-android-review.googlesource.com/23844590'] into udc-release.

Change-Id: I18810c58b0965180abde8af92e7b6338b43e728f
parents 1a578f8e 58286efb
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -2657,17 +2657,6 @@ public final class InputMethodManager {
            }
        }

        if (windowGainingFocus == null) {
            windowGainingFocus = view.getWindowToken();
            if (windowGainingFocus == null) {
                Log.e(TAG, "ABORT input: ServedView must be attached to a Window");
                return false;
            }
            startInputFlags = getStartInputFlags(view, startInputFlags);
            softInputMode = view.getViewRootImpl().mWindowAttributes.softInputMode;
            windowFlags = view.getViewRootImpl().mWindowAttributes.flags;
        }

        // Now we need to get an input connection from the served view.
        // This is complicated in a couple ways: we can't be holding our lock
        // when calling out to the view, and we need to make sure we call into
@@ -2690,6 +2679,17 @@ public final class InputMethodManager {
            return false;
        }

        if (windowGainingFocus == null) {
            windowGainingFocus = view.getWindowToken();
            if (windowGainingFocus == null) {
                Log.e(TAG, "ABORT input: ServedView must be attached to a Window");
                return false;
            }
            startInputFlags = getStartInputFlags(view, startInputFlags);
            softInputMode = view.getViewRootImpl().mWindowAttributes.softInputMode;
            windowFlags = view.getViewRootImpl().mWindowAttributes.flags;
        }

        // Okay we are now ready to call into the served view and have it
        // do its stuff.
        // Life is good: let's hook everything up!
+40 −16
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.telecom.TelecomManager;
import android.util.Log;
import android.util.Slog;
import android.view.View;
import android.widget.Button;
@@ -124,16 +125,19 @@ public class IntentForwarderActivity extends Activity {
        String className = intentReceived.getComponent().getClassName();
        final int targetUserId;
        final String userMessage;
        final UserInfo managedProfile;
        if (className.equals(FORWARD_INTENT_TO_PARENT)) {
            userMessage = getForwardToPersonalMessage();
            targetUserId = getProfileParent();
            managedProfile = null;

            getMetricsLogger().write(
                    new LogMaker(MetricsEvent.ACTION_SWITCH_SHARE_PROFILE)
                    .setSubtype(MetricsEvent.PARENT_PROFILE));
        } else if (className.equals(FORWARD_INTENT_TO_MANAGED_PROFILE)) {
            userMessage = getForwardToWorkMessage();
            targetUserId = getManagedProfile();
            managedProfile = getManagedProfile();
            targetUserId = managedProfile == null ? UserHandle.USER_NULL : managedProfile.id;

            getMetricsLogger().write(
                    new LogMaker(MetricsEvent.ACTION_SWITCH_SHARE_PROFILE)
@@ -142,6 +146,7 @@ public class IntentForwarderActivity extends Activity {
            Slog.wtf(TAG, IntentForwarderActivity.class.getName() + " cannot be called directly");
            userMessage = null;
            targetUserId = UserHandle.USER_NULL;
            managedProfile = null;
        }
        if (targetUserId == UserHandle.USER_NULL) {
            // This covers the case where there is no parent / managed profile.
@@ -185,27 +190,49 @@ public class IntentForwarderActivity extends Activity {
                        finish();
                    // When switching to the work profile, ask the user for consent before launching
                    } else if (className.equals(FORWARD_INTENT_TO_MANAGED_PROFILE)) {
                        maybeShowUserConsentMiniResolver(result, newIntent, targetUserId);
                        maybeShowUserConsentMiniResolver(result, newIntent, managedProfile);
                    }
                }, getApplicationContext().getMainExecutor());
    }

    private void maybeShowUserConsentMiniResolver(
            ResolveInfo target, Intent launchIntent, int targetUserId) {
            ResolveInfo target, Intent launchIntent, UserInfo managedProfile) {
        if (target == null || isIntentForwarderResolveInfo(target) || !isDeviceProvisioned()) {
            finish();
            return;
        }

        if (launchIntent.getBooleanExtra(EXTRA_SKIP_USER_CONFIRMATION, /* defaultValue= */ false)
                && getCallingPackage() != null
        int targetUserId = managedProfile == null ? UserHandle.USER_NULL : managedProfile.id;
        String callingPackage = getCallingPackage();
        boolean privilegedCallerAskedToSkipUserConsent =
                launchIntent.getBooleanExtra(
                        EXTRA_SKIP_USER_CONFIRMATION, /* defaultValue= */ false)
                        && callingPackage != null
                        && PERMISSION_GRANTED == getPackageManager().checkPermission(
                        INTERACT_ACROSS_USERS, getCallingPackage())) {
                              INTERACT_ACROSS_USERS, callingPackage);

        DevicePolicyManager devicePolicyManager =
                getSystemService(DevicePolicyManager.class);
        ComponentName profileOwnerName = devicePolicyManager.getProfileOwnerAsUser(targetUserId);
        boolean intentToLaunchProfileOwner = profileOwnerName != null
                && profileOwnerName.getPackageName().equals(target.getComponentInfo().packageName);

        if (privilegedCallerAskedToSkipUserConsent || intentToLaunchProfileOwner) {
            Log.i("IntentForwarderActivity", String.format(
                    "Skipping user consent for redirection into the managed profile for intent [%s]"
                            + ", privilegedCallerAskedToSkipUserConsent=[%s]"
                            + ", intentToLaunchProfileOwner=[%s]",
                    launchIntent, privilegedCallerAskedToSkipUserConsent,
                    intentToLaunchProfileOwner));
            startActivityAsCaller(launchIntent, targetUserId);
            finish();
            return;
        }

        Log.i("IntentForwarderActivity", String.format(
                "Showing user consent for redirection into the managed profile for intent [%s] and "
                        + " calling package [%s]",
                launchIntent, callingPackage));
        int layoutId = R.layout.miniresolver;
        setContentView(layoutId);

@@ -245,8 +272,7 @@ public class IntentForwarderActivity extends Activity {


        View telephonyInfo = findViewById(R.id.miniresolver_info_section);
        DevicePolicyManager devicePolicyManager =
                getSystemService(DevicePolicyManager.class);

        // Additional information section is work telephony specific. Therefore, it is only shown
        // for telephony related intents, when all sim subscriptions are in the work profile.
        if ((isDialerIntent(launchIntent) || isTextMessageIntent(launchIntent))
@@ -507,20 +533,18 @@ public class IntentForwarderActivity extends Activity {
    }

    /**
     * Returns the userId of the managed profile for this device or UserHandle.USER_NULL if there is
     * no managed profile.
     * Returns the managed profile for this device or null if there is no managed profile.
     *
     * TODO: Remove the assumption that there is only one managed profile
     * on the device.
     * TODO: Remove the assumption that there is only one managed profile on the device.
     */
    private int getManagedProfile() {
    @Nullable private UserInfo getManagedProfile() {
        List<UserInfo> relatedUsers = mInjector.getUserManager().getProfiles(UserHandle.myUserId());
        for (UserInfo userInfo : relatedUsers) {
            if (userInfo.isManagedProfile()) return userInfo.id;
            if (userInfo.isManagedProfile()) return userInfo;
        }
        Slog.wtf(TAG, FORWARD_INTENT_TO_MANAGED_PROFILE
                + " has been called, but there is no managed profile");
        return UserHandle.USER_NULL;
        return null;
    }

    /**
+2 −2
Original line number Diff line number Diff line
@@ -840,7 +840,7 @@ public class PipTransition extends PipTransitionController {
        }

        final Rect destinationBounds = mPipBoundsAlgorithm.getEntryDestinationBounds();
        final Rect currentBounds = taskInfo.configuration.windowConfiguration.getBounds();
        final Rect currentBounds = pipChange.getStartAbsBounds();
        int rotationDelta = deltaRotation(startRotation, endRotation);
        Rect sourceHintRect = PipBoundsAlgorithm.getValidSourceHintRect(
                taskInfo.pictureInPictureParams, currentBounds, destinationBounds);
@@ -1059,7 +1059,7 @@ public class PipTransition extends PipTransitionController {
        // When the PIP window is visible and being a part of the transition, such as display
        // rotation, we need to update its bounds and rounded corner.
        final SurfaceControl leash = pipChange.getLeash();
        final Rect destBounds = mPipBoundsState.getBounds();
        final Rect destBounds = mPipOrganizer.getCurrentOrAnimatingBounds();
        final boolean isInPip = mPipTransitionState.isInPip();
        mSurfaceTransactionHelper
                .crop(startTransaction, leash, destBounds)
+19 −9
Original line number Diff line number Diff line
@@ -2828,19 +2828,25 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
            }
        }

        if (shouldBreakPairedTaskInRecents(dismissReason)) {
            // Notify recents if we are exiting in a way that breaks the pair, and disable further
            // updates to splits in the recents until we enter split again
            mRecentTasks.ifPresent(recentTasks -> {
        final ArrayMap<Integer, SurfaceControl> dismissingTasks = new ArrayMap<>();
        for (int i = info.getChanges().size() - 1; i >= 0; --i) {
            final TransitionInfo.Change change = info.getChanges().get(i);
            final ActivityManager.RunningTaskInfo taskInfo = change.getTaskInfo();
                    if (taskInfo != null && (getStageOfTask(taskInfo) != null
                            || getSplitItemPosition(change.getLastParent())
                            != SPLIT_POSITION_UNDEFINED)) {
                        recentTasks.removeSplitPair(taskInfo.taskId);
            if (taskInfo == null) continue;
            if (getStageOfTask(taskInfo) != null
                    || getSplitItemPosition(change.getLastParent()) != SPLIT_POSITION_UNDEFINED) {
                dismissingTasks.put(taskInfo.taskId, change.getLeash());
            }
        }


        if (shouldBreakPairedTaskInRecents(dismissReason)) {
            // Notify recents if we are exiting in a way that breaks the pair, and disable further
            // updates to splits in the recents until we enter split again
            mRecentTasks.ifPresent(recentTasks -> {
                for (int i = dismissingTasks.keySet().size() - 1; i >= 0; --i) {
                    recentTasks.removeSplitPair(dismissingTasks.keyAt(i));
                }
            });
        }
        mSplitRequest = null;
@@ -2857,6 +2863,10 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
            t.hide(toStage == STAGE_TYPE_MAIN ? mSideStage.mRootLeash : mMainStage.mRootLeash);
            t.setPosition(toStage == STAGE_TYPE_MAIN
                    ? mMainStage.mRootLeash : mSideStage.mRootLeash, 0, 0);
        } else {
            for (int i = dismissingTasks.keySet().size() - 1; i >= 0; --i) {
                finishT.hide(dismissingTasks.valueAt(i));
            }
        }

        if (toStage == STAGE_TYPE_UNDEFINED) {
@@ -2866,7 +2876,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
        }

        // Hide divider and dim layer on transition finished.
        setDividerVisibility(false, finishT);
        setDividerVisibility(false, t);
        finishT.hide(mMainStage.mDimLayer);
        finishT.hide(mSideStage.mDimLayer);
    }
+2 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static android.window.TransitionInfo.FLAG_IS_WALLPAPER;

import static com.android.wm.shell.common.split.SplitScreenConstants.FLAG_IS_DIVIDER_BAR;
import static com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_UNDEFINED;
import static com.android.wm.shell.pip.PipAnimationController.ANIM_TYPE_ALPHA;
import static com.android.wm.shell.splitscreen.SplitScreen.STAGE_TYPE_UNDEFINED;
import static com.android.wm.shell.splitscreen.SplitScreenController.EXIT_REASON_CHILD_TASK_ENTER_PIP;
import static com.android.wm.shell.util.TransitionUtil.isOpeningType;
@@ -476,6 +477,7 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
                }
            }

            mPipHandler.setEnterAnimationType(ANIM_TYPE_ALPHA);
            mPipHandler.startEnterAnimation(pipChange, startTransaction, finishTransaction,
                    finishCB);
            // Dispatch the rest of the transition normally. This will most-likely be taken by
Loading