diff options
author | Joanne Chung <joannechung@google.com> | 2020-07-29 17:36:10 +0800 |
---|---|---|
committer | Joanne Chung <joannechung@google.com> | 2020-07-31 08:23:08 +0000 |
commit | fe89715c86a7c503284d68e3be10dc8bafa446aa (patch) | |
tree | d200f11fe2864b98f20ebc2e9d8f570ca102b442 /services/autofill | |
parent | b8c40cdebefed3e8f5d2b578d4e2d0595b47bb4e (diff) |
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 a081250
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
Change-Id: Id7ff581b3a7f35cf97b4f3405a40bfa1a420823e
(cherry picked from commit 3c7ac7de467fbeb905ed4969a2f2fa59f06f11d1)
Diffstat (limited to 'services/autofill')
-rw-r--r-- | services/autofill/java/com/android/server/autofill/RemoteFillService.java | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/services/autofill/java/com/android/server/autofill/RemoteFillService.java b/services/autofill/java/com/android/server/autofill/RemoteFillService.java index 5a9320f61b38..b0755ac836e0 100644 --- a/services/autofill/java/com/android/server/autofill/RemoteFillService.java +++ b/services/autofill/java/com/android/server/autofill/RemoteFillService.java @@ -161,8 +161,9 @@ final class RemoteFillService extends ServiceConnector.Impl<IAutoFillService> { @Override public void onFailure(int requestId, CharSequence message) { + String errorMessage = message == null ? "" : String.valueOf(message); fillRequest.completeExceptionally( - new RuntimeException(String.valueOf(message))); + new RuntimeException(errorMessage)); } }); return fillRequest; |