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

Commit 6fb2a536 authored by Aishwarya Mallampati's avatar Aishwarya Mallampati
Browse files

Cleanup satellite messaging pipeline.

The following changes are made in this CL:
- Added new error code in SatelliteManager:
  SATELLITE_SEND_REQUEST_ABORTED
- Added config for datagram receiver ack timeout.
- Added ILongConsumer.aidl
- Removed ISatelliteDatagramReceiverAck.aidl
- sendSatelliteDatagram(): Removed datagramId and replaced
  OutcomeReceiver with IIntegerConsumer

Bug: 269637555
Change-Id: Ib343134c439e3e92b72e7dcd576cbfd4ff2f0ad1
parent d22cb8f2
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -114,6 +114,11 @@
    <string name="config_pointing_ui_package" translatable="false"></string>
    <java-symbol type="string" name="config_pointing_ui_package" />

    <!-- Telephony resends received satellite datagram to listener
         if ack is not received within this timeout -->
    <integer name="config_timeout_to_receive_delivered_ack_millis">300000</integer>
    <java-symbol type="integer" name="config_timeout_to_receive_delivered_ack_millis" />

    <!-- Whether enhanced IWLAN handover check is enabled. If enabled, telephony frameworks
         will not perform handover if the target transport is out of service, or VoPS not
         supported. The network will be torn down on the source transport, and will be
+6 −5
Original line number Diff line number Diff line
@@ -16,9 +16,10 @@

package android.telephony.satellite;

import android.telephony.satellite.ISatelliteDatagramReceiverAck;
import android.telephony.satellite.SatelliteDatagram;

import com.android.internal.telephony.ILongConsumer;

/**
 * Interface for satellite datagrams callback.
 * @hide
@@ -30,10 +31,10 @@ oneway interface ISatelliteDatagramCallback {
     * @param datagramId An id that uniquely identifies incoming datagram.
     * @param datagram Datagram received from satellite.
     * @param pendingCount Number of datagrams yet to be received from satellite.
     * @param callback This callback will be used by datagram receiver app to send ack back to
     *                 Telephony. If the callback is not received within five minutes,
     *                 Telephony will resend the datagrams.
     * @param callback This callback will be used by datagram receiver app to send received
     *                 datagramId to Telephony. If the callback is not received within five minutes,
     *                 Telephony will resend the datagram.
     */
    void onSatelliteDatagramReceived(long datagramId, in SatelliteDatagram datagram,
            int pendingCount, ISatelliteDatagramReceiverAck callback);
            int pendingCount, ILongConsumer callback);
}
+11 −7
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package android.telephony.satellite;
import android.annotation.NonNull;
import android.os.Binder;

import com.android.internal.telephony.ILongConsumer;

import java.util.concurrent.Executor;

