Fix handwriting trigger fail even isAutoHandwritingEnabled is true
Currently, our focusedView only records the View for which the
isAutoHandwritingEnabled method returns true. If
isAutoHandwritingEnabled returns false when the View gains focus, we
will not record it as focusedView. Unfortunately, if the View then
calls setAutoHandwritingEnabled with true, the focus will not change.
If we attempt to execute Handwriting at this point, it will not
succeed because the View already has focus and the focus request will
not change, thus preventing the initiation of Handwriting. Ideally, we
should notify the HandwritingInitiator of the focus information again
when setAutoHandwritingEnabled is called. However, we currently allow
developers to override the isAutoHandwritingEnabled method, which
makes it difficult to monitor changes to this value.
Here, we attempt to modify focusedView to record the view that actually
has the current focus, even if isAutoHandwritingEnabled still returns
false. When searching for the best candidate View, we will then check
the value of isAutoHandwritingEnabled and make corresponding decisions
to fix this issue.
Bug: 361256391
Test: atest StylusHandwritingTest
Flag: com.android.text.flags.handwriting_track_disabled
Signed-off-by: Linnan Li <lilinnan@xiaomi.corp-partner.google.com>
(cherry picked from https://partner-android-review.googlesource.com/q/commit:417d6317b06c3fbe9959f05984318b1ad01c117a)
Merged-In: I82ff9936ce8dc51a997d4e73e772e3eced300475
Change-Id: I82ff9936ce8dc51a997d4e73e772e3eced300475
2 files changed