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

Commit d93b105a authored by Thomas Nguyen's avatar Thomas Nguyen Committed by Android (Google) Code Review
Browse files

Merge "Support updating satellite listening timeout duration from CTS" into udc-dev

parents 1f8e0a19 10d6af18
Loading
Loading
Loading
Loading
+18 −6
Original line number Diff line number Diff line
@@ -1419,12 +1419,8 @@ public class SatelliteController extends Handler {
    public boolean setSatelliteServicePackageName(@Nullable String servicePackageName) {
        boolean result = mSatelliteModemInterface.setSatelliteServicePackageName(
                servicePackageName);
        if (result && (servicePackageName == null || servicePackageName.equals("null"))) {
            /**
             * Cached states like mIsSatelliteSupported and mIsSatelliteProvisioned are set to true
             * when running SatelliteManagerTestOnMockService. We need to reset them to the actual
             * states of the device.
             */
        if (result) {
            // Cached states need to be cleared whenever switching satellite vendor services.
            synchronized (mIsSatelliteSupportedLock) {
                mIsSatelliteSupported = null;
            }
@@ -1448,6 +1444,22 @@ public class SatelliteController extends Handler {
        return result;
    }

    /**
     * This API can be used by only CTS to update the timeout duration in milliseconds that
     * satellite should stay at listening mode to wait for the next incoming page before disabling
     * listening mode.
     *
     * @param timeoutMillis The timeout duration in millisecond.
     * @return {@code true} if the timeout duration is set successfully, {@code false} otherwise.
     */
    public boolean setSatelliteListeningTimeoutDuration(long timeoutMillis) {
        if (mSatelliteSessionController == null) {
            loge("mSatelliteSessionController is not initialized yet");
            return false;
        }
        return mSatelliteSessionController.setSatelliteListeningTimeoutDuration(timeoutMillis);
    }

    /**
     * This function is used by {@link SatelliteModemInterface} to notify
     * {@link SatelliteController} that the satellite vendor service was just connected.
+38 −3
Original line number Diff line number Diff line
@@ -26,11 +26,12 @@ import static android.telephony.satellite.SatelliteManager.SATELLITE_DATAGRAM_TR

import android.annotation.NonNull;
import android.content.Context;
import android.os.AsyncResult;
import android.os.Build;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.provider.DeviceConfig;
import android.telephony.Rlog;
import android.telephony.satellite.ISatelliteStateCallback;
@@ -53,6 +54,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
public class SatelliteSessionController extends StateMachine {
    private static final String TAG = "SatelliteSessionController";
    private static final boolean DBG = true;
    private static final String ALLOW_MOCK_MODEM_PROPERTY = "persist.radio.allow_mock_modem";
    private static final boolean DEBUG = !"user".equals(Build.TYPE);

    /**
     * The time duration in millis that the satellite will stay at listening mode to wait for the
@@ -90,8 +93,8 @@ public class SatelliteSessionController extends StateMachine {
    @NonNull private final ListeningState mListeningState = new ListeningState();
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    protected AtomicBoolean mIsSendingTriggeredDuringTransferringState;
    private final long mSatelliteStayAtListeningFromSendingMillis;
    private final long mSatelliteStayAtListeningFromReceivingMillis;
    private long mSatelliteStayAtListeningFromSendingMillis;
    private long mSatelliteStayAtListeningFromReceivingMillis;
    private final ConcurrentHashMap<IBinder, ISatelliteStateCallback> mListeners;
    @SatelliteManager.SatelliteModemState private int mCurrentState;
    final boolean mIsSatelliteSupported;
@@ -223,6 +226,34 @@ public class SatelliteSessionController extends StateMachine {
        mListeners.remove(callback.asBinder());
    }

    /**
     * This API can be used by only CTS to update the timeout duration in milliseconds that
     * satellite should stay at listening mode to wait for the next incoming page before disabling
     * listening mode.
     *
     * @param timeoutMillis The timeout duration in millisecond.
     * @return {@code true} if the timeout duration is set successfully, {@code false} otherwise.
     */
    boolean setSatelliteListeningTimeoutDuration(long timeoutMillis) {
        if (!isMockModemAllowed()) {
            loge("Updating listening timeout duration is not allowed");
            return false;
        }

        logd("setSatelliteListeningTimeoutDuration: timeoutMillis=" + timeoutMillis);
        if (timeoutMillis == 0) {
            mSatelliteStayAtListeningFromSendingMillis =
                    getSatelliteStayAtListeningFromSendingMillis();
            mSatelliteStayAtListeningFromReceivingMillis =
                    getSatelliteStayAtListeningFromReceivingMillis();
        } else {
            mSatelliteStayAtListeningFromSendingMillis = timeoutMillis;
            mSatelliteStayAtListeningFromReceivingMillis = timeoutMillis;
        }

        return true;
    }

    private static class DatagramTransferState {
        @SatelliteManager.SatelliteDatagramTransferState public int sendState;
        @SatelliteManager.SatelliteDatagramTransferState public int receiveState;
@@ -481,6 +512,10 @@ public class SatelliteSessionController extends StateMachine {
                || receiveState == SATELLITE_DATAGRAM_TRANSFER_STATE_RECEIVE_NONE);
    }

    private boolean isMockModemAllowed() {
        return (DEBUG || SystemProperties.getBoolean(ALLOW_MOCK_MODEM_PROPERTY, false));
    }

    private static long getSatelliteStayAtListeningFromSendingMillis() {
        return DeviceConfig.getLong(DeviceConfig.NAMESPACE_TELEPHONY,
                SATELLITE_STAY_AT_LISTENING_FROM_SENDING_MILLIS,