Your Name ac8c52db31 Updating TrustManagerService to react to keyguard visible changes.
Trustagents should know to downgrade to trustable when the keyguard
visiblity changes. This will fix a bug on tablet where hitting the power
button doesn't sleep the device, and consequently doesn't broadcast the
SCREEN_OFF broadcast which causes the unit tests to fail. This also
fixes a larger issue where if the phone gets unlatched, or if a
trustagent is set up while the phone is unlocked, the phone will be able
to downgrade the trustagent to trustable at the correct time.

As part of this chance, we can remove the USER_PRESENT broadcast which
ends up duplicating the reportKeyguardShowingChanged. Also, in
TemporaryAndRenewableTrustTest.kt, we now grantTrust after waking the
phone which is more realistic and was causing the tests to fail before.

Test: atest TrustTests:TemporaryAndRenewableTrustTests --iterations
Bug: 213631682
Fixes: 231326751
Change-Id: I10a3270ff0b9f12d62acd448ad754f829d843b0e
2022-05-04 23:05:39 +00:00
..

TrustTests framework tests

These tests test the "trust" part of the platform primarily implemented via TrustManagerService in the system server and TrustAgentService in system apps.

Tests are separated into separate files based on major groupings. When creating new tests, find a closely matching existing test file or create a new test file. Prefer many test files over large test files.

Each test file has its own trust agent. To create a new trust agent:

  1. Create a new class extending from BaseTrustAgentService class in your test file
  2. Add a new <service> stanza to AndroidManifest.xml in this directory for the new agent following the pattern fo the existing agents.

To run:

atest TrustTests

Testing approach:

  1. Test the agent service as a black box; avoid inspecting internal state of the service or modifying the system code outside of this directory.
  2. The primary interface to the system is through these three points:
    1. TrustAgentService, your agent created by the TrustAgentRule and accessible via the agent property of the rule.
      1. Call command methods (e.g. grantTrust) directly on the agent
      2. Listen to events (e.g. onUserRequestedUnlock) by implementing the method in your test's agent class and tracking invocations. See UserUnlockRequestTest for an example.
    2. TrustManager which is the interface the rest of the system (e.g. SystemUI) has to the service.
      1. Through this API, simulate system events that the service cares about (e.g. reportUnlockAttempt).
    3. TrustListener which is the interface the rest of the system (e.g. SystemUI) uses to receive events from the service.
      1. Through this, verify behavior that affects the rest of the system. For example, see LockStateTrackingRule.
  3. To re-use code between tests, prefer creating new rules alongside the existing rules or adding functionality to a closely matching existing rule.