Add overlay configs for sending and enabling timeout

Bug: 323571903
Test: atest SatelliteManagerTestOnMockService SatelliteControllerTest DatagramDispatcherTest
Manual test with SatelliteTestApp. SMS, MMS, call with live network.

Change-Id: I4f5a1b6b60571f19e6e5bcdf97bb919455b72492
diff --git a/core/res/res/values/config_telephony.xml b/core/res/res/values/config_telephony.xml
index d0216b30..c14fe57 100644
--- a/core/res/res/values/config_telephony.xml
+++ b/core/res/res/values/config_telephony.xml
@@ -172,6 +172,35 @@
     <integer name="config_satellite_nb_iot_inactivity_timeout_millis">180000</integer>
     <java-symbol type="integer" name="config_satellite_nb_iot_inactivity_timeout_millis" />
 
+    <!-- The time duration in millis needed to switch the modem image from TN to NTN. -->
+    <integer name="config_satellite_modem_image_switching_duration_millis">20000</integer>
+    <java-symbol type="integer" name="config_satellite_modem_image_switching_duration_millis" />
+
+    <!-- The time duration in millis after which Telephony will abort the datagram sending requests.
+         Telephony starts a timer when receiving a datagram sending request in either OFF, IDLE, or
+         NOT_CONNECTED state. In NOT_CONNECTED, the duration of the timer is given by this config.
+         In OFF or IDLE state, the duration of the timer is the sum of this config and the
+         config_satellite_modem_image_switching_duration_millis.
+         -->
+    <integer name="config_datagram_wait_for_connected_state_timeout_millis">60000</integer>
+    <java-symbol type="integer" name="config_datagram_wait_for_connected_state_timeout_millis" />
+
+    <!-- The time duration in millis after which Telephony will stop waiting for the response of the
+         satellite enable request from modem, and send failure response to the client that has
+         requested Telephony to enable satellite.
+         -->
+    <integer name="config_wait_for_satellite_enabling_response_timeout_millis">180000</integer>
+    <java-symbol type="integer" name="config_wait_for_satellite_enabling_response_timeout_millis" />
+
+    <!-- The time duration in millis after which Telephony will abort the datagram sending requests
+         and send failure response to the client that has requested sending the datagrams. Telephony
+         starts a timer after pushing down the datagram sending request to modem. Before expiry, the
+         timer will be stopped when Telephony receives the response for the sending request from
+         modem.
+         -->
+    <integer name="config_wait_for_datagram_sending_response_timeout_millis">180000</integer>
+    <java-symbol type="integer" name="config_wait_for_datagram_sending_response_timeout_millis" />
+
     <!-- The timeout duration in milliseconds to determine whether to recommend Dialer to show the
          emergency messaging option to users.
 
diff --git a/telephony/java/android/telephony/satellite/stub/ISatellite.aidl b/telephony/java/android/telephony/satellite/stub/ISatellite.aidl
index 711be02..9441fb5 100644
--- a/telephony/java/android/telephony/satellite/stub/ISatellite.aidl
+++ b/telephony/java/android/telephony/satellite/stub/ISatellite.aidl
@@ -501,4 +501,22 @@
      *   SatelliteResult:SATELLITE_RESULT_REQUEST_NOT_SUPPORTED
      */
      void stopSendingNtnSignalStrength(in IIntegerConsumer resultCallback);
+
+     /**
+      * Abort all outgoing satellite datagrams which vendor service has received from Telephony
+      * framework.
+      *
+      * This API helps modem to be in sync with framework when framework times out on sending
+      * datagrams.
+      *
+      * @param resultCallback The callback to receive the error code result of the operation.
+      *
+      * Valid result codes returned:
+      *   SatelliteResult:SATELLITE_RESULT_SUCCESS
+      *   SatelliteResult:SATELLITE_RESULT_INVALID_MODEM_STATE
+      *   SatelliteResult:SATELLITE_RESULT_MODEM_ERROR
+      *   SatelliteResult:SATELLITE_RESULT_RADIO_NOT_AVAILABLE
+      *   SatelliteResult:SATELLITE_RESULT_REQUEST_NOT_SUPPORTED
+      */
+     void abortSendingSatelliteDatagrams(in IIntegerConsumer resultCallback);
 }
diff --git a/telephony/java/android/telephony/satellite/stub/SatelliteImplBase.java b/telephony/java/android/telephony/satellite/stub/SatelliteImplBase.java
index abacd15..f17ff17 100644
--- a/telephony/java/android/telephony/satellite/stub/SatelliteImplBase.java
+++ b/telephony/java/android/telephony/satellite/stub/SatelliteImplBase.java
@@ -265,6 +265,14 @@
                     "stopSendingNtnSignalStrength");
         }
 
+        @Override
+        public void abortSendingSatelliteDatagrams(IIntegerConsumer resultCallback)
+                throws RemoteException {
+            executeMethodAsync(
+                    () -> SatelliteImplBase.this.abortSendingSatelliteDatagrams(resultCallback),
+                    "abortSendingSatelliteDatagrams");
+        }
+
         // Call the methods with a clean calling identity on the executor and wait indefinitely for
         // the future to return.
         private void executeMethodAsync(Runnable r, String errorLogName) throws RemoteException {
@@ -783,4 +791,13 @@
     public void stopSendingNtnSignalStrength(@NonNull IIntegerConsumer resultCallback){
         // stub implementation
     }
+
+    /**
+     * Requests to abort sending satellite datagrams
+     *
+     * @param resultCallback The {@link SatelliteError} result of the operation.
+     */
+    public void abortSendingSatelliteDatagrams(@NonNull IIntegerConsumer resultCallback){
+        // stub implementation
+    }
 }
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index bd47b1f..ff2ee27 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -3046,13 +3046,24 @@
     boolean setSatellitePointingUiClassName(in String packageName, in String className);
 
     /**
-     * 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
+     * This API can be used by only CTS to override the timeout durations used by the
+     * DatagramController module.
      *
      * @param timeoutMillis The timeout duration in millisecond.
      * @return {@code true} if the timeout duration is set successfully, {@code false} otherwise.
      */
-    boolean setSatelliteDeviceAlignedTimeoutDuration(long timeoutMillis);
+    boolean setDatagramControllerTimeoutDuration(
+            boolean reset, int timeoutType, long timeoutMillis);
+
+    /**
+     * This API can be used by only CTS to override the timeout durations used by the
+     * SatelliteController module.
+     *
+     * @param timeoutMillis The timeout duration in millisecond.
+     * @return {@code true} if the timeout duration is set successfully, {@code false} otherwise.
+     */
+    boolean setSatelliteControllerTimeoutDuration(
+            boolean reset, int timeoutType, long timeoutMillis);
 
     /**
      * This API can be used in only testing to override connectivity status in monitoring emergency