From 7502259de0bd131a90bfda4b97a5b7560249d7bc Mon Sep 17 00:00:00 2001 From: Aishwarya Mallampati Date: Thu, 9 Feb 2023 22:10:45 +0000 Subject: [PATCH] Added send satellite datagram. Bug: 260896985 Test: atest SatelliteManagerTest Change-Id: I56cbd934fdded25f1dfebced10a0b7212a2e1215 --- .../telephony/satellite/SatelliteManager.java | 39 +++++++++++++++++++ .../internal/telephony/ITelephony.aidl | 14 +++++++ 2 files changed, 53 insertions(+) diff --git a/telephony/java/android/telephony/satellite/SatelliteManager.java b/telephony/java/android/telephony/satellite/SatelliteManager.java index 5f6218da93228..100799e67c36e 100644 --- a/telephony/java/android/telephony/satellite/SatelliteManager.java +++ b/telephony/java/android/telephony/satellite/SatelliteManager.java @@ -1070,6 +1070,45 @@ public class SatelliteManager { return SATELLITE_REQUEST_FAILED; } + /** + * Send datagram over satellite. + * @param datagramType - type of datagram + * @param datagram - datagram to send over satellite + * @param executor - The executor on which the result listener will be called. + * @param resultListener - Listener that will be called with the 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) + public void sendSatelliteDatagram(@DatagramType int datagramType, + @NonNull SatelliteDatagram datagram, @NonNull @CallbackExecutor Executor executor, + @SatelliteError @NonNull Consumer resultListener) { + Objects.requireNonNull(datagram); + Objects.requireNonNull(executor); + Objects.requireNonNull(resultListener); + + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + IIntegerConsumer internalCallback = new IIntegerConsumer.Stub() { + @Override + public void accept(int result) { + executor.execute(() -> Binder.withCleanCallingIdentity( + () -> resultListener.accept(result))); + } + }; + telephony.sendSatelliteDatagram(mSubId, datagramType, datagram, + internalCallback); + } else { + throw new IllegalStateException("telephony service is null."); + } + } catch (RemoteException ex) { + loge("sendSatelliteDatagram() RemoteException:" + ex); + ex.rethrowFromSystemServer(); + } + } + private static ITelephony getITelephony() { ITelephony binder = ITelephony.Stub.asInterface(TelephonyFrameworkInitializer .getTelephonyServiceManager() diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 331ee6f4dd2bc..9090edb098703 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -69,6 +69,7 @@ import android.telephony.ims.aidl.IImsRegistrationCallback; import android.telephony.ims.aidl.IRcsConfigCallback; import android.telephony.satellite.ISatelliteStateListener; import android.telephony.satellite.SatelliteCapabilities; +import android.telephony.satellite.SatelliteDatagram; import com.android.ims.internal.IImsServiceFeatureCallback; import com.android.internal.telephony.CellNetworkScanResult; import com.android.internal.telephony.IBooleanConsumer; @@ -2894,4 +2895,17 @@ interface ITelephony { @JavaPassthrough(annotation="@android.annotation.RequiresPermission(" + "android.Manifest.permission.SATELLITE_COMMUNICATION)") int pollPendingSatelliteDatagrams(int subId); + + /** + * Send datagram over satellite. + * + * @param subId - The subId of the subscription used for receiving datagrams. + * @param datagramType - type of datagram + * @param datagram - datagram to send over satellite + * @param callback - The callback to get the error code of the request. + */ + @JavaPassthrough(annotation="@android.annotation.RequiresPermission(" + + "android.Manifest.permission.SATELLITE_COMMUNICATION)") + void sendSatelliteDatagram(int subId, int datagramType, in SatelliteDatagram datagram, + IIntegerConsumer callback); }