From e8170d76b21ebcbfe3b21991d66802dd97935452 Mon Sep 17 00:00:00 2001 From: Wenhao Wang Date: Wed, 17 May 2023 15:51:29 -0700 Subject: [PATCH] [BIC] Filter out REQUEST_INSTALL_PACKAGES perm The installations via REQUEST_INSTALL_PACKAGES need users' approval by default. So we don't count them as background ones. Bug: 283130197 Test: BackgroundInstallControlServiceTest Change-Id: Iacab4de788e53d6fb7ddaa1a3f51eb7b83c06742 --- .../server/pm/BackgroundInstallControlService.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/services/core/java/com/android/server/pm/BackgroundInstallControlService.java b/services/core/java/com/android/server/pm/BackgroundInstallControlService.java index 0bb05aab43942..1b34c703f6631 100644 --- a/services/core/java/com/android/server/pm/BackgroundInstallControlService.java +++ b/services/core/java/com/android/server/pm/BackgroundInstallControlService.java @@ -231,6 +231,14 @@ public class BackgroundInstallControlService extends SystemService { return; } + // the installers without INSTALL_PACKAGES perm can't perform + // the installation in background. So we can just filter out them. + if (mPermissionManager.checkPermission(installerPackageName, + android.Manifest.permission.INSTALL_PACKAGES, + userId) != PackageManager.PERMISSION_GRANTED) { + return; + } + // convert up-time to current time. final long installTimestamp = System.currentTimeMillis() - (SystemClock.uptimeMillis() - appInfo.createTimestamp);