/**
@@ -38,8 +40,9 @@ public class SatelliteDatagramCallback {
        }

        @Override
        public void onSatelliteDatagramReceived(long datagramId, SatelliteDatagram datagram,
                int pendingCount, ISatelliteDatagramReceiverAck callback) {
        public void onSatelliteDatagramReceived(long datagramId,
                @NonNull SatelliteDatagram datagram, int pendingCount,
                @NonNull ILongConsumer callback) {
            final long callingIdentity = Binder.clearCallingIdentity();
            try {
                mExecutor.execute(() -> mLocalCallback.onSatelliteDatagramReceived(datagramId,
@@ -59,17 +62,18 @@ public class SatelliteDatagramCallback {
     * @param datagramId An id that uniquely identifies incoming datagram.
     * @param datagram Datagram to be received over satellite.
     * @param pendingCount Number of datagrams yet to be received by the app.
     * @param callback This callback will be used by datagram receiver app to send ack back to
     *                 Telephony.
     * @param callback This callback will be used by datagram receiver app to send received
     *                 datagramId to Telephony. If the callback is not received within five minutes,
     *                 Telephony will resend the datagram.
     */
    public void onSatelliteDatagramReceived(long datagramId, SatelliteDatagram datagram,
            int pendingCount, ISatelliteDatagramReceiverAck callback) {
    public void onSatelliteDatagramReceived(long datagramId, @NonNull SatelliteDatagram datagram,
            int pendingCount, @NonNull ILongConsumer callback) {
        // Base Implementation
    }

    /** @hide */
    @NonNull
    public final ISatelliteDatagramCallback getBinder() {
    final ISatelliteDatagramCallback getBinder() {
        return mBinder;
    }

+12 −37
Original line number Diff line number Diff line
@@ -165,13 +165,6 @@ public class SatelliteManager {
     */
    public static final String KEY_SATELLITE_NEXT_VISIBILITY = "satellite_next_visibility";

    /**
     * Bundle key to get the respoonse from {@link
     * #sendSatelliteDatagram(long, int, SatelliteDatagram, boolean, Executor, OutcomeReceiver)}.
     * @hide
     */
    public static final String KEY_SEND_SATELLITE_DATAGRAM = "send_satellite_datagram";

    /**
     * The request was successfully processed.
     */
@@ -239,6 +232,8 @@ public class SatelliteManager {
    public static final int SATELLITE_SERVICE_PROVISION_IN_PROGRESS = 14;
    /**
     * The ongoing request was aborted by either the satellite modem or the network.
     * This error is also returned when framework decides to abort current send request as one
     * of the previous send request failed.
     */
    public static final int SATELLITE_REQUEST_ABORTED = 15;
    /**
@@ -1268,7 +1263,6 @@ public class SatelliteManager {
     * input to this method. Datagram received here will be passed down to modem without any
     * encoding or encryption.
     *
     * @param datagramId An id that uniquely identifies datagram requested to be sent.
     * @param datagramType datagram type indicating whether the datagram is of type
     *                     SOS_SMS or LOCATION_SHARING.
     * @param datagram encoded gateway datagram which is encrypted by the caller.
@@ -1283,51 +1277,32 @@ public class SatelliteManager {
     *                                 user activity and the application's ability to determine the
     *                                 best possible UX experience for the user.
     * @param executor The executor on which the result listener will be called.
     * @param callback The callback object to which the result will be returned.
     *                 If datagram is sent successfully, then
     *                 {@link OutcomeReceiver#onResult(Object)} will return datagramId.
     *                 If the request is not successful, {@link OutcomeReceiver#onError(Throwable)}
     *                 will return a {@link SatelliteException} with the {@link SatelliteError}.
     * @param resultListener Listener for the {@link SatelliteError} 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(long datagramId, @DatagramType int datagramType,
    public void sendSatelliteDatagram(@DatagramType int datagramType,
            @NonNull SatelliteDatagram datagram, boolean needFullScreenPointingUI,
            @NonNull @CallbackExecutor Executor executor,
            @NonNull OutcomeReceiver<Long, SatelliteException> callback) {
            @SatelliteError @NonNull Consumer<Integer> resultListener) {
        Objects.requireNonNull(datagram);
        Objects.requireNonNull(executor);
        Objects.requireNonNull(callback);
        Objects.requireNonNull(resultListener);

        try {
            ITelephony telephony = getITelephony();
            if (telephony != null) {
                ResultReceiver receiver = new ResultReceiver(null) {
                IIntegerConsumer internalCallback = new IIntegerConsumer.Stub() {
                    @Override
                    protected void onReceiveResult(int resultCode, Bundle resultData) {
                        if (resultCode == SATELLITE_ERROR_NONE) {
                            if (resultData.containsKey(KEY_SEND_SATELLITE_DATAGRAM)) {
                                long resultDatagramId = resultData
                                        .getLong(KEY_SEND_SATELLITE_DATAGRAM);
                                executor.execute(() -> Binder.withCleanCallingIdentity(() ->
                                        callback.onResult(resultDatagramId)));
                            } else {
                                loge("KEY_SEND_SATELLITE_DATAGRAM does not exist.");
                                executor.execute(() -> Binder.withCleanCallingIdentity(() ->
                                        callback.onError(
                                                new SatelliteException(SATELLITE_REQUEST_FAILED))));
                            }

                        } else {
                            executor.execute(() -> Binder.withCleanCallingIdentity(() ->
                                    callback.onError(new SatelliteException(resultCode))));
                        }
                    public void accept(int result) {
                        executor.execute(() -> Binder.withCleanCallingIdentity(
                                () -> resultListener.accept(result)));
                    }
                };
                telephony.sendSatelliteDatagram(mSubId, datagramId, datagramType, datagram,
                        needFullScreenPointingUI, receiver);
                telephony.sendSatelliteDatagram(mSubId, datagramType, datagram,
                        needFullScreenPointingUI, internalCallback);
            } else {
                throw new IllegalStateException("telephony service is null.");
            }
+1 −1
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ public class SatellitePositionUpdateCallback {

    /**@hide*/
    @NonNull
    public final ISatellitePositionUpdateCallback getBinder() {
    final ISatellitePositionUpdateCallback getBinder() {
        return mBinder;
    }

Loading