Keystore StrongBox-unavailable fault¶
The debug SDK’s Keystore fault plan wraps the SDK’s own Keystore backend, which
covers metadata lookups and deletion. Key generation happens in app code, through
KeyGenerator or KeyPairGenerator, so the SDK cannot intercept it.
STRONGBOX_UNAVAILABLE therefore needs the app to make one call before it
generates a key.
Contract¶
- The app calls
KeystoreTestState.checkKeyGeneration(spec)with itsKeyGenParameterSpecimmediately beforegenerateKey()/generateKeyPair(). - The method reads
spec.keystoreAliasandspec.isStrongBoxBackedand passes them to an internalKeyGenerationGate. Main source holds only that nullable gate.KeystoreFaultPlan(debug source) installs the gate when a fault is injected. - The gate throws
StrongBoxUnavailableExceptionwith no message when StrongBox is requested and the alias is declared, enabled, and armed withSTRONGBOX_UNAVAILABLE. That is the type the platform throws from key generation on a device without StrongBox, and it is aProviderException, so the app’s existing fallback handles it. - Release builds never install the gate, so the call is a no-op there. It is also
a no-op below API 28, where StrongBox cannot be requested. The published-AAR
check (
scripts/android/validate-sdk-debug-inspector-consumer.sh) requiresKeystoreFaultPlanin the debug AAR and its absence from the release AAR. - The fault plan’s backend decorator treats this kind as a no-op, so metadata and deletion report the real Keystore state.