diff options
| -rw-r--r-- | telephony/java/android/telephony/satellite/SatelliteManager.java | 113 |
1 files changed, 69 insertions, 44 deletions
diff --git a/telephony/java/android/telephony/satellite/SatelliteManager.java b/telephony/java/android/telephony/satellite/SatelliteManager.java index b97822a9d913..8bda5bf95e05 100644 --- a/telephony/java/android/telephony/satellite/SatelliteManager.java +++ b/telephony/java/android/telephony/satellite/SatelliteManager.java @@ -489,7 +489,6 @@ public final class SatelliteManager { * @param resultListener Listener for the {@link SatelliteResult} result of the operation. * * @throws SecurityException if the caller doesn't have required permission. - * @throws IllegalStateException if the Telephony process is not currently available. */ @RequiresPermission(Manifest.permission.SATELLITE_COMMUNICATION) @FlaggedApi(Flags.FLAG_OEM_ENABLED_SATELLITE_FLAG) @@ -512,11 +511,14 @@ public final class SatelliteManager { telephony.requestSatelliteEnabled(mSubId, enableSatellite, enableDemoMode, errorCallback); } else { - throw new IllegalStateException("telephony service is null."); + Rlog.e(TAG, "requestEnabled() invalid telephony"); + executor.execute(() -> Binder.withCleanCallingIdentity( + () -> resultListener.accept(SATELLITE_RESULT_ILLEGAL_STATE))); } } catch (RemoteException ex) { - Rlog.e(TAG, "requestSatelliteEnabled() RemoteException: ", ex); - ex.rethrowAsRuntimeException(); + Rlog.e(TAG, "requestEnabled() exception: ", ex); + executor.execute(() -> Binder.withCleanCallingIdentity( + () -> resultListener.accept(SATELLITE_RESULT_ILLEGAL_STATE))); } } @@ -566,12 +568,14 @@ public final class SatelliteManager { }; telephony.requestIsSatelliteEnabled(mSubId, receiver); } else { + loge("requestIsEnabled() invalid telephony"); executor.execute(() -> Binder.withCleanCallingIdentity(() -> callback.onError( new SatelliteException(SATELLITE_RESULT_ILLEGAL_STATE)))); } } catch (RemoteException ex) { - loge("requestIsSatelliteEnabled() RemoteException: " + ex); - ex.rethrowAsRuntimeException(); + loge("requestIsEnabled() RemoteException: " + ex); + executor.execute(() -> Binder.withCleanCallingIdentity(() -> callback.onError( + new SatelliteException(SATELLITE_RESULT_ILLEGAL_STATE)))); } } @@ -621,12 +625,14 @@ public final class SatelliteManager { }; telephony.requestIsDemoModeEnabled(mSubId, receiver); } else { + loge("requestIsDemoModeEnabled() invalid telephony"); executor.execute(() -> Binder.withCleanCallingIdentity(() -> callback.onError( new SatelliteException(SATELLITE_RESULT_ILLEGAL_STATE)))); } } catch (RemoteException ex) { loge("requestIsDemoModeEnabled() RemoteException: " + ex); - ex.rethrowAsRuntimeException(); + executor.execute(() -> Binder.withCleanCallingIdentity(() -> callback.onError( + new SatelliteException(SATELLITE_RESULT_ILLEGAL_STATE)))); } } @@ -678,12 +684,14 @@ public final class SatelliteManager { }; telephony.requestIsSatelliteSupported(mSubId, receiver); } else { + loge("requestIsSupported() invalid telephony"); executor.execute(() -> Binder.withCleanCallingIdentity(() -> callback.onError( new SatelliteException(SATELLITE_RESULT_ILLEGAL_STATE)))); } } catch (RemoteException ex) { - loge("requestIsSatelliteSupported() RemoteException: " + ex); - ex.rethrowAsRuntimeException(); + loge("requestIsSupported() RemoteException: " + ex); + executor.execute(() -> Binder.withCleanCallingIdentity(() -> callback.onError( + new SatelliteException(SATELLITE_RESULT_ILLEGAL_STATE)))); } } @@ -733,12 +741,14 @@ public final class SatelliteManager { }; telephony.requestSatelliteCapabilities(mSubId, receiver); } else { + loge("requestCapabilities() invalid telephony"); executor.execute(() -> Binder.withCleanCallingIdentity(() -> callback.onError( new SatelliteException(SATELLITE_RESULT_ILLEGAL_STATE)))); } } catch (RemoteException ex) { - loge("requestSatelliteCapabilities() RemoteException: " + ex); - ex.rethrowAsRuntimeException(); + loge("requestCapabilities() RemoteException: " + ex); + executor.execute(() -> Binder.withCleanCallingIdentity(() -> callback.onError( + new SatelliteException(SATELLITE_RESULT_ILLEGAL_STATE)))); } } @@ -1014,12 +1024,14 @@ public final class SatelliteManager { telephony.startSatelliteTransmissionUpdates(mSubId, errorCallback, internalCallback); } else { + loge("startTransmissionUpdates() invalid telephony"); executor.execute(() -> Binder.withCleanCallingIdentity( () -> resultListener.accept(SATELLITE_RESULT_ILLEGAL_STATE))); } } catch (RemoteException ex) { - loge("startSatelliteTransmissionUpdates() RemoteException: " + ex); - ex.rethrowAsRuntimeException(); + loge("startTransmissionUpdates() RemoteException: " + ex); + executor.execute(() -> Binder.withCleanCallingIdentity( + () -> resultListener.accept(SATELLITE_RESULT_ILLEGAL_STATE))); } } @@ -1069,12 +1081,14 @@ public final class SatelliteManager { () -> resultListener.accept(SATELLITE_RESULT_INVALID_ARGUMENTS))); } } else { + loge("stopTransmissionUpdates() invalid telephony"); executor.execute(() -> Binder.withCleanCallingIdentity( () -> resultListener.accept(SATELLITE_RESULT_ILLEGAL_STATE))); } } catch (RemoteException ex) { - loge("stopSatelliteTransmissionUpdates() RemoteException: " + ex); - ex.rethrowAsRuntimeException(); + loge("stopTransmissionUpdates() RemoteException: " + ex); + executor.execute(() -> Binder.withCleanCallingIdentity( + () -> resultListener.accept(SATELLITE_RESULT_ILLEGAL_STATE))); } } @@ -1092,7 +1106,6 @@ public final class SatelliteManager { * @param resultListener Listener for the {@link SatelliteResult} result of the operation. * * @throws SecurityException if the caller doesn't have required permission. - * @throws IllegalStateException if the Telephony process is not currently available. */ @RequiresPermission(Manifest.permission.SATELLITE_COMMUNICATION) @FlaggedApi(Flags.FLAG_OEM_ENABLED_SATELLITE_FLAG) @@ -1119,12 +1132,14 @@ public final class SatelliteManager { cancelRemote = telephony.provisionSatelliteService(mSubId, token, provisionData, errorCallback); } else { + loge("provisionService() invalid telephony"); executor.execute(() -> Binder.withCleanCallingIdentity( () -> resultListener.accept(SATELLITE_RESULT_ILLEGAL_STATE))); } } catch (RemoteException ex) { - loge("provisionSatelliteService() RemoteException=" + ex); - ex.rethrowAsRuntimeException(); + loge("provisionService() RemoteException=" + ex); + executor.execute(() -> Binder.withCleanCallingIdentity( + () -> resultListener.accept(SATELLITE_RESULT_ILLEGAL_STATE))); } if (cancellationSignal != null) { cancellationSignal.setRemote(cancelRemote); @@ -1168,12 +1183,14 @@ public final class SatelliteManager { }; telephony.deprovisionSatelliteService(mSubId, token, errorCallback); } else { + loge("deprovisionService() invalid telephony"); executor.execute(() -> Binder.withCleanCallingIdentity( () -> resultListener.accept(SATELLITE_RESULT_ILLEGAL_STATE))); } } catch (RemoteException ex) { - loge("deprovisionSatelliteService() RemoteException=" + ex); - ex.rethrowAsRuntimeException(); + loge("deprovisionService() RemoteException ex=" + ex); + executor.execute(() -> Binder.withCleanCallingIdentity( + () -> resultListener.accept(SATELLITE_RESULT_ILLEGAL_STATE))); } } @@ -1215,7 +1232,7 @@ public final class SatelliteManager { throw new IllegalStateException("telephony service is null."); } } catch (RemoteException ex) { - loge("registerForSatelliteProvisionStateChanged() RemoteException: " + ex); + loge("registerForProvisionStateChanged() RemoteException: " + ex); ex.rethrowAsRuntimeException(); } return SATELLITE_RESULT_REQUEST_FAILED; @@ -1302,12 +1319,14 @@ public final class SatelliteManager { }; telephony.requestIsSatelliteProvisioned(mSubId, receiver); } else { + loge("requestIsProvisioned() invalid telephony"); executor.execute(() -> Binder.withCleanCallingIdentity(() -> callback.onError( new SatelliteException(SATELLITE_RESULT_ILLEGAL_STATE)))); } } catch (RemoteException ex) { - loge("requestIsSatelliteProvisioned() RemoteException: " + ex); - ex.rethrowAsRuntimeException(); + loge("requestIsProvisioned() RemoteException: " + ex); + executor.execute(() -> Binder.withCleanCallingIdentity(() -> callback.onError( + new SatelliteException(SATELLITE_RESULT_ILLEGAL_STATE)))); } } @@ -1347,7 +1366,7 @@ public final class SatelliteManager { throw new IllegalStateException("telephony service is null."); } } catch (RemoteException ex) { - loge("registerForSatelliteModemStateChanged() RemoteException:" + ex); + loge("registerForModemStateChanged() RemoteException:" + ex); ex.rethrowAsRuntimeException(); } return SATELLITE_RESULT_REQUEST_FAILED; @@ -1516,12 +1535,14 @@ public final class SatelliteManager { }; telephony.pollPendingDatagrams(mSubId, internalCallback); } else { + loge("pollPendingDatagrams() invalid telephony"); executor.execute(() -> Binder.withCleanCallingIdentity( () -> resultListener.accept(SATELLITE_RESULT_ILLEGAL_STATE))); } } catch (RemoteException ex) { loge("pollPendingDatagrams() RemoteException:" + ex); - ex.rethrowAsRuntimeException(); + executor.execute(() -> Binder.withCleanCallingIdentity( + () -> resultListener.accept(SATELLITE_RESULT_ILLEGAL_STATE))); } } @@ -1573,12 +1594,14 @@ public final class SatelliteManager { telephony.sendDatagram(mSubId, datagramType, datagram, needFullScreenPointingUI, internalCallback); } else { + loge("sendDatagram() invalid telephony"); executor.execute(() -> Binder.withCleanCallingIdentity( () -> resultListener.accept(SATELLITE_RESULT_ILLEGAL_STATE))); } } catch (RemoteException ex) { loge("sendDatagram() RemoteException:" + ex); - ex.rethrowAsRuntimeException(); + executor.execute(() -> Binder.withCleanCallingIdentity( + () -> resultListener.accept(SATELLITE_RESULT_ILLEGAL_STATE))); } } @@ -1628,16 +1651,16 @@ public final class SatelliteManager { } } }; - telephony.requestIsCommunicationAllowedForCurrentLocation(mSubId, - receiver); + telephony.requestIsCommunicationAllowedForCurrentLocation(mSubId, receiver); } else { + loge("requestIsCommunicationAllowedForCurrentLocation() invalid telephony"); executor.execute(() -> Binder.withCleanCallingIdentity(() -> callback.onError( new SatelliteException(SATELLITE_RESULT_ILLEGAL_STATE)))); } } catch (RemoteException ex) { - loge("requestIsCommunicationAllowedForCurrentLocation() RemoteException: " - + ex); - ex.rethrowAsRuntimeException(); + loge("requestIsCommunicationAllowedForCurrentLocation() RemoteException: " + ex); + executor.execute(() -> Binder.withCleanCallingIdentity(() -> callback.onError( + new SatelliteException(SATELLITE_RESULT_ILLEGAL_STATE)))); } } @@ -1688,12 +1711,14 @@ public final class SatelliteManager { }; telephony.requestTimeForNextSatelliteVisibility(mSubId, receiver); } else { + loge("requestTimeForNextSatelliteVisibility() invalid telephony"); executor.execute(() -> Binder.withCleanCallingIdentity(() -> callback.onError( new SatelliteException(SATELLITE_RESULT_ILLEGAL_STATE)))); } } catch (RemoteException ex) { loge("requestTimeForNextSatelliteVisibility() RemoteException: " + ex); - ex.rethrowAsRuntimeException(); + executor.execute(() -> Binder.withCleanCallingIdentity(() -> callback.onError( + new SatelliteException(SATELLITE_RESULT_ILLEGAL_STATE)))); } } @@ -1720,7 +1745,7 @@ public final class SatelliteManager { throw new IllegalStateException("telephony service is null."); } } catch (RemoteException ex) { - loge("informDeviceAlignedToSatellite() RemoteException:" + ex); + loge("setDeviceAlignedWithSatellite() RemoteException:" + ex); ex.rethrowAsRuntimeException(); } } @@ -1830,12 +1855,14 @@ public final class SatelliteManager { }; telephony.addAttachRestrictionForCarrier(subId, reason, errorCallback); } else { + loge("addAttachRestrictionForCarrier() invalid telephony"); executor.execute(() -> Binder.withCleanCallingIdentity( () -> resultListener.accept(SATELLITE_RESULT_ILLEGAL_STATE))); } } catch (RemoteException ex) { loge("addAttachRestrictionForCarrier() RemoteException:" + ex); - ex.rethrowAsRuntimeException(); + executor.execute(() -> Binder.withCleanCallingIdentity( + () -> resultListener.accept(SATELLITE_RESULT_ILLEGAL_STATE))); } } @@ -1873,12 +1900,14 @@ public final class SatelliteManager { }; telephony.removeAttachRestrictionForCarrier(subId, reason, errorCallback); } else { + loge("removeAttachRestrictionForCarrier() invalid telephony"); executor.execute(() -> Binder.withCleanCallingIdentity( () -> resultListener.accept(SATELLITE_RESULT_ILLEGAL_STATE))); } } catch (RemoteException ex) { loge("removeAttachRestrictionForCarrier() RemoteException:" + ex); - ex.rethrowAsRuntimeException(); + executor.execute(() -> Binder.withCleanCallingIdentity( + () -> resultListener.accept(SATELLITE_RESULT_ILLEGAL_STATE))); } } @@ -1939,10 +1968,7 @@ public final class SatelliteManager { * The {@link NtnSignalStrength#NTN_SIGNAL_STRENGTH_NONE} will be returned if there is no * signal strength data available. * If the request is not successful, {@link OutcomeReceiver#onError(Throwable)} will return a - * {@link SatelliteException} with the {@link SatelliteResult}, or return a - * {@link IllegalStateException} if the Telephony process is not currently available or - * satellite is not supported, or return a {@link RuntimeException} when remote procedure call - * has failed. + * {@link SatelliteException} with the {@link SatelliteResult}. * * @throws SecurityException if the caller doesn't have required permission. */ @@ -1980,12 +2006,14 @@ public final class SatelliteManager { }; telephony.requestNtnSignalStrength(mSubId, receiver); } else { + loge("requestNtnSignalStrength() invalid telephony"); executor.execute(() -> Binder.withCleanCallingIdentity(() -> callback.onError( new SatelliteException(SATELLITE_RESULT_ILLEGAL_STATE)))); } } catch (RemoteException ex) { loge("requestNtnSignalStrength() RemoteException: " + ex); - ex.rethrowAsRuntimeException(); + executor.execute(() -> Binder.withCleanCallingIdentity(() -> callback.onError( + new SatelliteException(SATELLITE_RESULT_ILLEGAL_STATE)))); } } @@ -2187,14 +2215,11 @@ public final class SatelliteManager { return new ArrayList<>(); } - private static ITelephony getITelephony() { + @Nullable private static ITelephony getITelephony() { ITelephony binder = ITelephony.Stub.asInterface(TelephonyFrameworkInitializer .getTelephonyServiceManager() .getTelephonyServiceRegisterer() .get()); - if (binder == null) { - throw new RuntimeException("Could not find Telephony Service."); - } return binder; } |