summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/am/ProcessRecord.java17
-rw-r--r--services/core/java/com/android/server/am/ServiceRecord.java7
-rw-r--r--services/core/java/com/android/server/wm/BackgroundLaunchProcessController.java9
-rw-r--r--services/core/java/com/android/server/wm/WindowProcessController.java13
4 files changed, 30 insertions, 16 deletions
diff --git a/services/core/java/com/android/server/am/ProcessRecord.java b/services/core/java/com/android/server/am/ProcessRecord.java
index e651e23a5318..afae623cd217 100644
--- a/services/core/java/com/android/server/am/ProcessRecord.java
+++ b/services/core/java/com/android/server/am/ProcessRecord.java
@@ -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);
}
diff --git a/services/core/java/com/android/server/am/ServiceRecord.java b/services/core/java/com/android/server/am/ServiceRecord.java
index 18ef66febe89..edf0dbd65ef2 100644
--- a/services/core/java/com/android/server/am/ServiceRecord.java
+++ b/services/core/java/com/android/server/am/ServiceRecord.java
@@ -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);
}
diff --git a/services/core/java/com/android/server/wm/BackgroundLaunchProcessController.java b/services/core/java/com/android/server/wm/BackgroundLaunchProcessController.java
index 002c32ef32f6..e88cfbf6986e 100644
--- a/services/core/java/com/android/server/wm/BackgroundLaunchProcessController.java
+++ b/services/core/java/com/android/server/wm/BackgroundLaunchProcessController.java
@@ -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) {
diff --git a/services/core/java/com/android/server/wm/WindowProcessController.java b/services/core/java/com/android/server/wm/WindowProcessController.java
index c34aa2b336cd..85c601fe0a5c 100644
--- a/services/core/java/com/android/server/wm/WindowProcessController.java
+++ b/services/core/java/com/android/server/wm/WindowProcessController.java
@@ -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);
}