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
This commit is contained in:
TYM Tsai
2019-12-17 14:37:47 +08:00
parent 247901bb4f
commit 9d3ba8257e

View File

@@ -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.");