diff options
Diffstat (limited to 'telephony')
19 files changed, 484 insertions, 258 deletions
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java index fa4ec1692b0e..0b3d720bf52a 100644 --- a/telephony/java/android/telephony/CarrierConfigManager.java +++ b/telephony/java/android/telephony/CarrierConfigManager.java @@ -3219,7 +3219,6 @@ public class CarrierConfigManager { * The roaming indicator will be shown if this is {@code true} and will not be shown if this is * {@code false}. */ - @FlaggedApi(Flags.FLAG_HIDE_ROAMING_ICON) public static final String KEY_SHOW_ROAMING_INDICATOR_BOOL = "show_roaming_indicator_bool"; /** @@ -10596,6 +10595,8 @@ public class CarrierConfigManager { * <!-- Handover from 4G to IWLAN is not allowed if the device has capability in either IMS * or EIMS--> * <item value="source=EUTRAN, target=IWLAN, type=disallowed, capabilities=IMS|EIMS"/> + * <!-- Handover from IWLAN to 5G is not allowed if the device is incall. --> + * <item value="source=IWLAN, target=NGRAN, incall=true, type=disallowed"/> * <!-- Handover is always allowed in any condition. --> * <item value="source=GERAN|UTRAN|EUTRAN|NGRAN|IWLAN|UNKNOWN, * target=GERAN|UTRAN|EUTRAN|NGRAN|IWLAN, type=allowed"/> diff --git a/telephony/java/android/telephony/CellularIdentifierDisclosure.java b/telephony/java/android/telephony/CellularIdentifierDisclosure.java index 0b6a70feac9d..92c51ec9e84f 100644 --- a/telephony/java/android/telephony/CellularIdentifierDisclosure.java +++ b/telephony/java/android/telephony/CellularIdentifierDisclosure.java @@ -74,6 +74,14 @@ public final class CellularIdentifierDisclosure implements Parcelable { /** IMEI DETATCH INDICATION. Reference: 3GPP TS 24.008 9.2.14. * Applies to 2g and 3g networks. Used for circuit-switched detach. */ public static final int NAS_PROTOCOL_MESSAGE_IMSI_DETACH_INDICATION = 11; + /** Vendor-specific enumeration to identify a disclosure as potentially benign. + * Enables vendors to semantically classify disclosures based on their own logic. */ + @FlaggedApi(Flags.FLAG_VENDOR_SPECIFIC_CELLULAR_IDENTIFIER_DISCLOSURE_INDICATIONS) + public static final int NAS_PROTOCOL_MESSAGE_THREAT_IDENTIFIER_FALSE = 12; + /** Vendor-specific enumeration to identify a disclosure as potentially harmful. + * Enables vendors to semantically classify disclosures based on their own logic. */ + @FlaggedApi(Flags.FLAG_VENDOR_SPECIFIC_CELLULAR_IDENTIFIER_DISCLOSURE_INDICATIONS) + public static final int NAS_PROTOCOL_MESSAGE_THREAT_IDENTIFIER_TRUE = 13; /** @hide */ @Retention(RetentionPolicy.SOURCE) @@ -84,7 +92,9 @@ public final class CellularIdentifierDisclosure implements Parcelable { NAS_PROTOCOL_MESSAGE_AUTHENTICATION_AND_CIPHERING_RESPONSE, NAS_PROTOCOL_MESSAGE_REGISTRATION_REQUEST, NAS_PROTOCOL_MESSAGE_DEREGISTRATION_REQUEST, NAS_PROTOCOL_MESSAGE_CM_REESTABLISHMENT_REQUEST, - NAS_PROTOCOL_MESSAGE_CM_SERVICE_REQUEST, NAS_PROTOCOL_MESSAGE_IMSI_DETACH_INDICATION}) + NAS_PROTOCOL_MESSAGE_CM_SERVICE_REQUEST, NAS_PROTOCOL_MESSAGE_IMSI_DETACH_INDICATION, + NAS_PROTOCOL_MESSAGE_THREAT_IDENTIFIER_FALSE, + NAS_PROTOCOL_MESSAGE_THREAT_IDENTIFIER_TRUE}) public @interface NasProtocolMessage { } @@ -156,6 +166,14 @@ public final class CellularIdentifierDisclosure implements Parcelable { return mIsEmergency; } + /** + * @return if the modem vendor classifies the disclosure as benign. + */ + @FlaggedApi(Flags.FLAG_VENDOR_SPECIFIC_CELLULAR_IDENTIFIER_DISCLOSURE_INDICATIONS) + public boolean isBenign() { + return mNasProtocolMessage == NAS_PROTOCOL_MESSAGE_THREAT_IDENTIFIER_FALSE; + } + @Override public int describeContents() { return 0; diff --git a/telephony/java/android/telephony/PreciseDisconnectCause.java b/telephony/java/android/telephony/PreciseDisconnectCause.java index 2d650ab20802..bb9e7065b154 100644 --- a/telephony/java/android/telephony/PreciseDisconnectCause.java +++ b/telephony/java/android/telephony/PreciseDisconnectCause.java @@ -326,6 +326,13 @@ public final class PreciseDisconnectCause { @Deprecated public static final int CDMA_ACCESS_BLOCKED = 1009; + /** Call was disconnected with cause code retry over volte. */ + @FlaggedApi(Flags.FLAG_ADD_IMS_REDIAL_CODES_FOR_EMERGENCY_CALLS) + public static final int EMERGENCY_REDIAL_ON_IMS = 3001; + /** Call was disconnected with cause code retry over vowifi. */ + @FlaggedApi(Flags.FLAG_ADD_IMS_REDIAL_CODES_FOR_EMERGENCY_CALLS) + public static final int EMERGENCY_REDIAL_ON_VOWIFI = 3002; + /* OEM specific error codes. To be used by OEMs when they don't want to reveal error code which would be replaced by ERROR_UNSPECIFIED */ public static final int OEM_CAUSE_1 = 0xf001; diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 24fb8c5da2d7..504605d0a1a2 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -180,7 +180,7 @@ import java.util.stream.IntStream; * permission-protected. Your application cannot access the protected * information unless it has the appropriate permissions declared in * its manifest file. Where permissions apply, they are noted in the - * the methods through which you access the protected information. + * methods through which you access the protected information. * * <p>TelephonyManager is intended for use on devices that implement * {@link android.content.pm.PackageManager#FEATURE_TELEPHONY FEATURE_TELEPHONY}. On devices @@ -633,11 +633,14 @@ public class TelephonyManager { } /** - * Returns the multi SIM variant - * Returns DSDS for Dual SIM Dual Standby - * Returns DSDA for Dual SIM Dual Active - * Returns TSTS for Triple SIM Triple Standby - * Returns UNKNOWN for others + * Returns the multi SIM variant. + * + * <ul> + * <li>Returns DSDS for Dual SIM Dual Standby.</li> + * <li>Returns DSDA for Dual SIM Dual Active.</li> + * <li>Returns TSTS for Triple SIM Triple Standby.</li> + * <li>Returns UNKNOWN for others.</li> + * </ul> */ /** {@hide} */ @UnsupportedAppUsage @@ -657,10 +660,14 @@ public class TelephonyManager { /** * Returns the number of phones available. - * Returns 0 if none of voice, sms, data is not supported - * Returns 1 for Single standby mode (Single SIM functionality). - * Returns 2 for Dual standby mode (Dual SIM functionality). - * Returns 3 for Tri standby mode (Tri SIM functionality). + * + * <ul> + * <li>Returns 0 if none of voice, sms, data is supported.</li> + * <li>Returns 1 for Single standby mode (Single SIM functionality).</li> + * <li>Returns 2 for Dual standby mode (Dual SIM functionality).</li> + * <li>Returns 3 for Tri standby mode (Tri SIM functionality).</li> + * </ul> + * * @deprecated Use {@link #getActiveModemCount} instead. */ @Deprecated @@ -671,10 +678,12 @@ public class TelephonyManager { /** * Returns the number of logical modems currently configured to be activated. * - * Returns 0 if none of voice, sms, data is not supported - * Returns 1 for Single standby mode (Single SIM functionality). - * Returns 2 for Dual standby mode (Dual SIM functionality). - * Returns 3 for Tri standby mode (Tri SIM functionality). + * <ul> + * <li>Returns 0 if none of voice, sms, data is supported.</li> + * <li>Returns 1 for Single standby mode (Single SIM functionality).</li> + * <li>Returns 2 for Dual standby mode (Dual SIM functionality).</li> + * <li>Returns 3 for Tri standby mode (Tri SIM functionality).</li> + * </ul> */ public int getActiveModemCount() { int modemCount = 1; @@ -2438,6 +2447,7 @@ public class TelephonyManager { * as follows: * * <ul> + * <li>If the device is running Android 25Q2 or later, then null is returned.</li> * <li>If the calling app's target SDK is API level 28 or lower and the app has the * READ_PHONE_STATE permission then null is returned.</li> * <li>If the calling app's target SDK is API level 28 or lower and the app does not have @@ -2446,7 +2456,8 @@ public class TelephonyManager { * </ul> * * @deprecated Legacy CDMA is unsupported. - * @throws UnsupportedOperationException If the device does not have + * @throws UnsupportedOperationException If the device is running + * Android 25Q1 or earlier and does not have * {@link PackageManager#FEATURE_TELEPHONY_CDMA}. */ @FlaggedApi(Flags.FLAG_DEPRECATE_CDMA) @@ -19369,7 +19380,6 @@ public class TelephonyManager { * * @hide */ - @FlaggedApi(Flags.FLAG_ENABLE_IDENTIFIER_DISCLOSURE_TRANSPARENCY) @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) @SystemApi public void setEnableCellularIdentifierDisclosureNotifications(boolean enable) { @@ -19395,7 +19405,6 @@ public class TelephonyManager { * * @hide */ - @FlaggedApi(Flags.FLAG_ENABLE_IDENTIFIER_DISCLOSURE_TRANSPARENCY) @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) @SystemApi public boolean isCellularIdentifierDisclosureNotificationsEnabled() { @@ -19423,7 +19432,6 @@ public class TelephonyManager { * and integrity algorithms in use * @hide */ - @FlaggedApi(Flags.FLAG_ENABLE_MODEM_CIPHER_TRANSPARENCY) @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) @SystemApi public void setNullCipherNotificationsEnabled(boolean enable) { @@ -19450,7 +19458,6 @@ public class TelephonyManager { * and integrity algorithms in use * @hide */ - @FlaggedApi(Flags.FLAG_ENABLE_MODEM_CIPHER_TRANSPARENCY) @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) @SystemApi public boolean isNullCipherNotificationsEnabled() { diff --git a/telephony/java/android/telephony/data/ApnSetting.java b/telephony/java/android/telephony/data/ApnSetting.java index 567314beadd3..5daa29b940bf 100644 --- a/telephony/java/android/telephony/data/ApnSetting.java +++ b/telephony/java/android/telephony/data/ApnSetting.java @@ -130,10 +130,10 @@ public class ApnSetting implements Parcelable { public static final int TYPE_RCS = ApnTypes.RCS; /** APN type for OEM_PAID networks (Automotive PANS) */ @FlaggedApi(Flags.FLAG_OEM_PAID_PRIVATE) - public static final int TYPE_OEM_PAID = 1 << 16; // TODO(b/366194627): ApnTypes.OEM_PAID; + public static final int TYPE_OEM_PAID = ApnTypes.OEM_PAID; /** APN type for OEM_PRIVATE networks (Automotive PANS) */ @FlaggedApi(Flags.FLAG_OEM_PAID_PRIVATE) - public static final int TYPE_OEM_PRIVATE = 1 << 17; // TODO(b/366194627): ApnTypes.OEM_PRIVATE; + public static final int TYPE_OEM_PRIVATE = ApnTypes.OEM_PRIVATE; /** @hide */ @IntDef(flag = true, prefix = {"TYPE_"}, value = { diff --git a/telephony/java/android/telephony/satellite/ISatelliteCommunicationAllowedStateCallback.aidl b/telephony/java/android/telephony/satellite/ISatelliteCommunicationAccessStateCallback.aidl index 2730f90c4e5e..a3c66a03fd7f 100644 --- a/telephony/java/android/telephony/satellite/ISatelliteCommunicationAllowedStateCallback.aidl +++ b/telephony/java/android/telephony/satellite/ISatelliteCommunicationAccessStateCallback.aidl @@ -19,18 +19,18 @@ package android.telephony.satellite; import android.telephony.satellite.SatelliteAccessConfiguration; /** - * Interface for satellite communication allowed state callback. + * Interface for satellite communication access state callback. * @hide */ -oneway interface ISatelliteCommunicationAllowedStateCallback { +oneway interface ISatelliteCommunicationAccessStateCallback { /** * Telephony does not guarantee that whenever there is a change in communication allowed * state, this API will be called. Telephony does its best to detect the changes and notify - * its listners accordingly. + * its listeners accordingly. * * @param allowed whether satellite communication state or not */ - void onSatelliteCommunicationAllowedStateChanged(in boolean isAllowed); + void onAccessAllowedStateChanged(in boolean isAllowed); /** * Callback method invoked when the satellite access configuration changes @@ -39,6 +39,6 @@ oneway interface ISatelliteCommunicationAllowedStateCallback { * When satellite is not allowed at the current location, * {@code satelliteRegionalConfiguration} will be null. */ - void onSatelliteAccessConfigurationChanged(in SatelliteAccessConfiguration + void onAccessConfigurationChanged(in SatelliteAccessConfiguration satelliteAccessConfiguration); } diff --git a/telephony/java/android/telephony/satellite/ISatelliteSupportedStateCallback.aidl b/telephony/java/android/telephony/satellite/ISatelliteSupportedStateCallback.aidl deleted file mode 100644 index 04550906324b..000000000000 --- a/telephony/java/android/telephony/satellite/ISatelliteSupportedStateCallback.aidl +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 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; - -/** - * Interface for satellite supported state change callback. - * @hide - */ -oneway interface ISatelliteSupportedStateCallback { - /** - * Called when satellite supported state has changed. - * - * @param supoprted Whether satellite is supported or not. - */ - void onSatelliteSupportedStateChanged(in boolean supported); -} - diff --git a/telephony/java/android/telephony/satellite/SatelliteCommunicationAllowedStateCallback.java b/telephony/java/android/telephony/satellite/SatelliteCommunicationAccessStateCallback.java index 6291102cd6e3..7fb8a968a6e3 100644 --- a/telephony/java/android/telephony/satellite/SatelliteCommunicationAllowedStateCallback.java +++ b/telephony/java/android/telephony/satellite/SatelliteCommunicationAccessStateCallback.java @@ -25,24 +25,24 @@ import com.android.internal.telephony.flags.Flags; /** - * A callback class for monitoring satellite communication allowed state changed events. + * A callback class for monitoring satellite communication access state changed events. * * @hide */ @SystemApi @FlaggedApi(Flags.FLAG_SATELLITE_SYSTEM_APIS) -public interface SatelliteCommunicationAllowedStateCallback { +public interface SatelliteCommunicationAccessStateCallback { /** * Telephony does not guarantee that whenever there is a change in communication allowed state, * this API will be called. Telephony does its best to detect the changes and notify its - * listeners accordingly. Satellite communication is allowed at a location when it is legally - * allowed by the local authority and satellite signal coverage is available. + * listeners accordingly. Satellite communication access is allowed at a location when it is + * legally allowed by the local authority and satellite signal coverage is available. * * @param isAllowed {@code true} means satellite is allowed, * {@code false} satellite is not allowed. */ - void onSatelliteCommunicationAllowedStateChanged(boolean isAllowed); + void onAccessAllowedStateChanged(boolean isAllowed); /** * Callback method invoked when the satellite access configuration changes @@ -52,6 +52,6 @@ public interface SatelliteCommunicationAllowedStateCallback { * the current location, * {@code satelliteRegionalConfiguration} will be null. */ - default void onSatelliteAccessConfigurationChanged( + default void onAccessConfigurationChanged( @Nullable SatelliteAccessConfiguration satelliteAccessConfiguration) {}; } diff --git a/telephony/java/android/telephony/satellite/SatelliteManager.java b/telephony/java/android/telephony/satellite/SatelliteManager.java index cf807a295a2d..b7b209b78300 100644 --- a/telephony/java/android/telephony/satellite/SatelliteManager.java +++ b/telephony/java/android/telephony/satellite/SatelliteManager.java @@ -43,6 +43,7 @@ import android.telephony.TelephonyFrameworkInitializer; import android.telephony.TelephonyManager; import android.telephony.TelephonyRegistryManager; +import com.android.internal.telephony.IBooleanConsumer; import com.android.internal.telephony.IIntegerConsumer; import com.android.internal.telephony.ITelephony; import com.android.internal.telephony.IVoidConsumer; @@ -96,12 +97,12 @@ public final class SatelliteManager { private static final ConcurrentHashMap<SatelliteCapabilitiesCallback, ISatelliteCapabilitiesCallback> sSatelliteCapabilitiesCallbackMap = new ConcurrentHashMap<>(); - private static final ConcurrentHashMap<SatelliteSupportedStateCallback, - ISatelliteSupportedStateCallback> sSatelliteSupportedStateCallbackMap = + private static final ConcurrentHashMap<Consumer<Boolean>, + IBooleanConsumer> sSatelliteSupportedStateCallbackMap = new ConcurrentHashMap<>(); - private static final ConcurrentHashMap<SatelliteCommunicationAllowedStateCallback, - ISatelliteCommunicationAllowedStateCallback> - sSatelliteCommunicationAllowedStateCallbackMap = + private static final ConcurrentHashMap<SatelliteCommunicationAccessStateCallback, + ISatelliteCommunicationAccessStateCallback> + sSatelliteCommunicationAccessStateCallbackMap = new ConcurrentHashMap<>(); private static final ConcurrentHashMap<SatelliteDisallowedReasonsCallback, ISatelliteDisallowedReasonsCallback> @@ -781,6 +782,28 @@ public final class SatelliteManager { @FlaggedApi(Flags.FLAG_SATELLITE_SYSTEM_APIS) public static final String ACTION_SATELLITE_START_NON_EMERGENCY_SESSION = "android.telephony.satellite.action.SATELLITE_START_NON_EMERGENCY_SESSION"; + + /** + * Application level {@link android.content.pm.PackageManager.Property} tag that represents + * whether the application supports P2P SMS over carrier roaming satellite which needs manual + * trigger to connect to satellite. The messaging applications that supports P2P SMS over + * carrier roaming satellite should set value of this property to {@code true}. + * + * <p><b>Syntax:</b> + * <pre> + * <application> + * <property + * android:name="android.telephony.satellite.PROPERTY_SATELLITE_MANUAL_CONNECT_P2P_SUPPORT" + * android:value="true"/> + * </application> + * </pre> + * @hide + */ + @SystemApi + @FlaggedApi(Flags.FLAG_SATELLITE_SYSTEM_APIS) + public static final String PROPERTY_SATELLITE_MANUAL_CONNECT_P2P_SUPPORT = + "android.telephony.satellite.PROPERTY_SATELLITE_MANUAL_CONNECT_P2P_SUPPORT"; + /** * Meta-data represents whether the application supports P2P SMS over carrier roaming satellite * which needs manual trigger to connect to satellite. The messaging applications that supports @@ -794,8 +817,6 @@ public final class SatelliteManager { * } * @hide */ - @SystemApi - @FlaggedApi(Flags.FLAG_SATELLITE_SYSTEM_APIS) public static final String METADATA_SATELLITE_MANUAL_CONNECT_P2P_SUPPORT = "android.telephony.METADATA_SATELLITE_MANUAL_CONNECT_P2P_SUPPORT"; @@ -3303,7 +3324,7 @@ public final class SatelliteManager { * @param executor The executor on which the callback will be called. * @param callback The callback to handle the satellite supoprted state changed event. * - * @return The {@link SatelliteResult} result of the operation. + * @return The result of the operation. * * @throws SecurityException if the caller doesn't have required permission. * @throws IllegalStateException if the Telephony process is not currently available. @@ -3313,23 +3334,20 @@ public final class SatelliteManager { @FlaggedApi(Flags.FLAG_SATELLITE_SYSTEM_APIS) @RequiresPermission(Manifest.permission.SATELLITE_COMMUNICATION) @SatelliteResult public int registerForSupportedStateChanged( - @NonNull @CallbackExecutor Executor executor, - @NonNull SatelliteSupportedStateCallback callback) { + @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<Boolean> callback) { Objects.requireNonNull(executor); Objects.requireNonNull(callback); try { ITelephony telephony = getITelephony(); if (telephony != null) { - ISatelliteSupportedStateCallback internalCallback = - new ISatelliteSupportedStateCallback.Stub() { - @Override - public void onSatelliteSupportedStateChanged(boolean supported) { - executor.execute(() -> Binder.withCleanCallingIdentity( - () -> callback.onSatelliteSupportedStateChanged( - supported))); - } - }; + IBooleanConsumer internalCallback = new IBooleanConsumer.Stub() { + @Override + public void accept(boolean supported) { + executor.execute(() -> Binder.withCleanCallingIdentity( + () -> callback.accept(supported))); + } + }; sSatelliteSupportedStateCallbackMap.put(callback, internalCallback); return telephony.registerForSatelliteSupportedStateChanged( internalCallback); @@ -3348,7 +3366,7 @@ public final class SatelliteManager { * If callback was not registered before, the request will be ignored. * * @param callback The callback that was passed to - * {@link #registerForSupportedStateChanged(Executor, SatelliteSupportedStateCallback)} + * {@link #registerForSupportedStateChanged(Executor, Consumer)} * * @throws SecurityException if the caller doesn't have required permission. * @throws IllegalStateException if the Telephony process is not currently available. @@ -3357,10 +3375,9 @@ public final class SatelliteManager { @SystemApi @RequiresPermission(Manifest.permission.SATELLITE_COMMUNICATION) @FlaggedApi(Flags.FLAG_SATELLITE_SYSTEM_APIS) - public void unregisterForSupportedStateChanged( - @NonNull SatelliteSupportedStateCallback callback) { + public void unregisterForSupportedStateChanged(@NonNull Consumer<Boolean> callback) { Objects.requireNonNull(callback); - ISatelliteSupportedStateCallback internalCallback = + IBooleanConsumer internalCallback = sSatelliteSupportedStateCallbackMap.remove(callback); try { @@ -3381,10 +3398,10 @@ public final class SatelliteManager { } /** - * Registers for the satellite communication allowed state changed. + * Registers for the satellite communication access state changed event. * * @param executor The executor on which the callback will be called. - * @param callback The callback to handle satellite communication allowed state changed event. + * @param callback The callback to handle satellite communication access state changed event. * @return The {@link SatelliteResult} result of the operation. * @throws SecurityException if the caller doesn't have required permission. * @throws IllegalStateException if the Telephony process is not currently available. @@ -3394,54 +3411,54 @@ public final class SatelliteManager { @FlaggedApi(Flags.FLAG_SATELLITE_SYSTEM_APIS) @RequiresPermission(Manifest.permission.SATELLITE_COMMUNICATION) @SatelliteResult - public int registerForCommunicationAllowedStateChanged( + public int registerForCommunicationAccessStateChanged( @NonNull @CallbackExecutor Executor executor, - @NonNull SatelliteCommunicationAllowedStateCallback callback) { + @NonNull SatelliteCommunicationAccessStateCallback callback) { Objects.requireNonNull(executor); Objects.requireNonNull(callback); try { ITelephony telephony = getITelephony(); if (telephony != null) { - ISatelliteCommunicationAllowedStateCallback internalCallback = - new ISatelliteCommunicationAllowedStateCallback.Stub() { + ISatelliteCommunicationAccessStateCallback internalCallback = + new ISatelliteCommunicationAccessStateCallback.Stub() { @Override - public void onSatelliteCommunicationAllowedStateChanged( + public void onAccessAllowedStateChanged( boolean isAllowed) { executor.execute(() -> Binder.withCleanCallingIdentity( - () -> callback.onSatelliteCommunicationAllowedStateChanged( + () -> callback.onAccessAllowedStateChanged( isAllowed))); } @Override - public void onSatelliteAccessConfigurationChanged( + public void onAccessConfigurationChanged( @Nullable SatelliteAccessConfiguration satelliteAccessConfiguration) { executor.execute(() -> Binder.withCleanCallingIdentity( - () -> callback.onSatelliteAccessConfigurationChanged( + () -> callback.onAccessConfigurationChanged( satelliteAccessConfiguration))); } }; - sSatelliteCommunicationAllowedStateCallbackMap.put(callback, internalCallback); - return telephony.registerForCommunicationAllowedStateChanged( + sSatelliteCommunicationAccessStateCallbackMap.put(callback, internalCallback); + return telephony.registerForCommunicationAccessStateChanged( mSubId, internalCallback); } else { throw new IllegalStateException("telephony service is null."); } } catch (RemoteException ex) { - loge("registerForCommunicationAllowedStateChanged() RemoteException: " + ex); + loge("registerForCommunicationAccessStateChanged() RemoteException: " + ex); ex.rethrowAsRuntimeException(); } return SATELLITE_RESULT_REQUEST_FAILED; } /** - * Unregisters for the satellite communication allowed state changed. + * Unregisters for the satellite communication access state changed event. * If callback was not registered before, the request will be ignored. * * @param callback The callback that was passed to - * {@link #registerForCommunicationAllowedStateChanged(Executor, - * SatelliteCommunicationAllowedStateCallback)} + * {@link #registerForCommunicationAccessStateChanged(Executor, + * SatelliteCommunicationAccessStateCallback)} * @throws SecurityException if the caller doesn't have required permission. * @throws IllegalStateException if the Telephony process is not currently available. * @hide @@ -3449,26 +3466,26 @@ public final class SatelliteManager { @SystemApi @RequiresPermission(Manifest.permission.SATELLITE_COMMUNICATION) @FlaggedApi(Flags.FLAG_SATELLITE_SYSTEM_APIS) - public void unregisterForCommunicationAllowedStateChanged( - @NonNull SatelliteCommunicationAllowedStateCallback callback) { + public void unregisterForCommunicationAccessStateChanged( + @NonNull SatelliteCommunicationAccessStateCallback callback) { Objects.requireNonNull(callback); - ISatelliteCommunicationAllowedStateCallback internalCallback = - sSatelliteCommunicationAllowedStateCallbackMap.remove(callback); + ISatelliteCommunicationAccessStateCallback internalCallback = + sSatelliteCommunicationAccessStateCallbackMap.remove(callback); try { ITelephony telephony = getITelephony(); if (telephony != null) { if (internalCallback != null) { - telephony.unregisterForCommunicationAllowedStateChanged(mSubId, + telephony.unregisterForCommunicationAccessStateChanged(mSubId, internalCallback); } else { - loge("unregisterForCommunicationAllowedStateChanged: No internal callback."); + loge("unregisterForCommunicationAccessStateChanged: No internal callback."); } } else { throw new IllegalStateException("telephony service is null."); } } catch (RemoteException ex) { - loge("unregisterForCommunicationAllowedStateChanged() RemoteException: " + ex); + loge("unregisterForCommunicationAccessStateChanged() RemoteException: " + ex); ex.rethrowAsRuntimeException(); } } @@ -3673,6 +3690,11 @@ public final class SatelliteManager { * @param list The list of provisioned satellite subscriber infos. * @param executor The executor on which the callback will be called. * @param callback The callback object to which the result will be delivered. + * If the request is successful, {@link OutcomeReceiver#onResult} + * will be called. + * If the request is not successful, + * {@link OutcomeReceiver#onError(Throwable)} will return an error with + * a SatelliteException. * * @throws SecurityException if the caller doesn't have required permission. * @hide @@ -3682,7 +3704,7 @@ public final class SatelliteManager { @FlaggedApi(Flags.FLAG_SATELLITE_SYSTEM_APIS) public void provisionSatellite(@NonNull List<SatelliteSubscriberInfo> list, @NonNull @CallbackExecutor Executor executor, - @NonNull OutcomeReceiver<Boolean, SatelliteException> callback) { + @NonNull OutcomeReceiver<Void, SatelliteException> callback) { Objects.requireNonNull(executor); Objects.requireNonNull(callback); @@ -3696,8 +3718,8 @@ public final class SatelliteManager { if (resultData.containsKey(KEY_PROVISION_SATELLITE_TOKENS)) { boolean isUpdated = resultData.getBoolean(KEY_PROVISION_SATELLITE_TOKENS); - executor.execute(() -> Binder.withCleanCallingIdentity(() -> - callback.onResult(isUpdated))); + executor.execute(() -> Binder.withCleanCallingIdentity( + () -> callback.onResult(null))); } else { loge("KEY_REQUEST_PROVISION_TOKENS does not exist."); executor.execute(() -> Binder.withCleanCallingIdentity(() -> @@ -3729,6 +3751,11 @@ public final class SatelliteManager { * @param list The list of deprovisioned satellite subscriber infos. * @param executor The executor on which the callback will be called. * @param callback The callback object to which the result will be delivered. + * If the request is successful, {@link OutcomeReceiver#onResult} + * will be called. + * If the request is not successful, + * {@link OutcomeReceiver#onError(Throwable)} will return an error with + * a SatelliteException. * * @throws SecurityException if the caller doesn't have required permission. * @hide @@ -3738,7 +3765,7 @@ public final class SatelliteManager { @FlaggedApi(Flags.FLAG_SATELLITE_SYSTEM_APIS) public void deprovisionSatellite(@NonNull List<SatelliteSubscriberInfo> list, @NonNull @CallbackExecutor Executor executor, - @NonNull OutcomeReceiver<Boolean, SatelliteException> callback) { + @NonNull OutcomeReceiver<Void, SatelliteException> callback) { Objects.requireNonNull(executor); Objects.requireNonNull(callback); @@ -3753,7 +3780,7 @@ public final class SatelliteManager { boolean isUpdated = resultData.getBoolean(KEY_DEPROVISION_SATELLITE_TOKENS); executor.execute(() -> Binder.withCleanCallingIdentity(() -> - callback.onResult(isUpdated))); + callback.onResult(null))); } else { loge("KEY_DEPROVISION_SATELLITE_TOKENS does not exist."); executor.execute(() -> Binder.withCleanCallingIdentity(() -> diff --git a/telephony/java/android/telephony/satellite/SatelliteModemEnableRequestAttributes.java b/telephony/java/android/telephony/satellite/SatelliteModemEnableRequestAttributes.java index d7fa3c9265e0..8fd05fc4d94a 100644 --- a/telephony/java/android/telephony/satellite/SatelliteModemEnableRequestAttributes.java +++ b/telephony/java/android/telephony/satellite/SatelliteModemEnableRequestAttributes.java @@ -29,7 +29,8 @@ import java.util.Objects; /** * SatelliteModemEnableRequestAttributes is used to pack info needed by modem to allow carrier to * roam to satellite. - * + * These attributes will be used by modem to decide how they should act, + * decide how to attach to the network and whether to enable or disable satellite mode. * @hide */ @SystemApi @@ -42,32 +43,38 @@ public final class SatelliteModemEnableRequestAttributes implements Parcelable { * {@code true} to enable demo mode and {@code false} to disable. When disabling satellite, * {@code mIsDemoMode} is always considered as {@code false} by Telephony. */ - private final boolean mIsDemoMode; + private final boolean mIsForDemoMode; /** * {@code true} means satellite is enabled for emergency mode, {@code false} otherwise. When * disabling satellite, {@code isEmergencyMode} is always considered as {@code false} by * Telephony. */ - private final boolean mIsEmergencyMode; + private final boolean mIsForEmergencyMode; /** The subscription related info */ @NonNull private final SatelliteSubscriptionInfo mSatelliteSubscriptionInfo; /** - * @hide + * Constructor for SatelliteModemEnableRequestAttributes objects. + * @param isEnabled {@code true} to enable satellite and {@code false} to disable satellite + * @param isForDemoMode {@code true} to enable demo mode and {@code false} to disable. + * @param isForEmergencyMode {@code true} means satellite is enabled for emergency mode, + * {@code false} otherwise. + * @param satelliteSubscriptionInfo satellite subscription related info. */ - public SatelliteModemEnableRequestAttributes(boolean isEnabled, boolean isDemoMode, - boolean isEmergencyMode, @NonNull SatelliteSubscriptionInfo satelliteSubscriptionInfo) { + public SatelliteModemEnableRequestAttributes(boolean isEnabled, boolean isForDemoMode, + boolean isForEmergencyMode, + @NonNull SatelliteSubscriptionInfo satelliteSubscriptionInfo) { mIsEnabled = isEnabled; - mIsDemoMode = isDemoMode; - mIsEmergencyMode = isEmergencyMode; + mIsForDemoMode = isForDemoMode; + mIsForEmergencyMode = isForEmergencyMode; mSatelliteSubscriptionInfo = satelliteSubscriptionInfo; } private SatelliteModemEnableRequestAttributes(Parcel in) { mIsEnabled = in.readBoolean(); - mIsDemoMode = in.readBoolean(); - mIsEmergencyMode = in.readBoolean(); + mIsForDemoMode = in.readBoolean(); + mIsForEmergencyMode = in.readBoolean(); mSatelliteSubscriptionInfo = in.readParcelable( SatelliteSubscriptionInfo.class.getClassLoader(), SatelliteSubscriptionInfo.class); } @@ -80,8 +87,8 @@ public final class SatelliteModemEnableRequestAttributes implements Parcelable { @Override public void writeToParcel(@NonNull Parcel dest, int flags) { dest.writeBoolean(mIsEnabled); - dest.writeBoolean(mIsDemoMode); - dest.writeBoolean(mIsEmergencyMode); + dest.writeBoolean(mIsForDemoMode); + dest.writeBoolean(mIsForEmergencyMode); mSatelliteSubscriptionInfo.writeToParcel(dest, flags); } @@ -102,8 +109,8 @@ public final class SatelliteModemEnableRequestAttributes implements Parcelable { public String toString() { return (new StringBuilder()).append("SatelliteModemEnableRequestAttributes{") .append(", mIsEnabled=").append(mIsEnabled) - .append(", mIsDemoMode=").append(mIsDemoMode) - .append(", mIsDemoMode=").append(mIsDemoMode) + .append(", mIsForDemoMode=").append(mIsForDemoMode) + .append(", mIsForEmergencyMode=").append(mIsForEmergencyMode) .append("mSatelliteSubscriptionInfo=").append(mSatelliteSubscriptionInfo) .append("}") .toString(); @@ -114,14 +121,15 @@ public final class SatelliteModemEnableRequestAttributes implements Parcelable { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SatelliteModemEnableRequestAttributes that = (SatelliteModemEnableRequestAttributes) o; - return mIsEnabled == that.mIsEnabled && mIsDemoMode == that.mIsDemoMode - && mIsEmergencyMode == that.mIsEmergencyMode && mSatelliteSubscriptionInfo.equals( - that.mSatelliteSubscriptionInfo); + return mIsEnabled == that.mIsEnabled && mIsForDemoMode == that.mIsForDemoMode + && mIsForEmergencyMode == that.mIsForEmergencyMode + && mSatelliteSubscriptionInfo.equals(that.mSatelliteSubscriptionInfo); } @Override public int hashCode() { - return Objects.hash(mIsEnabled, mIsDemoMode, mIsEmergencyMode, mSatelliteSubscriptionInfo); + return Objects.hash(mIsEnabled, mIsForDemoMode, mIsForEmergencyMode, + mSatelliteSubscriptionInfo); } @@ -138,8 +146,8 @@ public final class SatelliteModemEnableRequestAttributes implements Parcelable { * Get whether satellite modem is enabled for demo mode. * @return {@code true} if the request is to enable demo mode, else {@code false}. */ - public boolean isDemoMode() { - return mIsDemoMode; + public boolean isForDemoMode() { + return mIsForDemoMode; } /** @@ -147,8 +155,8 @@ public final class SatelliteModemEnableRequestAttributes implements Parcelable { * @return {@code true} if the request is to enable satellite for emergency mode, * else {@code false}. */ - public boolean isEmergencyMode() { - return mIsEmergencyMode; + public boolean isForEmergencyMode() { + return mIsForEmergencyMode; } diff --git a/telephony/java/android/telephony/satellite/SatellitePosition.java b/telephony/java/android/telephony/satellite/SatellitePosition.java index b8d138fe5c17..354b729f3854 100644 --- a/telephony/java/android/telephony/satellite/SatellitePosition.java +++ b/telephony/java/android/telephony/satellite/SatellitePosition.java @@ -16,6 +16,7 @@ package android.telephony.satellite; import android.annotation.FlaggedApi; +import android.annotation.FloatRange; import android.annotation.SystemApi; import android.os.Parcel; import android.os.Parcelable; @@ -32,6 +33,7 @@ import java.util.Objects; * Longitude is the angular distance, measured in degrees, east or west of the prime longitude line * ranging from -180 to 180 degrees * Altitude is the distance from the center of the Earth to the satellite, measured in kilometers + * Latitude is not added as only geo stationary satellite are handled for now. * * @hide */ @@ -65,9 +67,9 @@ public final class SatellitePosition implements Parcelable { * * @param longitudeDegree The longitude of the satellite in degrees. * @param altitudeKm The altitude of the satellite in kilometers. - * @hide */ - public SatellitePosition(double longitudeDegree, double altitudeKm) { + public SatellitePosition(@FloatRange(from = -180, to = 180) double longitudeDegree, + @FloatRange(from = 0.0) double altitudeKm) { mLongitudeDegree = longitudeDegree; mAltitudeKm = altitudeKm; } @@ -106,6 +108,7 @@ public final class SatellitePosition implements Parcelable { * * @return The longitude of the satellite. */ + @FloatRange(from = -180, to = 180) public double getLongitudeDegrees() { return mLongitudeDegree; } @@ -115,6 +118,7 @@ public final class SatellitePosition implements Parcelable { * * @return The altitude of the satellite. */ + @FloatRange(from = 0.0) public double getAltitudeKm() { return mAltitudeKm; } diff --git a/telephony/java/android/telephony/satellite/SatelliteSessionStats.java b/telephony/java/android/telephony/satellite/SatelliteSessionStats.java index 556ec1aa2246..402ac732a01d 100644 --- a/telephony/java/android/telephony/satellite/SatelliteSessionStats.java +++ b/telephony/java/android/telephony/satellite/SatelliteSessionStats.java @@ -252,6 +252,13 @@ public final class SatelliteSessionStats implements Parcelable { } } + public void resetCountOfUserMessagesInQueueToBeSent() { + for (Map.Entry<Integer, SatelliteSessionStats> entry : datagramStats.entrySet()) { + SatelliteSessionStats statsPerDatagramType = entry.getValue(); + statsPerDatagramType.mCountOfUserMessagesInQueueToBeSent = 0; + } + } + public int getCountOfSuccessfulOutgoingDatagram( @SatelliteManager.DatagramType int datagramType) { SatelliteSessionStats data = datagramStats.getOrDefault(datagramType, diff --git a/telephony/java/android/telephony/satellite/SatelliteSubscriberInfo.java b/telephony/java/android/telephony/satellite/SatelliteSubscriberInfo.java index 8427057fcaab..d62fd63aeda6 100644 --- a/telephony/java/android/telephony/satellite/SatelliteSubscriberInfo.java +++ b/telephony/java/android/telephony/satellite/SatelliteSubscriberInfo.java @@ -22,16 +22,16 @@ import android.annotation.NonNull; import android.annotation.SystemApi; import android.os.Parcel; import android.os.Parcelable; +import android.telephony.Rlog; import com.android.internal.telephony.flags.Flags; +import com.android.internal.telephony.util.TelephonyUtils; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.Objects; /** - * SatelliteSubscriberInfo - * * Satellite Gateway client will use these subscriber ids to register with satellite gateway service * which identify user subscription with unique subscriber ids. These subscriber ids can be any * unique value like iccid, imsi or msisdn which is decided based upon carrier requirements. @@ -49,19 +49,19 @@ public final class SatelliteSubscriberInfo implements Parcelable { /** apn */ private String mNiddApn; - private int mSubId; + private int mSubscriptionId; /** SubscriberId format is the ICCID. */ - public static final int ICCID = 0; + public static final int SUBSCRIBER_ID_TYPE_ICCID = 0; /** SubscriberId format is the 6 digit of IMSI + MSISDN. */ - public static final int IMSI_MSISDN = 1; + public static final int SUBSCRIBER_ID_TYPE_IMSI_MSISDN = 1; /** Type of subscriber id */ @SubscriberIdType private int mSubscriberIdType; /** @hide */ - @IntDef(prefix = "SubscriberId_Type_", value = { - ICCID, - IMSI_MSISDN + @IntDef(prefix = "SUBSCRIBER_ID_TYPE_", value = { + SUBSCRIBER_ID_TYPE_ICCID, + SUBSCRIBER_ID_TYPE_IMSI_MSISDN }) @Retention(RetentionPolicy.SOURCE) public @interface SubscriberIdType {} @@ -77,7 +77,7 @@ public final class SatelliteSubscriberInfo implements Parcelable { this.mSubscriberId = builder.mSubscriberId; this.mCarrierId = builder.mCarrierId; this.mNiddApn = builder.mNiddApn; - this.mSubId = builder.mSubId; + this.mSubscriptionId = builder.mSubscriptionId; this.mSubscriberIdType = builder.mSubscriberIdType; } @@ -89,7 +89,7 @@ public final class SatelliteSubscriberInfo implements Parcelable { private int mCarrierId; @NonNull private String mNiddApn; - private int mSubId; + private int mSubscriptionId; @SubscriberIdType private int mSubscriberIdType; @@ -127,8 +127,8 @@ public final class SatelliteSubscriberInfo implements Parcelable { * Set the subId and returns the Builder class. */ @NonNull - public Builder setSubId(int subId) { - mSubId = subId; + public Builder setSubscriptionId(int subId) { + mSubscriptionId = subId; return this; } @@ -155,7 +155,7 @@ public final class SatelliteSubscriberInfo implements Parcelable { out.writeString(mSubscriberId); out.writeInt(mCarrierId); out.writeString(mNiddApn); - out.writeInt(mSubId); + out.writeInt(mSubscriptionId); out.writeInt(mSubscriberIdType); } @@ -205,8 +205,8 @@ public final class SatelliteSubscriberInfo implements Parcelable { /** * Return the subscriptionId of the subscription which is used for satellite attachment. */ - public int getSubId() { - return mSubId; + public int getSubscriptionId() { + return mSubscriptionId; } /** @@ -222,7 +222,7 @@ public final class SatelliteSubscriberInfo implements Parcelable { StringBuilder sb = new StringBuilder(); sb.append("SubscriberId:"); - sb.append(mSubscriberId); + sb.append(Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, mSubscriberId)); sb.append(","); sb.append("CarrierId:"); @@ -233,8 +233,8 @@ public final class SatelliteSubscriberInfo implements Parcelable { sb.append(mNiddApn); sb.append(","); - sb.append("SubId:"); - sb.append(mSubId); + sb.append("SubscriptionId:"); + sb.append(mSubscriptionId); sb.append(","); sb.append("SubscriberIdType:"); @@ -244,7 +244,8 @@ public final class SatelliteSubscriberInfo implements Parcelable { @Override public int hashCode() { - return Objects.hash(mSubscriberId, mCarrierId, mNiddApn, mSubId, mSubscriberIdType); + return Objects.hash( + mSubscriberId, mCarrierId, mNiddApn, mSubscriptionId, mSubscriberIdType); } @Override @@ -253,7 +254,8 @@ public final class SatelliteSubscriberInfo implements Parcelable { if (!(o instanceof SatelliteSubscriberInfo)) return false; SatelliteSubscriberInfo that = (SatelliteSubscriberInfo) o; return Objects.equals(mSubscriberId, that.mSubscriberId) && mCarrierId == that.mCarrierId - && Objects.equals(mNiddApn, that.mNiddApn) && mSubId == that.mSubId + && Objects.equals(mNiddApn, that.mNiddApn) + && mSubscriptionId == that.mSubscriptionId && mSubscriberIdType == that.mSubscriberIdType; } @@ -261,7 +263,7 @@ public final class SatelliteSubscriberInfo implements Parcelable { mSubscriberId = in.readString(); mCarrierId = in.readInt(); mNiddApn = in.readString(); - mSubId = in.readInt(); + mSubscriptionId = in.readInt(); mSubscriberIdType = in.readInt(); } } diff --git a/telephony/java/android/telephony/satellite/SatelliteSubscriberProvisionStatus.java b/telephony/java/android/telephony/satellite/SatelliteSubscriberProvisionStatus.java index fb4f89ded547..75d3ec6d3fe6 100644 --- a/telephony/java/android/telephony/satellite/SatelliteSubscriberProvisionStatus.java +++ b/telephony/java/android/telephony/satellite/SatelliteSubscriberProvisionStatus.java @@ -21,8 +21,10 @@ import android.annotation.NonNull; import android.annotation.SystemApi; import android.os.Parcel; import android.os.Parcelable; +import android.telephony.Rlog; import com.android.internal.telephony.flags.Flags; +import com.android.internal.telephony.util.TelephonyUtils; import java.util.Objects; @@ -132,7 +134,7 @@ public final class SatelliteSubscriberProvisionStatus implements Parcelable { StringBuilder sb = new StringBuilder(); sb.append("SatelliteSubscriberInfo:"); - sb.append(mSubscriberInfo); + sb.append(Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, mSubscriberInfo)); sb.append(","); sb.append("ProvisionStatus:"); diff --git a/telephony/java/android/telephony/satellite/SatelliteSupportedStateCallback.java b/telephony/java/android/telephony/satellite/SatelliteSupportedStateCallback.java deleted file mode 100644 index 5487eb6ac942..000000000000 --- a/telephony/java/android/telephony/satellite/SatelliteSupportedStateCallback.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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; - -import android.annotation.FlaggedApi; -import android.annotation.SystemApi; - -import com.android.internal.telephony.flags.Flags; - -/** - * A callback class for monitoring satellite supported state change events. - * - * @hide - */ -@SystemApi -@FlaggedApi(Flags.FLAG_SATELLITE_SYSTEM_APIS) -public interface SatelliteSupportedStateCallback { - /** - * Called when satellite supported state changes. - * - * @param supported The new supported state. {@code true} means satellite is supported, - * {@code false} means satellite is not supported. - */ - void onSatelliteSupportedStateChanged(boolean supported); -} diff --git a/telephony/java/android/telephony/satellite/SatelliteTransmissionUpdateCallback.java b/telephony/java/android/telephony/satellite/SatelliteTransmissionUpdateCallback.java index b5dfb631609c..e18fad3eda79 100644 --- a/telephony/java/android/telephony/satellite/SatelliteTransmissionUpdateCallback.java +++ b/telephony/java/android/telephony/satellite/SatelliteTransmissionUpdateCallback.java @@ -78,6 +78,9 @@ public interface SatelliteTransmissionUpdateCallback { /** * Called when framework receives a request to send a datagram. * + * Informs external apps that device is working on sending a datagram out and is in the process + * of checking if all the conditions required to send datagrams are met. + * * @param datagramType The type of the requested datagram. */ @FlaggedApi(Flags.FLAG_SATELLITE_SYSTEM_APIS) diff --git a/telephony/java/android/telephony/satellite/SystemSelectionSpecifier.java b/telephony/java/android/telephony/satellite/SystemSelectionSpecifier.java index 61e1e5fa8e7e..ca69984c581a 100644 --- a/telephony/java/android/telephony/satellite/SystemSelectionSpecifier.java +++ b/telephony/java/android/telephony/satellite/SystemSelectionSpecifier.java @@ -27,11 +27,17 @@ import android.util.IntArray; import com.android.internal.telephony.flags.Flags; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Objects; /** + * This class defines the information that modem will use to decide which satellites it should + * attach to and how it should scan for the signal from the chosen satellites. + * Moreover, it also provides the customized information {@code mTagIds} to provide the flexibility + * for OEMs and vendors to define more info that they need for communicating with satellites like + * how modem should control the power to meet the requirement of local authorities. * @hide */ @SystemApi @@ -42,20 +48,20 @@ public final class SystemSelectionSpecifier implements Parcelable { @NonNull private String mMccMnc; /** The frequency bands to scan. Maximum length of the vector is 8. */ - @NonNull private IntArray mBands; + @NonNull private int[] mBands; /** * The radio channels to scan as defined in 3GPP TS 25.101 and 36.101. * Maximum length of the vector is 32. */ - @NonNull private IntArray mEarfcns; + @NonNull private int[] mEarfcns; /* The list of satellites configured for the current location */ @Nullable - private SatelliteInfo[] mSatelliteInfos; + private List<SatelliteInfo> mSatelliteInfos; /* The list of tag IDs associated with the current location */ - @Nullable private IntArray mTagIds; + @Nullable private int[] mTagIds; /** * @hide @@ -64,10 +70,84 @@ public final class SystemSelectionSpecifier implements Parcelable { @NonNull IntArray earfcns, @Nullable SatelliteInfo[] satelliteInfos, @Nullable IntArray tagIds) { mMccMnc = mccmnc; - mBands = bands; - mEarfcns = earfcns; - mSatelliteInfos = satelliteInfos; - mTagIds = tagIds; + mBands = bands.toArray(); + mEarfcns = earfcns.toArray(); + mSatelliteInfos = Arrays.stream(satelliteInfos).toList(); + mTagIds = tagIds.toArray(); + } + + /** + * @hide + */ + public SystemSelectionSpecifier(Builder builder) { + mMccMnc = builder.mMccMnc; + mBands = builder.mBands; + mEarfcns = builder.mEarfcns; + mSatelliteInfos = builder.mSatelliteInfos; + mTagIds = builder.mTagIds; + } + + /** + * Builder class for constructing SystemSelectionSpecifier objects + */ + public static final class Builder { + @NonNull private String mMccMnc; + @NonNull private int[] mBands; + @NonNull private int[] mEarfcns; + private List<SatelliteInfo> mSatelliteInfos; + @Nullable private int[] mTagIds; + + /** Set network plmn associated with the channel and return the Builder class. */ + @NonNull + public Builder setMccMnc(@NonNull String mccMnc) { + this.mMccMnc = mccMnc; + return this; + } + + /** + * Set frequency bands to scan and return the Builder class. + * Maximum length of the vector is 8. + */ + @NonNull + public Builder setBands(@NonNull int[] bands) { + this.mBands = bands; + return this; + } + + /** + * Set radio channels to scan as defined in 3GPP TS 25.101 and 36.101 + * and returns the Builder class. + * Maximum length if the vector is 32. + */ + @NonNull + public Builder setEarfcns(@NonNull int[] earfcns) { + this.mEarfcns = earfcns; + return this; + } + + /** + * Set list of satellites configured for the current location and return the Builder class. + */ + @NonNull + public Builder setSatelliteInfos(@NonNull List<SatelliteInfo> satelliteInfos) { + this.mSatelliteInfos = satelliteInfos; + return this; + } + + /** + * Set list of tag IDs associated with the current location and return the Builder class. + */ + @NonNull + public Builder setTagIds(@NonNull int[] tagIds) { + this.mTagIds = tagIds; + return this; + } + + /** Return SystemSelectionSpecifier object */ + @NonNull + public SystemSelectionSpecifier build() { + return new SystemSelectionSpecifier(this); + } } private SystemSelectionSpecifier(Parcel in) { @@ -84,30 +164,30 @@ public final class SystemSelectionSpecifier implements Parcelable { mMccMnc = TextUtils.emptyIfNull(mMccMnc); out.writeString8(mMccMnc); - if (mBands != null && mBands.size() > 0) { - out.writeInt(mBands.size()); - for (int i = 0; i < mBands.size(); i++) { - out.writeInt(mBands.get(i)); + if (mBands != null && mBands.length > 0) { + out.writeInt(mBands.length); + for (int i = 0; i < mBands.length; i++) { + out.writeInt(mBands[i]); } } else { out.writeInt(0); } - if (mEarfcns != null && mEarfcns.size() > 0) { - out.writeInt(mEarfcns.size()); - for (int i = 0; i < mEarfcns.size(); i++) { - out.writeInt(mEarfcns.get(i)); + if (mEarfcns != null && mEarfcns.length > 0) { + out.writeInt(mEarfcns.length); + for (int i = 0; i < mEarfcns.length; i++) { + out.writeInt(mEarfcns[i]); } } else { out.writeInt(0); } - out.writeTypedArray(mSatelliteInfos, flags); + out.writeTypedArray(mSatelliteInfos.toArray(new SatelliteInfo[0]), flags); if (mTagIds != null) { - out.writeInt(mTagIds.size()); - for (int i = 0; i < mTagIds.size(); i++) { - out.writeInt(mTagIds.get(i)); + out.writeInt(mTagIds.length); + for (int i = 0; i < mTagIds.length; i++) { + out.writeInt(mTagIds[i]); } } else { out.writeInt(0); @@ -135,9 +215,9 @@ public final class SystemSelectionSpecifier implements Parcelable { sb.append(","); sb.append("bands:"); - if (mBands != null && mBands.size() > 0) { - for (int i = 0; i < mBands.size(); i++) { - sb.append(mBands.get(i)); + if (mBands != null && mBands.length > 0) { + for (int i = 0; i < mBands.length; i++) { + sb.append(mBands[i]); sb.append(","); } } else { @@ -145,9 +225,9 @@ public final class SystemSelectionSpecifier implements Parcelable { } sb.append("earfcs:"); - if (mEarfcns != null && mEarfcns.size() > 0) { - for (int i = 0; i < mEarfcns.size(); i++) { - sb.append(mEarfcns.get(i)); + if (mEarfcns != null && mEarfcns.length > 0) { + for (int i = 0; i < mEarfcns.length; i++) { + sb.append(mEarfcns[i]); sb.append(","); } } else { @@ -155,7 +235,7 @@ public final class SystemSelectionSpecifier implements Parcelable { } sb.append("mSatelliteInfos:"); - if (mSatelliteInfos != null && mSatelliteInfos.length > 0) { + if (mSatelliteInfos != null && mSatelliteInfos.size() > 0) { for (SatelliteInfo satelliteInfo : mSatelliteInfos) { sb.append(satelliteInfo); sb.append(","); @@ -165,9 +245,9 @@ public final class SystemSelectionSpecifier implements Parcelable { } sb.append("mTagIds:"); - if (mTagIds != null && mTagIds.size() > 0) { - for (int i = 0; i < mTagIds.size(); i++) { - sb.append(mTagIds.get(i)); + if (mTagIds != null && mTagIds.length > 0) { + for (int i = 0; i < mTagIds.length; i++) { + sb.append(mTagIds[i]); sb.append(","); } } else { @@ -183,16 +263,16 @@ public final class SystemSelectionSpecifier implements Parcelable { if (o == null || getClass() != o.getClass()) return false; SystemSelectionSpecifier that = (SystemSelectionSpecifier) o; return Objects.equals(mMccMnc, that.mMccMnc) - && Objects.equals(mBands, that.mBands) - && Objects.equals(mEarfcns, that.mEarfcns) - && (mSatelliteInfos == null ? that.mSatelliteInfos == null : Arrays.equals( - mSatelliteInfos, that.mSatelliteInfos)) - && Objects.equals(mTagIds, that.mTagIds); + && Arrays.equals(mBands, that.mBands) + && Arrays.equals(mEarfcns, that.mEarfcns) + && (mSatelliteInfos == null ? that.mSatelliteInfos == null : + mSatelliteInfos.equals(that.mSatelliteInfos)) + && Arrays.equals(mTagIds, that.mTagIds); } @Override public int hashCode() { - return Objects.hash(mMccMnc, mBands, mEarfcns); + return Objects.hash(mMccMnc, Arrays.hashCode(mBands), Arrays.hashCode(mEarfcns)); } /** Return network plmn associated with channel information. */ @@ -203,9 +283,10 @@ public final class SystemSelectionSpecifier implements Parcelable { /** * Return the frequency bands to scan. * Maximum length of the vector is 8. + * Refer specification 3GPP TS 36.101 for detailed information on frequency bands. */ @NonNull public int[] getBands() { - return mBands.toArray(); + return mBands; } /** @@ -213,13 +294,13 @@ public final class SystemSelectionSpecifier implements Parcelable { * Maximum length of the vector is 32. */ @NonNull public int[] getEarfcns() { - return mEarfcns.toArray(); + return mEarfcns; } /** Return the list of satellites configured for the current location. */ @NonNull public List<SatelliteInfo> getSatelliteInfos() { - return Arrays.stream(mSatelliteInfos).toList(); + return mSatelliteInfos; } /** @@ -229,34 +310,36 @@ public final class SystemSelectionSpecifier implements Parcelable { */ @NonNull public int[] getTagIds() { - return mTagIds.toArray(); + return mTagIds; } private void readFromParcel(Parcel in) { mMccMnc = in.readString(); - mBands = new IntArray(); int numBands = in.readInt(); + mBands = new int[numBands]; if (numBands > 0) { for (int i = 0; i < numBands; i++) { - mBands.add(in.readInt()); + mBands[i] = in.readInt(); } } - mEarfcns = new IntArray(); int numEarfcns = in.readInt(); + mEarfcns = new int[numEarfcns]; if (numEarfcns > 0) { for (int i = 0; i < numEarfcns; i++) { - mEarfcns.add(in.readInt()); + mEarfcns[i] = in.readInt(); } } - mSatelliteInfos = in.createTypedArray(SatelliteInfo.CREATOR); + mSatelliteInfos = new ArrayList<>(); + in.readList(mSatelliteInfos, SatelliteInfo.class.getClassLoader(), SatelliteInfo.class); int numTagIds = in.readInt(); + mTagIds = new int[numTagIds]; if (numTagIds > 0) { for (int i = 0; i < numTagIds; i++) { - mTagIds.add(in.readInt()); + mTagIds[i] = in.readInt(); } } } diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 74d9204e9c84..08c003027c5b 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -69,12 +69,11 @@ import android.telephony.ims.aidl.IImsRegistrationCallback; import android.telephony.ims.aidl.IRcsConfigCallback; import android.telephony.satellite.INtnSignalStrengthCallback; import android.telephony.satellite.ISatelliteCapabilitiesCallback; -import android.telephony.satellite.ISatelliteCommunicationAllowedStateCallback; +import android.telephony.satellite.ISatelliteCommunicationAccessStateCallback; import android.telephony.satellite.ISatelliteDatagramCallback; import android.telephony.satellite.ISatelliteDisallowedReasonsCallback; import android.telephony.satellite.ISatelliteTransmissionUpdateCallback; import android.telephony.satellite.ISatelliteProvisionStateCallback; -import android.telephony.satellite.ISatelliteSupportedStateCallback; import android.telephony.satellite.ISatelliteModemStateCallback; import android.telephony.satellite.ISelectedNbIotSatelliteSubscriptionCallback; import android.telephony.satellite.NtnSignalStrength; @@ -3425,8 +3424,7 @@ interface ITelephony { */ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(" + "android.Manifest.permission.SATELLITE_COMMUNICATION)") - int registerForSatelliteSupportedStateChanged( - in ISatelliteSupportedStateCallback callback); + int registerForSatelliteSupportedStateChanged(in IBooleanConsumer callback); /** * Unregisters for supported state changed from satellite modem. @@ -3436,8 +3434,7 @@ interface ITelephony { */ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(" + "android.Manifest.permission.SATELLITE_COMMUNICATION)") - void unregisterForSatelliteSupportedStateChanged( - in ISatelliteSupportedStateCallback callback); + void unregisterForSatelliteSupportedStateChanged(in IBooleanConsumer callback); /** * Registers for satellite communication allowed state changed. @@ -3449,20 +3446,20 @@ interface ITelephony { */ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(" + "android.Manifest.permission.SATELLITE_COMMUNICATION)") - int registerForCommunicationAllowedStateChanged(int subId, - in ISatelliteCommunicationAllowedStateCallback callback); + int registerForCommunicationAccessStateChanged(int subId, + in ISatelliteCommunicationAccessStateCallback callback); /** * Unregisters for satellite communication allowed state. * If callback was not registered before, the request will be ignored. * * @param subId The subId of the subscription to unregister for supported state changed. - * @param callback The callback that was passed to registerForCommunicationAllowedStateChanged. + * @param callback The callback that was passed to registerForCommunicationAccessStateChanged. */ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(" + "android.Manifest.permission.SATELLITE_COMMUNICATION)") - void unregisterForCommunicationAllowedStateChanged(int subId, - in ISatelliteCommunicationAllowedStateCallback callback); + void unregisterForCommunicationAccessStateChanged(int subId, + in ISatelliteCommunicationAccessStateCallback callback); /** * This API can be used by only CTS to override the boolean configs used by the diff --git a/telephony/java/com/android/internal/telephony/util/WorkerThread.java b/telephony/java/com/android/internal/telephony/util/WorkerThread.java new file mode 100644 index 000000000000..f5b653656352 --- /dev/null +++ b/telephony/java/com/android/internal/telephony/util/WorkerThread.java @@ -0,0 +1,130 @@ +/* + * 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 com.android.internal.telephony.util; + +import android.annotation.NonNull; +import android.os.Handler; +import android.os.HandlerExecutor; +import android.os.HandlerThread; + +import com.android.internal.annotations.VisibleForTesting; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Executor; + +/** + * Shared singleton worker thread for each process. + * + * This thread should be used for work that needs to be executed at standard priority + * but not on the main thread. This is suitable for handling asynchronous tasks that + * are ephemeral or require enough work that they shouldn't block the main thread, but + * should not block each other for more than around 100ms. + */ +public final class WorkerThread extends HandlerThread { + private static volatile WorkerThread sInstance; + private static volatile Handler sHandler; + private static volatile HandlerExecutor sHandlerExecutor; + private static final Object sLock = new Object(); + + private CountDownLatch mInitLock = new CountDownLatch(1); + + + private WorkerThread() { + super("android.telephony.worker"); + } + + private static void ensureThread() { + if (sInstance != null) return; + synchronized (sLock) { + if (sInstance != null) return; + + final WorkerThread tmpThread = new WorkerThread(); + tmpThread.start(); + + try { + tmpThread.mInitLock.await(); + } catch (InterruptedException ignored) { + } + + + sHandler = new Handler( + tmpThread.getLooper(), + /* callback= */ null, + /* async= */ false, + /* shared= */ true); + sHandlerExecutor = new HandlerExecutor(sHandler); + sInstance = tmpThread; // Note: order matters here. sInstance must be assigned last. + + } + } + + @Override + protected void onLooperPrepared() { + mInitLock.countDown(); + } + + /** + * Get the worker thread directly. + * + * Users of this thread should take care not to block it for extended periods of + * time. + * + * @return a HandlerThread, never null + */ + @NonNull public static HandlerThread get() { + ensureThread(); + return sInstance; + } + + /** + * Get a Handler that can process Runnables. + * + * @return a Handler, never null + */ + @NonNull public static Handler getHandler() { + ensureThread(); + return sHandler; + } + + /** + * Get an Executor that can process Runnables + * + * @return an Executor, never null + */ + @NonNull public static Executor getExecutor() { + ensureThread(); + return sHandlerExecutor; + } + + /** + * A method to reset the WorkerThread from scratch. + * + * This method should only be used for unit testing. In production it would have + * catastrophic consequences. Do not ever use this outside of tests. + */ + @VisibleForTesting + public static void reset() { + synchronized (sLock) { + if (sInstance == null) return; + sInstance.quitSafely(); + sInstance = null; + sHandler = null; + sHandlerExecutor = null; + ensureThread(); + } + } +} |