Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit e579033d authored by Ben Lin's avatar Ben Lin
Browse files

Notify AutofillManager in onResume() IFF activity was not recreated.

In Activity#onResume(), AutofillManager is notified when there is a
current focus, in cases where user backgrounds and then foregrounds the
app, etc. However, onResume() is also called when screen rotation
occurs, but because both the window and the layout is torn down,
Activity#getCurrentFocus() returns null, thus AutofillManager is not
notified because there is no current focus. This is true on phones.

However, in some devices, such as Chromebooks, window is preserved on
rotation. The API is supported in Window Management's task resize
capabilities. Because the window is not torn down,
Activity#getCurrentFocus() now returns true, even if an upcoming layout
pass is bound to happen. Thus, AutofillManager gets notified twice: once
on screen rotation (onResume()), and another during the subsequent
layout pass.

This changes the logic to explicitly check for the case where activity
is recreated from a previous saved instance. If it is, then skip
notifying AutofillManager, as the subsequent layout pass will do the
job.

Bug: 111619119
Test: atest android.autofillservice.cts.SessionLifecycleTest#testDatasetVisibleWhileAutofilledAppIsLifecycled
atest android.autofillservice.cts.DuplicateIdActivityTest#testDoNotRestoreDuplicateAutofillIds

Change-Id: I1816abfa23d39d6f3370c9f32c6de7fc5ae0398e
(cherry picked from commit af5a24eea08975990c7487be8b64657bf61641b7)
parent 2f91645c
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment