Skip to content
Commit 3c7ac7de authored by Joanne Chung's avatar Joanne Chung
Browse files

Fix "null" toast when FillCallback.onFailure(null) called.

Root cause
The error message is set by AutofillService, AutofillService calls
FillCallback.onFailure(null) back to the platform. Because a081250c
uses String.valueOf(message), this method will make a null object
become to a "null" string. This may cause the Autofill session to
think we should show message because of a non-null message. And if
the AutofillService target SDK is lower than 29, we don't ignore show
message, then users will see a "null" toast.

Solution
Instead of passing the message parameter to String.valueOf() directly
, we check the message first, only passing to String.valueOf() if the
message is not null. And we pass an empty string if the message
parameter is null.

Bug: 159888723
Test: Use a test AutofillService which target SDK is lower than 29,
make sure no null toast is shown
Test: atest CtsAutoFillServiceTestCases:LoginActivityTest#\
testAutofillAgainAfterOnFailure

Change-Id: Id7ff581b3a7f35cf97b4f3405a40bfa1a420823e
parent 6f7648c9
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