diff options
| author | 2024-04-23 18:14:54 +0000 | |
|---|---|---|
| committer | 2024-04-23 18:14:54 +0000 | |
| commit | d0f6082285b46568540091d9aab827d8863f073a (patch) | |
| tree | 68a1d17c80b6be2687aa834cb677145774e887e9 | |
| parent | ff20a75307698bee4949bfac4bc2d069ec660edb (diff) | |
| parent | e95561b92c6c759061ad981537ccff9d8088142b (diff) | |
Merge "Add new API to notify carrier roaming ntn mode changes." into 24D1-dev
6 files changed, 117 insertions, 1 deletions
diff --git a/core/java/android/telephony/PhoneStateListener.java b/core/java/android/telephony/PhoneStateListener.java index fb57921b1529..4281da12720b 100644 --- a/core/java/android/telephony/PhoneStateListener.java +++ b/core/java/android/telephony/PhoneStateListener.java @@ -1685,6 +1685,10 @@ public class PhoneStateListener { public final void onSimultaneousCallingStateChanged(int[] subIds) { // not supported on the deprecated interface - Use TelephonyCallback instead } + + public final void onCarrierRoamingNtnModeChanged(boolean active) { + // not supported on the deprecated interface - Use TelephonyCallback instead + } } private void log(String s) { diff --git a/core/java/android/telephony/TelephonyCallback.java b/core/java/android/telephony/TelephonyCallback.java index dc6a035a8176..b8b84d93c97c 100644 --- a/core/java/android/telephony/TelephonyCallback.java +++ b/core/java/android/telephony/TelephonyCallback.java @@ -644,6 +644,15 @@ public class TelephonyCallback { public static final int EVENT_SIMULTANEOUS_CELLULAR_CALLING_SUBSCRIPTIONS_CHANGED = 41; /** + * Event for listening to changes in carrier roaming non-terrestrial network mode. + * + * @see CarrierRoamingNtnModeListener + * + * @hide + */ + public static final int EVENT_CARRIER_ROAMING_NTN_MODE_CHANGED = 42; + + /** * @hide */ @IntDef(prefix = {"EVENT_"}, value = { @@ -687,7 +696,8 @@ public class TelephonyCallback { EVENT_TRIGGER_NOTIFY_ANBR, EVENT_MEDIA_QUALITY_STATUS_CHANGED, EVENT_EMERGENCY_CALLBACK_MODE_CHANGED, - EVENT_SIMULTANEOUS_CELLULAR_CALLING_SUBSCRIPTIONS_CHANGED + EVENT_SIMULTANEOUS_CELLULAR_CALLING_SUBSCRIPTIONS_CHANGED, + EVENT_CARRIER_ROAMING_NTN_MODE_CHANGED }) @Retention(RetentionPolicy.SOURCE) public @interface TelephonyEvent { @@ -1686,6 +1696,24 @@ public class TelephonyCallback { } /** + * Interface for carrier roaming non-terrestrial network listener. + * + * @hide + */ + public interface CarrierRoamingNtnModeListener { + /** + * 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); + } + + /** * The callback methods need to be called on the handler thread where * this object was created. If the binder did that for us it'd be nice. * <p> @@ -2086,5 +2114,16 @@ public class TelephonyCallback { Binder.withCleanCallingIdentity( () -> mExecutor.execute(() -> listener.onCallBackModeStopped(type, reason))); } + + public void onCarrierRoamingNtnModeChanged(boolean active) { + if (!Flags.carrierEnabledSatelliteFlag()) return; + + CarrierRoamingNtnModeListener listener = + (CarrierRoamingNtnModeListener) mTelephonyCallbackWeakRef.get(); + if (listener == null) return; + + Binder.withCleanCallingIdentity( + () -> mExecutor.execute(() -> listener.onCarrierRoamingNtnModeChanged(active))); + } } } diff --git a/core/java/android/telephony/TelephonyRegistryManager.java b/core/java/android/telephony/TelephonyRegistryManager.java index d39c4ce4ce24..6160fdb223f2 100644 --- a/core/java/android/telephony/TelephonyRegistryManager.java +++ b/core/java/android/telephony/TelephonyRegistryManager.java @@ -1073,6 +1073,24 @@ public class TelephonyRegistryManager { } /** + * Notify external listeners that carrier roaming non-terrestrial network mode changed. + * @param subId subscription ID. + * @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. + * @hide + */ + public void notifyCarrierRoamingNtnModeChanged(int subId, boolean active) { + try { + sRegistry.notifyCarrierRoamingNtnModeChanged(subId, active); + } catch (RemoteException ex) { + // system server crash + throw ex.rethrowFromSystemServer(); + } + } + + /** * Processes potential event changes from the provided {@link TelephonyCallback}. * * @param telephonyCallback callback for monitoring callback changes to the telephony state. @@ -1224,6 +1242,10 @@ public class TelephonyRegistryManager { eventList.add( TelephonyCallback.EVENT_SIMULTANEOUS_CELLULAR_CALLING_SUBSCRIPTIONS_CHANGED); } + + if (telephonyCallback instanceof TelephonyCallback.CarrierRoamingNtnModeListener) { + eventList.add(TelephonyCallback.EVENT_CARRIER_ROAMING_NTN_MODE_CHANGED); + } return eventList; } diff --git a/core/java/com/android/internal/telephony/IPhoneStateListener.aidl b/core/java/com/android/internal/telephony/IPhoneStateListener.aidl index 969f95db002d..792c22348d77 100644 --- a/core/java/com/android/internal/telephony/IPhoneStateListener.aidl +++ b/core/java/com/android/internal/telephony/IPhoneStateListener.aidl @@ -81,4 +81,5 @@ oneway interface IPhoneStateListener { void onCallBackModeStarted(int type); void onCallBackModeStopped(int type, int reason); void onSimultaneousCallingStateChanged(in int[] subIds); + void onCarrierRoamingNtnModeChanged(in boolean active); } diff --git a/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl b/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl index 0203ea49f252..04332cd758a6 100644 --- a/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl +++ b/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl @@ -120,4 +120,5 @@ interface ITelephonyRegistry { void notifyCallbackModeStarted(int phoneId, int subId, int type); void notifyCallbackModeStopped(int phoneId, int subId, int type, int reason); + void notifyCarrierRoamingNtnModeChanged(int subId, in boolean active); } diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index bd67cf42014a..e1710649f925 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -425,6 +425,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { private int[] mSCBMReason; private boolean[] mSCBMStarted; + private boolean[] mCarrierRoamingNtnMode = null; + /** * Per-phone map of precise data connection state. The key of the map is the pair of transport * type and APN setting. This is the cache to prevent redundant callbacks to the listeners. @@ -723,6 +725,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { mECBMStarted = copyOf(mECBMStarted, mNumPhones); mSCBMReason = copyOf(mSCBMReason, mNumPhones); mSCBMStarted = copyOf(mSCBMStarted, mNumPhones); + mCarrierRoamingNtnMode = copyOf(mCarrierRoamingNtnMode, mNumPhones); // ds -> ss switch. if (mNumPhones < oldNumPhones) { cutListToSize(mCellInfo, mNumPhones); @@ -781,6 +784,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { mECBMStarted[i] = false; mSCBMReason[i] = TelephonyManager.STOP_REASON_UNKNOWN; mSCBMStarted[i] = false; + mCarrierRoamingNtnMode[i] = false; } } } @@ -854,6 +858,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { mECBMStarted = new boolean[numPhones]; mSCBMReason = new int[numPhones]; mSCBMStarted = new boolean[numPhones]; + mCarrierRoamingNtnMode = new boolean[numPhones]; for (int i = 0; i < numPhones; i++) { mCallState[i] = TelephonyManager.CALL_STATE_IDLE; @@ -897,6 +902,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { mECBMStarted[i] = false; mSCBMReason[i] = TelephonyManager.STOP_REASON_UNKNOWN; mSCBMStarted[i] = false; + mCarrierRoamingNtnMode[i] = false; } mAppOps = mContext.getSystemService(AppOpsManager.class); @@ -1523,6 +1529,14 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { remove(r.binder); } } + if (events.contains(TelephonyCallback.EVENT_CARRIER_ROAMING_NTN_MODE_CHANGED)) { + try { + r.callback.onCarrierRoamingNtnModeChanged( + mCarrierRoamingNtnMode[r.phoneId]); + } catch (RemoteException ex) { + remove(r.binder); + } + } } } } @@ -3512,6 +3526,41 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { handleRemoveListLocked(); } + /** + * Notify external listeners that carrier roaming non-terrestrial network mode changed. + * @param subId subscription ID. + * @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. + */ + public void notifyCarrierRoamingNtnModeChanged(int subId, boolean active) { + if (!checkNotifyPermission("notifyCarrierRoamingNtnModeChanged")) { + return; + } + + if (VDBG) { + log("notifyCarrierRoamingNtnModeChanged: subId=" + subId + " active=" + active); + } + + synchronized (mRecords) { + int phoneId = getPhoneIdFromSubId(subId); + mCarrierRoamingNtnMode[phoneId] = active; + for (Record r : mRecords) { + if (r.matchTelephonyCallbackEvent( + TelephonyCallback.EVENT_CARRIER_ROAMING_NTN_MODE_CHANGED) + && idMatch(r, subId, phoneId)) { + try { + r.callback.onCarrierRoamingNtnModeChanged(active); + } catch (RemoteException ex) { + mRemoveList.add(r.binder); + } + } + } + handleRemoveListLocked(); + } + } + @NeverCompile // Avoid size overhead of debugging code. @Override public void dump(FileDescriptor fd, PrintWriter writer, String[] args) { |