Snap for 11873904 from b3a16d16e4aaba952dfd5dedcf5963f0be11930f to aml-frc-release Change-Id: I57a7bb4039e48d2db070dbe085822a2ca083b067
diff --git a/satellite_client/src/android/telephony/satellite/wrapper/CarrierRoamingNtnModeListenerWrapper.java b/satellite_client/src/android/telephony/satellite/wrapper/CarrierRoamingNtnModeListenerWrapper.java new file mode 100644 index 0000000..4a2436e --- /dev/null +++ b/satellite_client/src/android/telephony/satellite/wrapper/CarrierRoamingNtnModeListenerWrapper.java
@@ -0,0 +1,31 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telephony.satellite.wrapper; + +/** Interface for carrier roaming non-terrestrial network listener. */ +public interface CarrierRoamingNtnModeListenerWrapper { + /** + * Callback invoked when carrier roaming non-terrestrial network mode changes. + * + * @param active {@code true} If the device is connected to carrier roaming + * non-terrestrial network or was connected within the + * {CarrierConfigManager + * #KEY_SATELLITE_CONNECTION_HYSTERESIS_SEC_INT} duration, + * {code false} otherwise. + */ + void onCarrierRoamingNtnModeChanged(boolean active); +}
diff --git a/satellite_client/src/android/telephony/satellite/wrapper/SatelliteManagerWrapper.java b/satellite_client/src/android/telephony/satellite/wrapper/SatelliteManagerWrapper.java index 6406109..994c5a2 100644 --- a/satellite_client/src/android/telephony/satellite/wrapper/SatelliteManagerWrapper.java +++ b/satellite_client/src/android/telephony/satellite/wrapper/SatelliteManagerWrapper.java
@@ -32,6 +32,7 @@ import android.telephony.ServiceState; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; +import android.telephony.TelephonyCallback; import android.telephony.TelephonyManager; import android.telephony.satellite.AntennaPosition; import android.telephony.satellite.EnableRequestAttributes; @@ -99,6 +100,10 @@ SatelliteSupportedStateCallbackWrapper, SatelliteSupportedStateCallback> sSatelliteSupportedStateCallbackWrapperMap = new ConcurrentHashMap<>(); + private static final ConcurrentHashMap< + CarrierRoamingNtnModeListenerWrapper, TelephonyCallback.CarrierRoamingNtnModeListener> + sCarrierRoamingNtnModeListenerWrapperMap = new ConcurrentHashMap<>(); + private final SatelliteManager mSatelliteManager; private final SubscriptionManager mSubscriptionManager; private final TelephonyManager mTelephonyManager; @@ -133,7 +138,16 @@ * This type of datagram is used to keep the device in satellite connected state. */ public static final int DATAGRAM_TYPE_KEEP_ALIVE = 3; - + /** + * Datagram type indicating that the datagram to be sent or received is of type SOS message and + * is the last message to emergency service provider indicating still needs help. + */ + public static final int DATAGRAM_TYPE_LAST_SOS_MESSAGE_STILL_NEED_HELP = 4; + /** + * Datagram type indicating that the datagram to be sent or received is of type SOS message and + * is the last message to emergency service provider indicating no more help is needed. + */ + public static final int DATAGRAM_TYPE_LAST_SOS_MESSAGE_NO_HELP_NEEDED = 5; /** @hide */ @IntDef( prefix = "DATAGRAM_TYPE_", @@ -141,7 +155,9 @@ DATAGRAM_TYPE_UNKNOWN, DATAGRAM_TYPE_SOS_MESSAGE, DATAGRAM_TYPE_LOCATION_SHARING, - DATAGRAM_TYPE_KEEP_ALIVE + DATAGRAM_TYPE_KEEP_ALIVE, + DATAGRAM_TYPE_LAST_SOS_MESSAGE_STILL_NEED_HELP, + DATAGRAM_TYPE_LAST_SOS_MESSAGE_NO_HELP_NEEDED }) @Retention(RetentionPolicy.SOURCE) public @interface DatagramType {} @@ -801,6 +817,34 @@ } } + /** Register for carrier roaming non-terrestrial network mode changes. */ + public void registerForCarrierRoamingNtnModeChanged(int subId, + @NonNull @CallbackExecutor Executor executor, + @NonNull CarrierRoamingNtnModeListenerWrapper listener) { + TelephonyCallback.CarrierRoamingNtnModeListener internalListener = new TelephonyCallback + .CarrierRoamingNtnModeListener() { + @Override + public void onCarrierRoamingNtnModeChanged(boolean active) { + listener.onCarrierRoamingNtnModeChanged(active); + } + }; + sCarrierRoamingNtnModeListenerWrapperMap.put(listener, internalListener); + + TelephonyManager tm = mTelephonyManager.createForSubscriptionId(subId); + tm.registerTelephonyCallback(executor, (TelephonyCallback) internalListener); + } + + /** Unregister for carrier roaming non-terrestrial network mode changes. */ + public void unregisterForCarrierRoamingNtnModeChanged(int subId, + @NonNull CarrierRoamingNtnModeListenerWrapper listener) { + TelephonyCallback.CarrierRoamingNtnModeListener internalListener = + sCarrierRoamingNtnModeListenerWrapperMap.get(listener); + if (internalListener != null) { + TelephonyManager tm = mTelephonyManager.createForSubscriptionId(subId); + tm.unregisterTelephonyCallback((TelephonyCallback) internalListener); + } + } + /** Poll pending satellite datagrams over satellite. */ public void pollPendingDatagrams( @NonNull @CallbackExecutor Executor executor,