summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Derek Jedral <derekjedral@google.com> 2023-05-01 11:46:20 -0700
committer Derek Jedral <derekjedral@google.com> 2023-05-04 15:53:27 -0700
commit6241b77464a11856a7107419d37484b242a1b07c (patch)
treec8ac10c88731596bfa5a947e5acfe73a182e3f19
parentcfbdee11598bf87bcdec8d122002715ea3c2c4b3 (diff)
Report correct userId in onUserMayRequestUnlock.
obtainMessage with two arguments will set the user id as the object, but this value is retrieved as msg.arg1. We need to call obtainMessage with three arguments instead to make the second argument the userId. Thir third argument will be ignored by the receiver. Test: atest TrustTests:UserUnlockRequestTest Bug: b/278323473 Change-Id: Ie08c643f9fb5fbbe7f107a1f267074805ddc500b
-rw-r--r--services/core/java/com/android/server/trust/TrustManagerService.java2
-rw-r--r--tests/TrustTests/src/android/trust/test/UserUnlockRequestTest.kt10
2 files changed, 11 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/trust/TrustManagerService.java b/services/core/java/com/android/server/trust/TrustManagerService.java
index 8786005d519f..87b42014d5b4 100644
--- a/services/core/java/com/android/server/trust/TrustManagerService.java
+++ b/services/core/java/com/android/server/trust/TrustManagerService.java
@@ -1504,7 +1504,7 @@ public class TrustManagerService extends SystemService {
@Override
public void reportUserMayRequestUnlock(int userId) throws RemoteException {
enforceReportPermission();
- mHandler.obtainMessage(MSG_USER_MAY_REQUEST_UNLOCK, userId).sendToTarget();
+ mHandler.obtainMessage(MSG_USER_MAY_REQUEST_UNLOCK, userId, /*arg2=*/ 0).sendToTarget();
}
@Override
diff --git a/tests/TrustTests/src/android/trust/test/UserUnlockRequestTest.kt b/tests/TrustTests/src/android/trust/test/UserUnlockRequestTest.kt
index 6a8752abfde7..501b9d33871a 100644
--- a/tests/TrustTests/src/android/trust/test/UserUnlockRequestTest.kt
+++ b/tests/TrustTests/src/android/trust/test/UserUnlockRequestTest.kt
@@ -79,6 +79,16 @@ class UserUnlockRequestTest {
.isEqualTo(oldCount + 1)
}
+ @Test
+ fun reportUserMayRequestUnlock_differentUserId_doesNotPropagateToAgent() {
+ val oldCount = trustAgentRule.agent.onUserMayRequestUnlockCallCount
+ trustManager.reportUserMayRequestUnlock(userId + 1)
+ await()
+
+ assertThat(trustAgentRule.agent.onUserMayRequestUnlockCallCount)
+ .isEqualTo(oldCount)
+ }
+
companion object {
private const val TAG = "UserUnlockRequestTest"
private fun await() = Thread.sleep(250)