summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tim Yu <yunicorn@google.com> 2025-03-20 12:09:26 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2025-03-20 12:09:26 -0700
commit0da9bb05ab19e7cd2af686f7afce42671e1e2fec (patch)
tree3715963c9a6ca3b347fda423ddccb79581d71047
parent1d698831e183f0a6c453b9e02513d8014d308f41 (diff)
parent9c26fbf0d9dba6a179140ba19dff209fcb161c7d (diff)
Merge "Autofill Fix race condition with onSessionDestroyed" into main
-rw-r--r--services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java27
1 files changed, 17 insertions, 10 deletions
diff --git a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
index b39b5b1a7660..9b735d70abb5 100644
--- a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
+++ b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
@@ -26,6 +26,7 @@ import static android.view.autofill.AutofillManager.FLAG_ADD_CLIENT_ENABLED_FOR_
import static android.view.autofill.AutofillManager.NO_SESSION;
import static android.view.autofill.AutofillManager.RECEIVER_FLAG_SESSION_FOR_AUGMENTED_AUTOFILL_ONLY;
+import static com.android.internal.util.function.pooled.PooledLambda.obtainMessage;
import static com.android.server.autofill.Helper.sDebug;
import static com.android.server.autofill.Helper.sVerbose;
@@ -761,20 +762,16 @@ final class AutofillManagerServiceImpl
return false;
}
- @GuardedBy("mLock")
- void removeSessionLocked(int sessionId) {
- mSessions.remove(sessionId);
- if (Flags.autofillSessionDestroyed()) {
- if (sVerbose) {
- Slog.v(
- TAG,
- "removeSessionLocked(): removed " + sessionId);
- }
+ void callOnSessionDestroyed(int sessionId) {
+ if (sVerbose) {
+ Slog.v(TAG, "removeSessionLocked(): removed " + sessionId);
+ }
+ synchronized (mLock) {
FillEventHistory history = null;
if (AutofillFeatureFlags.isMultipleFillEventHistoryEnabled()
- && mFillHistories != null) {
+ && mFillHistories != null) {
history = mFillHistories.get(sessionId);
mFillHistories.delete(sessionId);
}
@@ -806,6 +803,16 @@ final class AutofillManagerServiceImpl
}
}
+ @GuardedBy("mLock")
+ void removeSessionLocked(int sessionId) {
+ mSessions.remove(sessionId);
+ if (Flags.autofillSessionDestroyed()) {
+ mHandler.sendMessage(
+ obtainMessage(
+ AutofillManagerServiceImpl::callOnSessionDestroyed, this, sessionId));
+ }
+ }
+
/**
* Ges the previous sessions asked to be kept alive in a given activity task.
*