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

Commit 8754ca79 authored by Sarah Chin's avatar Sarah Chin Committed by Android (Google) Code Review
Browse files

Merge "Added send satellite datagram."

parents db958d5e 7502259d
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -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<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() {
        ITelephony binder = ITelephony.Stub.asInterface(TelephonyFrameworkInitializer
                .getTelephonyServiceManager()
+14 −0
Original line number Diff line number Diff line
@@ -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);
}