Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7502259d authored by Aishwarya Mallampati's avatar Aishwarya Mallampati
Browse files

Added send satellite datagram.

Bug: 260896985
Test: atest SatelliteManagerTest
Change-Id: I56cbd934fdded25f1dfebced10a0b7212a2e1215
parent 67f50390
Loading
Loading
Loading
Loading
+39 −0
Original line number Original line Diff line number Diff line
@@ -1070,6 +1070,45 @@ public class SatelliteManager {
        return SATELLITE_REQUEST_FAILED;
        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<Integer> 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() {
    private static ITelephony getITelephony() {
        ITelephony binder = ITelephony.Stub.asInterface(TelephonyFrameworkInitializer
        ITelephony binder = ITelephony.Stub.asInterface(TelephonyFrameworkInitializer
                .getTelephonyServiceManager()
                .getTelephonyServiceManager()
+14 −0
Original line number Original line Diff line number Diff line
@@ -69,6 +69,7 @@ import android.telephony.ims.aidl.IImsRegistrationCallback;
import android.telephony.ims.aidl.IRcsConfigCallback;
import android.telephony.ims.aidl.IRcsConfigCallback;
import android.telephony.satellite.ISatelliteStateListener;
import android.telephony.satellite.ISatelliteStateListener;
import android.telephony.satellite.SatelliteCapabilities;
import android.telephony.satellite.SatelliteCapabilities;
import android.telephony.satellite.SatelliteDatagram;
import com.android.ims.internal.IImsServiceFeatureCallback;
import com.android.ims.internal.IImsServiceFeatureCallback;
import com.android.internal.telephony.CellNetworkScanResult;
import com.android.internal.telephony.CellNetworkScanResult;
import com.android.internal.telephony.IBooleanConsumer;
import com.android.internal.telephony.IBooleanConsumer;
@@ -2894,4 +2895,17 @@ interface ITelephony {
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission("
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission("
                + "android.Manifest.permission.SATELLITE_COMMUNICATION)")
                + "android.Manifest.permission.SATELLITE_COMMUNICATION)")
    int pollPendingSatelliteDatagrams(int subId);
    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);
}
}