diff options
| author | 2022-01-11 19:33:14 +0000 | |
|---|---|---|
| committer | 2022-01-11 19:33:14 +0000 | |
| commit | 306e4e79a357dbde74944b24928d44b8208a740e (patch) | |
| tree | 60661196c2c49daeb449b4b96c954b4948f89ccb | |
| parent | c6ebb14b7df21b1b6dcdea90d496582c57b6b46c (diff) | |
| parent | 7cd4e1cb0fd1d75b6bb2f2c82b8681a51e3e72cd (diff) | |
Merge "Catch service exceptions in AidlContextHubWrapper"
| -rw-r--r-- | services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java b/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java index f84b68e7c556..9b0b7829005d 100644 --- a/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java +++ b/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java @@ -35,6 +35,7 @@ import android.os.HandlerThread; import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; +import android.os.ServiceSpecificException; import android.util.Log; import android.util.Pair; @@ -435,7 +436,7 @@ public abstract class IContextHubWrapper { public void onHostEndpointConnected(HostEndpointInfo info) { try { mHub.onHostEndpointConnected(info); - } catch (RemoteException e) { + } catch (RemoteException | ServiceSpecificException e) { Log.e(TAG, "RemoteException in onHostEndpointConnected"); } } @@ -444,7 +445,7 @@ public abstract class IContextHubWrapper { public void onHostEndpointDisconnected(short hostEndpointId) { try { mHub.onHostEndpointDisconnected((char) hostEndpointId); - } catch (RemoteException e) { + } catch (RemoteException | ServiceSpecificException e) { Log.e(TAG, "RemoteException in onHostEndpointDisconnected"); } } @@ -457,7 +458,7 @@ public abstract class IContextHubWrapper { mHub.sendMessageToHub(contextHubId, ContextHubServiceUtil.createAidlContextHubMessage(hostEndpointId, message)); return ContextHubTransaction.RESULT_SUCCESS; - } catch (RemoteException e) { + } catch (RemoteException | ServiceSpecificException e) { return ContextHubTransaction.RESULT_FAILED_UNKNOWN; } } @@ -470,7 +471,7 @@ public abstract class IContextHubWrapper { try { mHub.loadNanoapp(contextHubId, aidlNanoAppBinary, transactionId); return ContextHubTransaction.RESULT_SUCCESS; - } catch (RemoteException e) { + } catch (RemoteException | ServiceSpecificException e) { return ContextHubTransaction.RESULT_FAILED_UNKNOWN; } } @@ -481,7 +482,7 @@ public abstract class IContextHubWrapper { try { mHub.unloadNanoapp(contextHubId, nanoappId, transactionId); return ContextHubTransaction.RESULT_SUCCESS; - } catch (RemoteException e) { + } catch (RemoteException | ServiceSpecificException e) { return ContextHubTransaction.RESULT_FAILED_UNKNOWN; } } @@ -492,7 +493,7 @@ public abstract class IContextHubWrapper { try { mHub.enableNanoapp(contextHubId, nanoappId, transactionId); return ContextHubTransaction.RESULT_SUCCESS; - } catch (RemoteException e) { + } catch (RemoteException | ServiceSpecificException e) { return ContextHubTransaction.RESULT_FAILED_UNKNOWN; } } @@ -503,7 +504,7 @@ public abstract class IContextHubWrapper { try { mHub.disableNanoapp(contextHubId, nanoappId, transactionId); return ContextHubTransaction.RESULT_SUCCESS; - } catch (RemoteException e) { + } catch (RemoteException | ServiceSpecificException e) { return ContextHubTransaction.RESULT_FAILED_UNKNOWN; } } @@ -513,21 +514,25 @@ public abstract class IContextHubWrapper { try { mHub.queryNanoapps(contextHubId); return ContextHubTransaction.RESULT_SUCCESS; - } catch (RemoteException e) { + } catch (RemoteException | ServiceSpecificException e) { return ContextHubTransaction.RESULT_FAILED_UNKNOWN; } } public void registerCallback(int contextHubId, ICallback callback) throws RemoteException { mAidlCallbackMap.put(contextHubId, new ContextHubAidlCallback(contextHubId, callback)); - mHub.registerCallback(contextHubId, mAidlCallbackMap.get(contextHubId)); + try { + mHub.registerCallback(contextHubId, mAidlCallbackMap.get(contextHubId)); + } catch (RemoteException | ServiceSpecificException e) { + Log.e(TAG, "Exception while registering callback: " + e.getMessage()); + } } private void onSettingChanged(byte setting, boolean enabled) { try { mHub.onSettingChanged(setting, enabled); - } catch (RemoteException e) { - Log.e(TAG, "RemoteException while sending setting update"); + } catch (RemoteException | ServiceSpecificException e) { + Log.e(TAG, "Exception while sending setting update: " + e.getMessage()); } } } |