diff options
Diffstat (limited to 'src/java/com/android/internal/telephony/satellite/DatagramController.java')
-rw-r--r-- | src/java/com/android/internal/telephony/satellite/DatagramController.java | 73 |
1 files changed, 60 insertions, 13 deletions
diff --git a/src/java/com/android/internal/telephony/satellite/DatagramController.java b/src/java/com/android/internal/telephony/satellite/DatagramController.java index e7f09c23ed..0c68d4b328 100644 --- a/src/java/com/android/internal/telephony/satellite/DatagramController.java +++ b/src/java/com/android/internal/telephony/satellite/DatagramController.java @@ -16,6 +16,9 @@ package com.android.internal.telephony.satellite; +import static android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_CONNECTED; +import static android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_DATAGRAM_TRANSFERRING; + import android.annotation.NonNull; import android.content.Context; import android.os.Build; @@ -43,9 +46,12 @@ public class DatagramController { @NonNull private final PointingAppController mPointingAppController; @NonNull private final DatagramDispatcher mDatagramDispatcher; @NonNull private final DatagramReceiver mDatagramReceiver; + public static final long MAX_DATAGRAM_ID = (long) Math.pow(2, 16); public static final int ROUNDING_UNIT = 10; public static final long SATELLITE_ALIGN_TIMEOUT = TimeUnit.SECONDS.toMillis(30); + public static final long DATAGRAM_WAIT_FOR_CONNECTED_STATE_TIMEOUT = + TimeUnit.SECONDS.toMillis(60); private static final String ALLOW_MOCK_MODEM_PROPERTY = "persist.radio.allow_mock_modem"; private static final boolean DEBUG = !"user".equals(Build.TYPE); @@ -59,7 +65,7 @@ public class DatagramController { @GuardedBy("mLock") private int mSendPendingCount = 0; @GuardedBy("mLock") - private int mSendErrorCode = SatelliteManager.SATELLITE_ERROR_NONE; + private int mSendErrorCode = SatelliteManager.SATELLITE_RESULT_SUCCESS; /** Variables used to update onReceiveDatagramStateChanged(). */ @GuardedBy("mLock") private int mReceiveSubId; @@ -69,11 +75,15 @@ public class DatagramController { @GuardedBy("mLock") private int mReceivePendingCount = 0; @GuardedBy("mLock") - private int mReceiveErrorCode = SatelliteManager.SATELLITE_ERROR_NONE; + private int mReceiveErrorCode = SatelliteManager.SATELLITE_RESULT_SUCCESS; private SatelliteDatagram mDemoModeDatagram; private boolean mIsDemoMode = false; private long mAlignTimeoutDuration = SATELLITE_ALIGN_TIMEOUT; + private long mDatagramWaitTimeForConnectedState = DATAGRAM_WAIT_FOR_CONNECTED_STATE_TIMEOUT; + @GuardedBy("mLock") + @SatelliteManager.SatelliteModemState + private int mSatelltieModemState = SatelliteManager.SATELLITE_MODEM_STATE_UNKNOWN; /** * @return The singleton instance of DatagramController. @@ -130,9 +140,9 @@ public class DatagramController { * @param subId The subId of the subscription to register for incoming satellite datagrams. * @param callback The callback to handle incoming datagrams over satellite. * - * @return The {@link SatelliteManager.SatelliteError} result of the operation. + * @return The {@link SatelliteManager.SatelliteResult} result of the operation. */ - @SatelliteManager.SatelliteError public int registerForSatelliteDatagram(int subId, + @SatelliteManager.SatelliteResult public int registerForSatelliteDatagram(int subId, @NonNull ISatelliteDatagramCallback callback) { return mDatagramReceiver.registerForSatelliteDatagram(subId, callback); } @@ -159,7 +169,7 @@ public class DatagramController { * long, SatelliteDatagram, int, Consumer)} * * @param subId The subId of the subscription used for receiving datagrams. - * @param callback The callback to get {@link SatelliteManager.SatelliteError} of the request. + * @param callback The callback to get {@link SatelliteManager.SatelliteResult} of the request. */ public void pollPendingSatelliteDatagrams(int subId, @NonNull Consumer<Integer> callback) { mDatagramReceiver.pollPendingSatelliteDatagrams(subId, callback); @@ -182,7 +192,7 @@ public class DatagramController { * Datagram will be passed down to modem without any encoding or encryption. * @param needFullScreenPointingUI this is used to indicate pointingUI app to open in * full screen mode. - * @param callback The callback to get {@link SatelliteManager.SatelliteError} of the request. + * @param callback The callback to get {@link SatelliteManager.SatelliteResult} of the request. */ public void sendSatelliteDatagram(int subId, @SatelliteManager.DatagramType int datagramType, @NonNull SatelliteDatagram datagram, boolean needFullScreenPointingUI, @@ -267,13 +277,16 @@ public class DatagramController { * @param state Current satellite modem state. */ public void onSatelliteModemStateChanged(@SatelliteManager.SatelliteModemState int state) { + synchronized (mLock) { + mSatelltieModemState = state; + } mDatagramDispatcher.onSatelliteModemStateChanged(state); mDatagramReceiver.onSatelliteModemStateChanged(state); } - void onDeviceAlignedWithSatellite(boolean isAligned) { - mDatagramDispatcher.onDeviceAlignedWithSatellite(isAligned); - mDatagramReceiver.onDeviceAlignedWithSatellite(isAligned); + void setDeviceAlignedWithSatellite(boolean isAligned) { + mDatagramDispatcher.setDeviceAlignedWithSatellite(isAligned); + mDatagramReceiver.setDeviceAlignedWithSatellite(isAligned); } @VisibleForTesting @@ -284,17 +297,33 @@ public class DatagramController { } } + /** + * Check if Telephony needs to wait for the modem satellite connected to a satellite network + * before transferring datagrams via satellite. + */ + @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) + public boolean needsWaitingForSatelliteConnected() { + synchronized (mLock) { + if (SatelliteController.getInstance().isSatelliteAttachRequired() + && mSatelltieModemState != SATELLITE_MODEM_STATE_CONNECTED + && mSatelltieModemState != SATELLITE_MODEM_STATE_DATAGRAM_TRANSFERRING) { + return true; + } + return false; + } + } + public boolean isSendingInIdleState() { synchronized (mLock) { - return mSendDatagramTransferState == - SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_IDLE; + return (mSendDatagramTransferState + == SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_IDLE); } } public boolean isPollingInIdleState() { synchronized (mLock) { - return mReceiveDatagramTransferState == - SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_IDLE; + return (mReceiveDatagramTransferState + == SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_IDLE); } } @@ -336,6 +365,11 @@ public class DatagramController { return mAlignTimeoutDuration; } + @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) + public long getDatagramWaitTimeForConnectedState() { + return mDatagramWaitTimeForConnectedState; + } + /** * This API can be used by only CTS to update the timeout duration in milliseconds whether * the device is aligned with the satellite for demo mode @@ -351,6 +385,7 @@ public class DatagramController { logd("setSatelliteDeviceAlignedTimeoutDuration: timeoutMillis=" + timeoutMillis); mAlignTimeoutDuration = timeoutMillis; + mDatagramWaitTimeForConnectedState = timeoutMillis; return true; } @@ -369,6 +404,18 @@ public class DatagramController { } } + /** + * This API can be used by only CTS to override the cached value for the device overlay config + * value : config_send_satellite_datagram_to_modem_in_demo_mode, which determines whether + * outgoing satellite datagrams should be sent to modem in demo mode. + * + * @param shouldSendToModemInDemoMode Whether send datagram in demo mode should be sent to + * satellite modem or not. + */ + void setShouldSendDatagramToModemInDemoMode(boolean shouldSendToModemInDemoMode) { + mDatagramDispatcher.setShouldSendDatagramToModemInDemoMode(shouldSendToModemInDemoMode); + } + private static void logd(@NonNull String log) { Rlog.d(TAG, log); } |