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

Commit e5fccdfb authored by Aishwarya Mallampati's avatar Aishwarya Mallampati Committed by Android (Google) Code Review
Browse files

Merge "Added getMaxCharPerTextMessage() API."

parents 74ecc642 49bffb80
Loading
Loading
Loading
Loading
+54 −4
Original line number Diff line number Diff line
@@ -25,19 +25,23 @@ import android.annotation.RequiresFeature;
import android.annotation.RequiresPermission;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Binder;
import android.os.RemoteException;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyFrameworkInitializer;
import android.util.ArrayMap;

import com.android.internal.telephony.IIntegerConsumer;
import com.android.internal.telephony.ITelephony;
import com.android.telephony.Rlog;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;

/**
 * Manages satellite operations such as provisioning, pointing, messaging, location sharing, etc.
@@ -116,9 +120,9 @@ public class SatelliteManager {
     */
    public static final int SATELLITE_SERVICE_SERVER_ERROR = 2;
    /**
     * Internal error received from the satellite service
     * Unexpected telephony internal error.
     */
    public static final int SATELLITE_SERVICE_INTERNAL_ERROR = 3;
    public static final int SATELLITE_SERVICE_TELEPHONY_INTERNAL_ERROR = 3;
    /**
     * Modem error received from the satellite service.
     */
@@ -176,12 +180,17 @@ public class SatelliteManager {
     */
    public static final int SATELLITE_SERVICE_ERROR = 17;

    /**
     * Satellite service is disabled on the requested subscription.
     */
    public static final int SATELLITE_SERVICE_DISABLED = 18;

    /** @hide */
    @IntDef(prefix = {"SATELLITE_SERVICE_"}, value = {
            SATELLITE_SERVICE_SUCCESS,
            SATELLITE_SERVICE_SERVER_NOT_REACHABLE,
            SATELLITE_SERVICE_SERVER_ERROR,
            SATELLITE_SERVICE_INTERNAL_ERROR,
            SATELLITE_SERVICE_TELEPHONY_INTERNAL_ERROR,
            SATELLITE_SERVICE_MODEM_ERROR,
            SATELLITE_SERVICE_SYSTEM_ERROR,
            SATELLITE_SERVICE_INVALID_ARGUMENTS,
@@ -195,7 +204,8 @@ public class SatelliteManager {
            SATELLITE_SERVICE_NO_RESOURCES,
            SATELLITE_SERVICE_REQUEST_FAILED,
            SATELLITE_SERVICE_INVALID_SUBSCRIPTION_ID,
            SATELLITE_SERVICE_ERROR
            SATELLITE_SERVICE_ERROR,
            SATELLITE_SERVICE_DISABLED
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface SatelliteServiceResult {}
@@ -345,6 +355,46 @@ public class SatelliteManager {
        return SATELLITE_SERVICE_REQUEST_FAILED;
    }

    /**
     * Get maximum number of characters per text message on satellite.
     * @param executor - The executor on which the result listener will be called.
     * @param resultListener - Listener that will be called when the operation is successful.
     *                       If this method returns {@link #SATELLITE_SERVICE_SUCCESS}, listener
     *                       will be called with maximum characters limit.
     *
     * @throws SecurityException if the caller doesn't have required permission.
     *
     * @return The result of the operation
     */
    @RequiresPermission(Manifest.permission.SATELLITE_COMMUNICATION)
    @SatelliteServiceResult
    public int getMaxCharactersPerSatelliteTextMessage(@NonNull @CallbackExecutor Executor executor,
            @NonNull Consumer<Integer> resultListener) {
        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)));
                    }
                };

                return telephony.getMaxCharactersPerSatelliteTextMessage(mSubId, internalCallback);
            } else {
                throw new IllegalStateException("telephony service is null.");
            }
        } catch (RemoteException ex) {
            loge("getMaxCharactersPerSatelliteTextMessage() RemoteException:" + ex);
            ex.rethrowFromSystemServer();
        }
        return SATELLITE_SERVICE_REQUEST_FAILED;
    }

    private static ITelephony getITelephony() {
        ITelephony binder = ITelephony.Stub.asInterface(TelephonyFrameworkInitializer
                .getTelephonyServiceManager()
+6 −1
Original line number Diff line number Diff line
@@ -2709,4 +2709,9 @@ interface ITelephony {
     * Stop receiving satellite pointing updates.
     */
    int stopSatellitePositionUpdates(int subId, int callbackId);

    /**
     * Get maximum number of characters per text message on satellite.
     */
    int getMaxCharactersPerSatelliteTextMessage(int subId, IIntegerConsumer internalCallback);
}
 No newline at end of file