From b0432c1fb5b2a0db8976d13cd9e1deab8b89ca8e Mon Sep 17 00:00:00 2001 From: Winson Date: Mon, 1 Feb 2021 09:05:06 -0800 Subject: [PATCH] Hook onUserUnlocked to verify no response packages Old v1 verification agents will not be boot aware, and thus cannot begin boot time verification until the user unlocks their device. To support them, this sends the broadcast once the user is unlocked and decrypted credential storage is available. The boot broadcast is maintained in case the verification agent is somehow direct boot aware, allowing it to start verification as soon as possible. It's expected that de-duplication and network response caching by the verification agent will make this double send low impact. Bug: 178864286 Test: manual boot device with no verified packages with a v1 verifier Change-Id: Id41306baeb3f94d4e709cf60dbfbc40e69cd1686 --- .../verify/domain/DomainVerificationService.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/services/core/java/com/android/server/pm/verify/domain/DomainVerificationService.java b/services/core/java/com/android/server/pm/verify/domain/DomainVerificationService.java index 4fd01d903261a..53540c8e0d4f0 100644 --- a/services/core/java/com/android/server/pm/verify/domain/DomainVerificationService.java +++ b/services/core/java/com/android/server/pm/verify/domain/DomainVerificationService.java @@ -177,6 +177,21 @@ public class DomainVerificationService extends SystemService verifyPackages(null, false); } + @Override + public void onUserUnlocked(@NonNull TargetUser user) { + super.onUserUnlocked(user); + + // Package verification is sent at both boot and user unlock. The latter will allow v1 + // verification agents to respond to the request, since they will not be directBootAware. + // However, ideally v2 implementations are boot aware and can handle the initial boot + // broadcast, to start verifying packages as soon as possible. It's possible this causes + // unnecessary duplication at device start up, but the implementation is responsible for + // de-duplicating. + // TODO: This can be improved by checking if the broadcast was received by the + // verification agent in the initial boot broadcast + verifyPackages(null, false); + } + @Override public void setProxy(@NonNull DomainVerificationProxy proxy) { mProxy = proxy;