From 9d3ba8257ef4f8cdbe2e8177140a5e91fa115f52 Mon Sep 17 00:00:00 2001 From: TYM Tsai Date: Tue, 17 Dec 2019 14:37:47 +0800 Subject: [PATCH] The reset() should not throw exceptions The reset() should catch the IllegalArgumentException even if the service was not registered. Fixes: 141739693 Test: atest -it CtsAutoFillServiceTestCases Change-Id: I58f68d502f5e5d1675525f8ad5bc0442f787c8b3 --- .../server/autofill/FieldClassificationStrategy.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/autofill/java/com/android/server/autofill/FieldClassificationStrategy.java b/services/autofill/java/com/android/server/autofill/FieldClassificationStrategy.java index 9db6254a8baab..36a4509203739 100644 --- a/services/autofill/java/com/android/server/autofill/FieldClassificationStrategy.java +++ b/services/autofill/java/com/android/server/autofill/FieldClassificationStrategy.java @@ -121,7 +121,12 @@ final class FieldClassificationStrategy { synchronized (mLock) { if (mServiceConnection != null) { if (sDebug) Slog.d(TAG, "reset(): unbinding service."); - mContext.unbindService(mServiceConnection); + try { + mContext.unbindService(mServiceConnection); + } catch (IllegalArgumentException e) { + // no-op, just log the error message. + Slog.w(TAG, "reset(): " + e.getMessage()); + } mServiceConnection = null; } else { if (sDebug) Slog.d(TAG, "reset(): service is not bound. Do nothing.");