Implement rate limiting on a per app basis for confirmationui
Implements the following strategy per app:
* Every attempted prompt increments a try counter.
* A prompt that was confirmed by the user resets the try counter.
* No penalty is applied after the first two cancelled attempts.
* A penalty of 30s is applied after attempt 3, 4, and 5 when
cancelled by the user
* A penalty of 60s * 2**(N - 6) after the Nth cancelled attempt
for attempts 6...
* A try counter that was not updated in 24h gets garbage collected.
Test: /data/nativetest64/keystore_unit_tests/keystore_unit_tests
Bug: 73892492
Change-Id: I0b50869259bfe920338c0c049cb9a715143ab103
diff --git a/keystore/tests/Android.bp b/keystore/tests/Android.bp
index 227f88f..c3f5177 100644
--- a/keystore/tests/Android.bp
+++ b/keystore/tests/Android.bp
@@ -10,11 +10,13 @@
srcs: [
"auth_token_table_test.cpp",
"auth_token_formatting_test.cpp",
+ "confirmationui_rate_limiting_test.cpp",
"gtest_main.cpp",
],
name: "keystore_unit_tests",
tags: ["test"],
static_libs: [
+ "android.hardware.confirmationui@1.0",
"libbase",
"libgtest_main",
"libhidlbase",