diff options
| author | 2024-11-25 17:28:02 +0000 | |
|---|---|---|
| committer | 2024-11-25 17:39:26 +0000 | |
| commit | bf6c7fd5e946e4d93477608f257c90705335c6a0 (patch) | |
| tree | e5dc68a3b092635c9eae35b73aebc1a318e24215 | |
| parent | fc83498dd4f5bcd219a413898f34d99fb3897201 (diff) | |
Fix NPE in onTransactionResponse callback
Bug: 380872826
Test: CHQTS pass, inject manual failure case and confirm no crash
Flag: EXEMPT bug fix
Change-Id: I7bd410666049f5d09bc18e966111e665aea90717
| -rw-r--r-- | services/core/java/com/android/server/location/contexthub/ContextHubTransactionManager.java | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/services/core/java/com/android/server/location/contexthub/ContextHubTransactionManager.java b/services/core/java/com/android/server/location/contexthub/ContextHubTransactionManager.java index da31bf29a8e8..ccfa61b400b6 100644 --- a/services/core/java/com/android/server/location/contexthub/ContextHubTransactionManager.java +++ b/services/core/java/com/android/server/location/contexthub/ContextHubTransactionManager.java @@ -492,14 +492,21 @@ import java.util.concurrent.atomic.AtomicInteger; /* package */ void onTransactionResponse(int transactionId, boolean success) { TransactionAcceptConditions conditions = - transaction -> transaction.getTransactionId() == transactionId; + transaction -> { + if (transaction.getTransactionId() != transactionId) { + Log.w( + TAG, + "Unexpected transaction: expected " + + transactionId + + ", received " + + transaction.getTransactionId()); + return false; + } + return true; + }; ContextHubServiceTransaction transaction = getTransactionAndHandleNext(conditions); if (transaction == null) { - Log.w(TAG, "Received unexpected transaction response (expected ID = " - + transactionId - + ", received ID = " - + transaction.getTransactionId() - + ")"); + Log.w(TAG, "Received unexpected transaction response"); return; } @@ -581,7 +588,7 @@ import java.util.concurrent.atomic.AtomicInteger; transaction.getTransactionType() == ContextHubTransaction.TYPE_QUERY_NANOAPPS; ContextHubServiceTransaction transaction = getTransactionAndHandleNext(conditions); if (transaction == null) { - Log.w(TAG, "Received unexpected query response (expected " + transaction + ")"); + Log.w(TAG, "Received unexpected query response"); return; } |