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

Commit ea6b64e6 authored by Achim Thesmann's avatar Achim Thesmann Committed by Android (Google) Code Review
Browse files

Merge "Reuse merged token and add additional checks." into udc-dev

parents 1d7343ea 277a6a45
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -16,10 +16,13 @@

package com.android.server.am;

import static com.android.internal.util.Preconditions.checkArgument;
import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM;
import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.am.ActivityManagerService.MY_PID;

import static java.util.Objects.requireNonNull;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityManager;
@@ -63,7 +66,6 @@ import com.android.server.wm.WindowProcessListener;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * Full information about a particular process that
@@ -1350,16 +1352,19 @@ class ProcessRecord implements WindowProcessListener {
     * {@param originatingToken} if you have one such originating token, this is useful for tracing
     * back the grant in the case of the notification token.
     */
    void addOrUpdateBackgroundStartPrivileges(Binder entity,
            BackgroundStartPrivileges backgroundStartPrivileges) {
        Objects.requireNonNull(entity);
    void addOrUpdateBackgroundStartPrivileges(@NonNull Binder entity,
            @NonNull BackgroundStartPrivileges backgroundStartPrivileges) {
        requireNonNull(entity, "entity");
        requireNonNull(backgroundStartPrivileges, "backgroundStartPrivileges");
        checkArgument(backgroundStartPrivileges.allowsAny(),
                "backgroundStartPrivileges does not allow anything");
        mWindowProcessController.addOrUpdateBackgroundStartPrivileges(entity,
                backgroundStartPrivileges);
        setBackgroundStartPrivileges(entity, backgroundStartPrivileges);
    }

    void removeBackgroundStartPrivileges(Binder entity) {
        Objects.requireNonNull(entity);
    void removeBackgroundStartPrivileges(@NonNull Binder entity) {
        requireNonNull(entity, "entity");
        mWindowProcessController.removeBackgroundStartPrivileges(entity);
        setBackgroundStartPrivileges(entity, null);
    }
+4 −3
Original line number Diff line number Diff line
@@ -850,10 +850,11 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
            mAppForAllowingBgActivityStartsByStart =
                    mBackgroundStartPrivilegesByStartMerged.allowsAny()
                    ? proc : null;
            if (mBackgroundStartPrivilegesByStartMerged.allowsAny()
                    || mIsAllowedBgActivityStartsByBinding) {
            BackgroundStartPrivileges backgroundStartPrivileges =
                    getBackgroundStartPrivilegesWithExclusiveToken();
            if (backgroundStartPrivileges.allowsAny()) {
                proc.addOrUpdateBackgroundStartPrivileges(this,
                        getBackgroundStartPrivilegesWithExclusiveToken());
                        backgroundStartPrivileges);
            } else {
                proc.removeBackgroundStartPrivileges(this);
            }
+5 −4
Original line number Diff line number Diff line
@@ -254,11 +254,12 @@ class BackgroundLaunchProcessController {
     *
     * If {@code entity} is already added, this method will update its {@code originatingToken}.
     */
    void addOrUpdateAllowBackgroundStartPrivileges(
            Binder entity, BackgroundStartPrivileges backgroundStartPrivileges) {
    void addOrUpdateAllowBackgroundStartPrivileges(@NonNull Binder entity,
            @NonNull BackgroundStartPrivileges backgroundStartPrivileges) {
        requireNonNull(entity, "entity");
        requireNonNull(backgroundStartPrivileges, "backgroundStartPrivileges");
        checkArgument(backgroundStartPrivileges.allowsAny());
        checkArgument(backgroundStartPrivileges.allowsAny(),
                "backgroundStartPrivileges does not allow anything");
        synchronized (this) {
            if (mBackgroundStartPrivileges == null) {
                mBackgroundStartPrivileges = new ArrayMap<>();
@@ -271,7 +272,7 @@ class BackgroundLaunchProcessController {
     * Removes token {@code entity} that allowed background activity starts added via {@link
     * #addOrUpdateAllowBackgroundStartPrivileges(Binder, BackgroundStartPrivileges)}.
     */
    void removeAllowBackgroundStartPrivileges(Binder entity) {
    void removeAllowBackgroundStartPrivileges(@NonNull Binder entity) {
        requireNonNull(entity, "entity");
        synchronized (this) {
            if (mBackgroundStartPrivileges != null) {
+10 −3
Original line number Diff line number Diff line
@@ -45,6 +45,8 @@ import static com.android.server.wm.ActivityTaskManagerService.RELAUNCH_REASON_N
import static com.android.server.wm.BackgroundActivityStartController.BAL_BLOCK;
import static com.android.server.wm.WindowManagerService.MY_PID;

import static java.util.Objects.requireNonNull;

import android.Manifest;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -559,14 +561,19 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
     * @see BackgroundLaunchProcessController#addOrUpdateAllowBackgroundStartPrivileges(Binder,
     * BackgroundStartPrivileges)
     */
    public void addOrUpdateBackgroundStartPrivileges(Binder entity,
            BackgroundStartPrivileges backgroundStartPrivileges) {
    public void addOrUpdateBackgroundStartPrivileges(@NonNull Binder entity,
            @NonNull BackgroundStartPrivileges backgroundStartPrivileges) {
        requireNonNull(entity, "entity");
        requireNonNull(backgroundStartPrivileges, "backgroundStartPrivileges");
        checkArgument(backgroundStartPrivileges.allowsAny(),
                "backgroundStartPrivileges does not allow anything");
        mBgLaunchController.addOrUpdateAllowBackgroundStartPrivileges(entity,
                backgroundStartPrivileges);
    }

    /** @see BackgroundLaunchProcessController#removeAllowBackgroundStartPrivileges(Binder) */
    public void removeBackgroundStartPrivileges(Binder entity) {
    public void removeBackgroundStartPrivileges(@NonNull Binder entity) {
        requireNonNull(entity, "entity");
        mBgLaunchController.removeAllowBackgroundStartPrivileges(entity);
    }