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)
1 file changed