Snap for 12326234 from e4c4b096ebfb23c701bf49b408f846f509cf2f3e to mainline-appsearch-release Change-Id: Ibd5bb90a7cbdc272aa81180c4f00ac761521999e
diff --git a/satellite_client/src/android/telephony/satellite/wrapper/CarrierRoamingNtnModeListenerWrapper.java b/satellite_client/src/android/telephony/satellite/wrapper/CarrierRoamingNtnModeListenerWrapper.java index 1c0a840..ae5d24e 100644 --- a/satellite_client/src/android/telephony/satellite/wrapper/CarrierRoamingNtnModeListenerWrapper.java +++ b/satellite_client/src/android/telephony/satellite/wrapper/CarrierRoamingNtnModeListenerWrapper.java
@@ -31,22 +31,4 @@ * {code false} otherwise. */ void onCarrierRoamingNtnModeChanged(boolean active); - - /** - * Callback invoked when eligibility to connect to carrier roaming non-terrestrial network - * changes. - * - * @param eligible {@code true} when the device is eligible for satellite - * communication if all the following conditions are met: - * <ul> - * <li>Any subscription on the device supports P2P satellite messaging which is defined by - * {@link CarrierConfigManager#KEY_SATELLITE_ATTACH_SUPPORTED_BOOL} </li> - * <li>{@link CarrierConfigManager#KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT} set to - * {@link CarrierConfigManager#CARRIER_ROAMING_NTN_CONNECT_MANUAL} </li> - * <li>The device is in {@link ServiceState#STATE_OUT_OF_SERVICE}, not connected to Wi-Fi, - * and the hysteresis timer defined by {@link CarrierConfigManager - * #KEY_CARRIER_SUPPORTED_SATELLITE_NOTIFICATION_HYSTERESIS_SEC_INT} is expired. </li> - * </ul> - */ - default void onCarrierRoamingNtnEligibleStateChanged(boolean eligible) {} }
diff --git a/satellite_client/src/android/telephony/satellite/wrapper/CarrierRoamingNtnModeListenerWrapper2.java b/satellite_client/src/android/telephony/satellite/wrapper/CarrierRoamingNtnModeListenerWrapper2.java new file mode 100644 index 0000000..c180817 --- /dev/null +++ b/satellite_client/src/android/telephony/satellite/wrapper/CarrierRoamingNtnModeListenerWrapper2.java
@@ -0,0 +1,52 @@ +/* + * 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; + +import android.telephony.CarrierConfigManager; +import android.telephony.ServiceState; + +/** Interface for carrier roaming non-terrestrial network listener. */ +public interface CarrierRoamingNtnModeListenerWrapper2 { + /** + * 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); + + /** + * Callback invoked when eligibility to connect to carrier roaming non-terrestrial network + * changes. + * + * @param eligible {@code true} when the device is eligible for satellite + * communication if all the following conditions are met: + * <ul> + * <li>Any subscription on the device supports P2P satellite messaging which is defined by + * {@link CarrierConfigManager#KEY_SATELLITE_ATTACH_SUPPORTED_BOOL} </li> + * <li>{@link CarrierConfigManager#KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT} set to + * {@link CarrierConfigManager#CARRIER_ROAMING_NTN_CONNECT_MANUAL} </li> + * <li>The device is in {@link ServiceState#STATE_OUT_OF_SERVICE}, not connected to Wi-Fi, + * and the hysteresis timer defined by {@link CarrierConfigManager + * #KEY_CARRIER_SUPPORTED_SATELLITE_NOTIFICATION_HYSTERESIS_SEC_INT} is expired. </li> + * </ul> + */ + default void onCarrierRoamingNtnEligibleStateChanged(boolean eligible) {} +}
diff --git a/satellite_client/src/android/telephony/satellite/wrapper/SatelliteManagerWrapper.java b/satellite_client/src/android/telephony/satellite/wrapper/SatelliteManagerWrapper.java index 21a08c4..72c2db0 100644 --- a/satellite_client/src/android/telephony/satellite/wrapper/SatelliteManagerWrapper.java +++ b/satellite_client/src/android/telephony/satellite/wrapper/SatelliteManagerWrapper.java
@@ -90,6 +90,10 @@ SatelliteModemStateCallback> sSatelliteModemStateCallbackWrapperMap = new ConcurrentHashMap<>(); + private static final ConcurrentHashMap<SatelliteModemStateCallbackWrapper2, + SatelliteModemStateCallback> sSatelliteModemStateCallbackWrapperMap2 = + new ConcurrentHashMap<>(); + private static final ConcurrentHashMap< SatelliteTransmissionUpdateCallbackWrapper, SatelliteTransmissionUpdateCallback> sSatelliteTransmissionUpdateCallbackWrapperMap = new ConcurrentHashMap<>(); @@ -110,6 +114,10 @@ CarrierRoamingNtnModeListener> sCarrierRoamingNtnModeListenerWrapperMap = new ConcurrentHashMap<>(); + private static final ConcurrentHashMap<CarrierRoamingNtnModeListenerWrapper2, + CarrierRoamingNtnModeListener> + sCarrierRoamingNtnModeListenerWrapperMap2 = new ConcurrentHashMap<>(); + private static final ConcurrentHashMap<SatelliteCommunicationAllowedStateCallbackWrapper, SatelliteCommunicationAllowedStateCallback> sSatelliteCommunicationAllowedStateCallbackWrapperMap = new ConcurrentHashMap<>(); @@ -809,10 +817,6 @@ public void onSatelliteModemStateChanged(@SatelliteModemState int state) { callback.onSatelliteModemStateChanged(state); } - - public void onEmergencyModeChanged(boolean isEmergency) { - callback.onEmergencyModeChanged(isEmergency); - } }; sSatelliteModemStateCallbackWrapperMap.put(callback, internalCallback); @@ -821,6 +825,28 @@ return result; } + /** Registers for modem state changed from satellite modem. */ + @SatelliteResult + public int registerForModemStateChanged( + @NonNull @CallbackExecutor Executor executor, + @NonNull SatelliteModemStateCallbackWrapper2 callback) { + SatelliteModemStateCallback internalCallback = + new SatelliteModemStateCallback() { + public void onSatelliteModemStateChanged(@SatelliteModemState int state) { + callback.onSatelliteModemStateChanged(state); + } + + public void onEmergencyModeChanged(boolean isEmergency) { + callback.onEmergencyModeChanged(isEmergency); + } + }; + sSatelliteModemStateCallbackWrapperMap2.put(callback, internalCallback); + + int result = + mSatelliteManager.registerForModemStateChanged(executor, internalCallback); + return result; + } + /** * Unregisters for modem state changed from satellite modem. If callback was not registered * before, the request will be ignored. @@ -834,6 +860,19 @@ } } + /** + * Unregisters for modem state changed from satellite modem. If callback was not registered + * before, the request will be ignored. + */ + public void unregisterForModemStateChanged( + @NonNull SatelliteModemStateCallbackWrapper2 callback) { + SatelliteModemStateCallback internalCallback = sSatelliteModemStateCallbackWrapperMap2.get( + callback); + if (internalCallback != null) { + mSatelliteManager.unregisterForModemStateChanged(internalCallback); + } + } + /** Register to receive incoming datagrams over satellite. */ @SatelliteResult public int registerForIncomingDatagram( @@ -874,21 +913,34 @@ implements TelephonyCallback.CarrierRoamingNtnModeListener { private CarrierRoamingNtnModeListenerWrapper mListenerWrapper; + private CarrierRoamingNtnModeListenerWrapper2 mListenerWrapper2; public CarrierRoamingNtnModeListener(CarrierRoamingNtnModeListenerWrapper listenerWrapper) { mListenerWrapper = listenerWrapper; + mListenerWrapper2 = null; + } + + public CarrierRoamingNtnModeListener(CarrierRoamingNtnModeListenerWrapper2 listenerWrapper) { + mListenerWrapper = null; + mListenerWrapper2 = listenerWrapper; } @Override public void onCarrierRoamingNtnModeChanged(boolean active) { logd("onCarrierRoamingNtnModeChanged: active=" + active); - mListenerWrapper.onCarrierRoamingNtnModeChanged(active); + if (mListenerWrapper2 != null) { + mListenerWrapper2.onCarrierRoamingNtnModeChanged(active); + } else if (mListenerWrapper != null) { + mListenerWrapper.onCarrierRoamingNtnModeChanged(active); + } } @Override public void onCarrierRoamingNtnEligibleStateChanged(boolean eligible) { logd("onCarrierRoamingNtnEligibleStateChanged: eligible=" + eligible); - mListenerWrapper.onCarrierRoamingNtnEligibleStateChanged(eligible); + if (mListenerWrapper2 != null) { + mListenerWrapper2.onCarrierRoamingNtnEligibleStateChanged(eligible); + } } } @@ -904,6 +956,17 @@ tm.registerTelephonyCallback(executor, internalListener); } + public void registerForCarrierRoamingNtnModeChanged(int subId, + @NonNull @CallbackExecutor Executor executor, + @NonNull CarrierRoamingNtnModeListenerWrapper2 listener) { + logd("registerForCarrierRoamingNtnModeChanged: subId=" + subId); + CarrierRoamingNtnModeListener internalListener = new CarrierRoamingNtnModeListener(listener); + sCarrierRoamingNtnModeListenerWrapperMap2.put(listener, internalListener); + + TelephonyManager tm = mTelephonyManager.createForSubscriptionId(subId); + tm.registerTelephonyCallback(executor, internalListener); + } + /** Unregister for carrier roaming non-terrestrial network mode changes. */ public void unregisterForCarrierRoamingNtnModeChanged(int subId, @NonNull CarrierRoamingNtnModeListenerWrapper listener) { @@ -916,6 +979,18 @@ } } + /** Unregister for carrier roaming non-terrestrial network mode changes. */ + public void unregisterForCarrierRoamingNtnModeChanged(int subId, + @NonNull CarrierRoamingNtnModeListenerWrapper2 listener) { + logd("unregisterForCarrierRoamingNtnModeChanged: subId=" + subId); + CarrierRoamingNtnModeListener internalListener = + sCarrierRoamingNtnModeListenerWrapperMap.get(listener); + if (internalListener != null) { + TelephonyManager tm = mTelephonyManager.createForSubscriptionId(subId); + tm.unregisterTelephonyCallback(internalListener); + } + } + /** Poll pending satellite datagrams over satellite. */ public void pollPendingDatagrams( @NonNull @CallbackExecutor Executor executor, @@ -1545,7 +1620,7 @@ public boolean isSatelliteSubscriberIdSupported() { try { - final String methodName = "requestSatelliteSubscriberProvisioningStatus"; + final String methodName = "requestSatelliteSubscriberProvisionStatus"; Method method = mSatelliteManager.getClass().getMethod(methodName, Executor.class, OutcomeReceiver.class); return method != null;
diff --git a/satellite_client/src/android/telephony/satellite/wrapper/SatelliteModemStateCallbackWrapper.java b/satellite_client/src/android/telephony/satellite/wrapper/SatelliteModemStateCallbackWrapper.java index f6cb67f..450e48a 100644 --- a/satellite_client/src/android/telephony/satellite/wrapper/SatelliteModemStateCallbackWrapper.java +++ b/satellite_client/src/android/telephony/satellite/wrapper/SatelliteModemStateCallbackWrapper.java
@@ -25,11 +25,4 @@ * @param state The new satellite modem state. */ void onSatelliteModemStateChanged(@SatelliteManagerWrapper.SatelliteModemState int state); - - /** - * Called when the satellite emergency mode has changed. - * - * @param isEmergency {@code true} enabled for emergency mode, {@code false} otherwise. - */ - default void onEmergencyModeChanged(boolean isEmergency) {}; }
diff --git a/satellite_client/src/android/telephony/satellite/wrapper/SatelliteModemStateCallbackWrapper2.java b/satellite_client/src/android/telephony/satellite/wrapper/SatelliteModemStateCallbackWrapper2.java new file mode 100644 index 0000000..b23d3ec --- /dev/null +++ b/satellite_client/src/android/telephony/satellite/wrapper/SatelliteModemStateCallbackWrapper2.java
@@ -0,0 +1,35 @@ + /* + * Copyright (C) 2023 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; + +/** A callback class for monitoring satellite modem state change events. */ +public interface SatelliteModemStateCallbackWrapper2 { + + /** + * Called when satellite modem state changes. + * + * @param state The new satellite modem state. + */ + void onSatelliteModemStateChanged(@SatelliteManagerWrapper.SatelliteModemState int state); + + /** + * Called when the satellite emergency mode has changed. + * + * @param isEmergency {@code true} enabled for emergency mode, {@code false} otherwise. + */ + default void onEmergencyModeChanged(boolean isEmergency) {}; +}