Handle failure to connect to KeyChainService.

KeyChain.bind() throws AssertionError when it fails to connect to the
service. If a requesting activity is destroyed, its context will be
invalid and connection attempt will fail. When this happens in an
AsyncTask from KeyChainActivity, it crashes the process because the
current catch-all case doesn't handle AssertionError which isn't derived
from Exception.

Note: Normally it is ill-advised to catch Errors, but in this case it
shouldn't have been an AssertionError in the first place and currently
the app crashes anyway.

Bug: 178967747
Test: atest CtsDevicePolicyTestCases:android.devicepolicy.cts.KeyManagementTest
Change-Id: I917acb5d1594a8bb867744f56688407b0cda95ee
1 file changed