diff options
| -rw-r--r-- | telephony/java/android/telephony/satellite/SatelliteManager.java | 79 | ||||
| -rw-r--r-- | telephony/java/com/android/internal/telephony/ITelephony.aidl | 11 |
2 files changed, 89 insertions, 1 deletions
diff --git a/telephony/java/android/telephony/satellite/SatelliteManager.java b/telephony/java/android/telephony/satellite/SatelliteManager.java index 887b79883710..23203ed65e9a 100644 --- a/telephony/java/android/telephony/satellite/SatelliteManager.java +++ b/telephony/java/android/telephony/satellite/SatelliteManager.java @@ -281,6 +281,14 @@ public final class SatelliteManager { "satellite_access_configuration"; /** + * Bundle key to get the response from + * {@link #requestSelectedNbIotSatelliteSubscriptionId(Executor, OutcomeReceiver)}. + * @hide + */ + public static final String KEY_SELECTED_NB_IOT_SATELLITE_SUBSCRIPTION_ID = + "selected_nb_iot_satellite_subscription_id"; + + /** * The request was successfully processed. * @hide */ @@ -531,6 +539,12 @@ public final class SatelliteManager { @FlaggedApi(Flags.FLAG_SATELLITE_SYSTEM_APIS) public static final int SATELLITE_RESULT_ENABLE_IN_PROGRESS = 29; + /** + * There is no valid satellite subscription selected. + * @hide + */ + public static final int SATELLITE_RESULT_NO_VALID_SATELLITE_SUBSCRIPTION = 30; + /** @hide */ @IntDef(prefix = {"SATELLITE_RESULT_"}, value = { SATELLITE_RESULT_SUCCESS, @@ -562,7 +576,8 @@ public final class SatelliteManager { SATELLITE_RESULT_LOCATION_NOT_AVAILABLE, SATELLITE_RESULT_EMERGENCY_CALL_IN_PROGRESS, SATELLITE_RESULT_DISABLE_IN_PROGRESS, - SATELLITE_RESULT_ENABLE_IN_PROGRESS + SATELLITE_RESULT_ENABLE_IN_PROGRESS, + SATELLITE_RESULT_NO_VALID_SATELLITE_SUBSCRIPTION }) @Retention(RetentionPolicy.SOURCE) public @interface SatelliteResult {} @@ -2464,6 +2479,68 @@ public final class SatelliteManager { } /** + * Request to get the currently selected satellite subscription id as an {@link Integer}. + * + * @param executor The executor on which the callback will be called. + * @param callback The callback object to which the result will be delivered. + * If the request is successful, {@link OutcomeReceiver#onResult(Object)} + * will return the time after which the satellite will be visible. + * If the request is not successful, {@link OutcomeReceiver#onError(Throwable)} + * will return a {@link SatelliteException} with the {@link SatelliteResult}. + * + * @throws SecurityException if the caller doesn't have required permission. + * + * @hide + */ + @RequiresPermission(Manifest.permission.SATELLITE_COMMUNICATION) + public void requestSelectedNbIotSatelliteSubscriptionId( + @NonNull @CallbackExecutor Executor executor, + @NonNull OutcomeReceiver<Integer, SatelliteException> callback) { + Objects.requireNonNull(executor); + Objects.requireNonNull(callback); + + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + ResultReceiver receiver = new ResultReceiver(null) { + @Override + protected void onReceiveResult(int resultCode, Bundle resultData) { + if (resultCode == SATELLITE_RESULT_SUCCESS) { + if (resultData + .containsKey(KEY_SELECTED_NB_IOT_SATELLITE_SUBSCRIPTION_ID)) { + int selectedSatelliteSubscriptionId = + resultData + .getInt(KEY_SELECTED_NB_IOT_SATELLITE_SUBSCRIPTION_ID); + executor.execute(() -> Binder.withCleanCallingIdentity(() -> + callback.onResult(selectedSatelliteSubscriptionId))); + } else { + loge( + "KEY_SELECTED_NB_IOT_SATELLITE_SUBSCRIPTION_ID does not exist." + ); + executor.execute(() -> Binder.withCleanCallingIdentity(() -> + callback.onError(new SatelliteException( + SATELLITE_RESULT_REQUEST_FAILED)))); + } + } else { + executor.execute(() -> Binder.withCleanCallingIdentity(() -> + callback.onError(new SatelliteException(resultCode)))); + } + } + }; + telephony.requestSelectedNbIotSatelliteSubscriptionId(receiver); + } else { + loge("requestSelectedNbIotSatelliteSubscriptionId() invalid telephony"); + executor.execute(() -> Binder.withCleanCallingIdentity(() -> callback.onError( + new SatelliteException(SATELLITE_RESULT_ILLEGAL_STATE)))); + } + } catch (RemoteException ex) { + loge("requestSelectedNbIotSatelliteSubscriptionId() RemoteException: " + ex); + executor.execute(() -> Binder.withCleanCallingIdentity(() -> callback.onError( + new SatelliteException(SATELLITE_RESULT_ILLEGAL_STATE)))); + } + } + + /** * Inform whether the device is aligned with the satellite in both real and demo mode. * * In demo mode, framework will send datagram to modem only when device is aligned with diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index a58427318b55..d22e9fa20101 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -3018,6 +3018,17 @@ interface ITelephony { + "android.Manifest.permission.SATELLITE_COMMUNICATION)") void requestTimeForNextSatelliteVisibility(in ResultReceiver receiver); + + /** + * Request to get the currently selected satellite subscription id. + * + * @param receiver Result receiver to get the error code of the request and the currently + * selected satellite subscription id. + */ + @JavaPassthrough(annotation="@android.annotation.RequiresPermission(" + + "android.Manifest.permission.SATELLITE_COMMUNICATION)") + void requestSelectedNbIotSatelliteSubscriptionId(in ResultReceiver receiver); + /** * Inform whether the device is aligned with the satellite in both real and demo mode. * |