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

Commit 5d3dfbad authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Merge cherrypicks of [14651914, 14651880, 14651759, 14652210, 14651594,...

Merge cherrypicks of [14651914, 14651880, 14651759, 14652210, 14651594, 14651881, 14651915, 14651882, 14651883, 14651799, 14652154, 14651595, 14651760, 14652271, 14652272, 14652273, 14652056, 14651800, 14651801, 14651802, 14651884, 14651885, 14651886, 14652274, 14652275, 14652276, 14652277, 14652278, 14651894, 14651723, 14652211, 14651895, 14651916, 14651887, 14651888, 14651596, 14651889, 14652212, 14651761, 14652310, 14652311, 14651973, 14651974, 14652312, 14652313, 14651896, 14651803] into rvc-qpr3-release

Change-Id: I28774b63565cb22778502a0eb9810751575e2862
parents ba595d5d ee8cc6fd
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -396,6 +396,8 @@
    <protected-broadcast android:name="android.net.wifi.p2p.action.WIFI_P2P_PERSISTENT_GROUPS_CHANGED" />
    <protected-broadcast android:name="android.net.conn.TETHER_STATE_CHANGED" />
    <protected-broadcast android:name="android.net.conn.INET_CONDITION_ACTION" />
    <!-- This broadcast is no longer sent in S but it should stay protected to avoid third party
         apps broadcasting this and confusing old system apps that may not have been updated. -->
    <protected-broadcast android:name="android.net.conn.NETWORK_CONDITIONS_MEASURED" />
    <protected-broadcast
            android:name="android.net.ConnectivityService.action.PKT_CNT_SAMPLE_INTERVAL_ELAPSED" />
+22 −15
Original line number Diff line number Diff line
@@ -2293,10 +2293,11 @@ public class PermissionManagerService extends IPermissionManager.Stub {
        }

        final int callingUid = Binder.getCallingUid();
        final int userId = UserHandle.getUserId(newPackage.getUid());
        for (int userId: mUserManagerInt.getUserIds()) {
            int numRequestedPermissions = newPackage.getRequestedPermissions().size();
            for (int i = 0; i < numRequestedPermissions; i++) {
            PermissionInfo permInfo = getPermissionInfo(newPackage.getRequestedPermissions().get(i),
                PermissionInfo permInfo = getPermissionInfo(
                        newPackage.getRequestedPermissions().get(i),
                        newPackage.getPackageName(), 0);
                if (permInfo == null || !STORAGE_PERMISSIONS.contains(permInfo.name)) {
                    continue;
@@ -2308,8 +2309,14 @@ public class PermissionManagerService extends IPermissionManager.Stub {
                                + downgradedSdk + " or newly requested legacy full storage "
                                + newlyRequestsLegacy);

                try {
                    revokeRuntimePermissionInternal(permInfo.name, newPackage.getPackageName(),
                            false, callingUid, userId, null, permissionCallback);
                } catch (IllegalStateException | SecurityException e) {
                    Log.e(TAG, "unable to revoke " + permInfo.name + " for "
                            + newPackage.getPackageName() + " user " + userId, e);
                }
            }
        }

    }
+4 −2
Original line number Diff line number Diff line
@@ -554,8 +554,10 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
                    PackageInstaller.SessionInfo session = mContext.getPackageManager()
                            .getPackageInstaller().getSessionInfo(rollback.getStagedSessionId());
                    if (session == null || session.isStagedSessionFailed()) {
                        if (rollback.isEnabling()) {
                            iter.remove();
                            rollback.delete(mAppDataRollbackHelper);
                        }
                        continue;
                    }

+8 −32
Original line number Diff line number Diff line
@@ -3372,7 +3372,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
    }

    /**
     * Find all visible task stacks containing {@param userId} and intercept them with an activity
     * Find all task stacks containing {@param userId} and intercept them with an activity
     * to block out the contents and possibly start a credential-confirming intent.
     *
     * @param userId user handle for the locked managed profile.
@@ -3380,40 +3380,16 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
    void lockAllProfileTasks(@UserIdInt int userId) {
        mService.deferWindowLayout();
        try {
            final PooledConsumer c = PooledLambda.obtainConsumer(
                    RootWindowContainer::taskTopActivityIsUser, this, PooledLambda.__(Task.class),
                    userId);
            forAllLeafTasks(c, true /* traverseTopToBottom */);
            c.recycle();
        } finally {
            mService.continueWindowLayout();
        }
    }

    /**
     * Detects whether we should show a lock screen in front of this task for a locked user.
     * <p>
     * We'll do this if either of the following holds:
     * <ul>
     *   <li>The top activity explicitly belongs to {@param userId}.</li>
     *   <li>The top activity returns a result to an activity belonging to {@param userId}.</li>
     * </ul>
     *
     * @return {@code true} if the top activity looks like it belongs to {@param userId}.
     */
    private void taskTopActivityIsUser(Task task, @UserIdInt int userId) {
        // To handle the case that work app is in the task but just is not the top one.
        final ActivityRecord activityRecord = task.getTopNonFinishingActivity();
        final ActivityRecord resultTo = (activityRecord != null ? activityRecord.resultTo : null);

        // Check the task for a top activity belonging to userId, or returning a
        // result to an activity belonging to userId. Example case: a document
        // picker for personal files, opened by a work app, should still get locked.
        if ((activityRecord != null && activityRecord.mUserId == userId)
                || (resultTo != null && resultTo.mUserId == userId)) {
            forAllLeafTasks(task -> {
                if (task.getActivity(activity -> !activity.finishing && activity.mUserId == userId)
                        != null) {
                    mService.getTaskChangeNotificationController().notifyTaskProfileLocked(
                            task.mTaskId, userId);
                }
            }, true /* traverseTopToBottom */);
        } finally {
            mService.continueWindowLayout();
        }
    }

    void cancelInitializingActivities() {
+33 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE;
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR;
import static android.view.WindowManager.LayoutParams.TYPE_TOAST;

import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.server.wm.ActivityStack.ActivityState.FINISHING;
import static com.android.server.wm.ActivityStack.ActivityState.PAUSED;
import static com.android.server.wm.ActivityStack.ActivityState.PAUSING;
@@ -36,10 +37,13 @@ import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;

import android.app.WindowConfiguration;
import android.content.ComponentName;
import android.content.pm.ActivityInfo;
import android.os.UserHandle;
import android.platform.test.annotations.Presubmit;

import androidx.test.filters.SmallTest;
@@ -169,5 +173,34 @@ public class RootWindowContainerTests extends WindowTestsBase {
        activity.setState(FINISHING, "test FINISHING");
        assertThat(mWm.mRoot.allPausedActivitiesComplete()).isTrue();
    }

    @Test
    public void testLockAllProfileTasks() {
        // Make an activity visible with the user id set to 0
        DisplayContent displayContent = mWm.mRoot.getDisplayContent(DEFAULT_DISPLAY);
        TaskDisplayArea taskDisplayArea = displayContent.getTaskDisplayAreaAt(0);
        final ActivityStack stack = createTaskStackOnDisplay(WINDOWING_MODE_FULLSCREEN,
                ACTIVITY_TYPE_STANDARD, displayContent);
        final ActivityRecord activity = new ActivityTestsBase.ActivityBuilder(stack.mAtmService)
                .setStack(stack)
                .setUid(0)
                .setCreateTask(true)
                .build();

        // Create another activity on top and the user id is 1
        Task task = activity.getTask();
        final ActivityRecord topActivity = new ActivityTestsBase.ActivityBuilder(mWm.mAtmService)
                .setStack(stack)
                .setUid(UserHandle.PER_USER_RANGE + 1)
                .setTask(task)
                .build();

        // Make sure the listeners will be notified for putting the task to locked state
        TaskChangeNotificationController controller =
                mWm.mAtmService.getTaskChangeNotificationController();
        spyOn(controller);
        mWm.mRoot.lockAllProfileTasks(0);
        verify(controller).notifyTaskProfileLocked(eq(task.mTaskId), eq(0));
    }
}
Loading