Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0881028e authored by Aishwarya Mallampati's avatar Aishwarya Mallampati Committed by Android (Google) Code Review
Browse files

Merge "Add onCarrierRoamingNtnEligibleStateChanged callback" into main

parents d0a151b5 1130054d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1689,6 +1689,10 @@ public class PhoneStateListener {
        public final void onCarrierRoamingNtnModeChanged(boolean active) {
            // not supported on the deprecated interface - Use TelephonyCallback instead
        }

        public final void onCarrierRoamingNtnEligibleStateChanged(boolean eligible) {
            // not supported on the deprecated interface - Use TelephonyCallback instead
        }
    }

    private void log(String s) {
+51 −1
Original line number Diff line number Diff line
@@ -652,6 +652,27 @@ public class TelephonyCallback {
     */
    public static final int EVENT_CARRIER_ROAMING_NTN_MODE_CHANGED = 42;

    /**
     * Event for listening to changes in carrier roaming non-terrestrial network eligibility.
     *
     * @see CarrierRoamingNtnModeListener
     *
     * 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>
     *
     * @hide
     */
    public static final int EVENT_CARRIER_ROAMING_NTN_ELIGIBLE_STATE_CHANGED = 43;

    /**
     * @hide
     */
@@ -697,7 +718,8 @@ public class TelephonyCallback {
            EVENT_MEDIA_QUALITY_STATUS_CHANGED,
            EVENT_EMERGENCY_CALLBACK_MODE_CHANGED,
            EVENT_SIMULTANEOUS_CELLULAR_CALLING_SUBSCRIPTIONS_CHANGED,
            EVENT_CARRIER_ROAMING_NTN_MODE_CHANGED
            EVENT_CARRIER_ROAMING_NTN_MODE_CHANGED,
            EVENT_CARRIER_ROAMING_NTN_ELIGIBLE_STATE_CHANGED
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface TelephonyEvent {
@@ -1711,6 +1733,23 @@ public class TelephonyCallback {
         *                           {code false} otherwise.
         */
        void onCarrierRoamingNtnModeChanged(boolean active);

        /**
         * Callback invoked when carrier roaming non-terrestrial network eligibility 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) {}
    }

    /**
@@ -2125,5 +2164,16 @@ public class TelephonyCallback {
            Binder.withCleanCallingIdentity(
                    () -> mExecutor.execute(() -> listener.onCarrierRoamingNtnModeChanged(active)));
        }

        public void onCarrierRoamingNtnEligibleStateChanged(boolean eligible) {
            if (!Flags.carrierRoamingNbIotNtn()) return;

            CarrierRoamingNtnModeListener listener =
                    (CarrierRoamingNtnModeListener) mTelephonyCallbackWeakRef.get();
            if (listener == null) return;

            Binder.withCleanCallingIdentity(() -> mExecutor.execute(
                    () -> listener.onCarrierRoamingNtnEligibleStateChanged(eligible)));
        }
    }
}
+33 −0
Original line number Diff line number Diff line
@@ -1090,6 +1090,34 @@ public class TelephonyRegistryManager {
        }
    }

    /**
     * Notify external listeners that device eligibility to connect to carrier roaming
     * non-terrestrial network changed.
     *
     * @param subId subscription ID.
     * @param eligible {@code true} when the device is eligible for satellite
     * communication if all the following conditions are met:
     * <ul>
     * <li>Any subscription 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>
     *
     * @hide
     */
    public void notifyCarrierRoamingNtnEligibleStateChanged(int subId, boolean eligible) {
        try {
            sRegistry.notifyCarrierRoamingNtnEligibleStateChanged(subId, eligible);
        } catch (RemoteException ex) {
            // system server crash
            throw ex.rethrowFromSystemServer();
        }
    }

    /**
     * Processes potential event changes from the provided {@link TelephonyCallback}.
     *
@@ -1246,6 +1274,11 @@ public class TelephonyRegistryManager {
        if (telephonyCallback instanceof TelephonyCallback.CarrierRoamingNtnModeListener) {
            eventList.add(TelephonyCallback.EVENT_CARRIER_ROAMING_NTN_MODE_CHANGED);
        }

        if (telephonyCallback instanceof TelephonyCallback.CarrierRoamingNtnModeListener) {
            eventList.add(TelephonyCallback.EVENT_CARRIER_ROAMING_NTN_ELIGIBLE_STATE_CHANGED);
        }

        return eventList;
    }

+1 −0
Original line number Diff line number Diff line
@@ -82,4 +82,5 @@ oneway interface IPhoneStateListener {
    void onCallBackModeStopped(int type, int reason);
    void onSimultaneousCallingStateChanged(in int[] subIds);
    void onCarrierRoamingNtnModeChanged(in boolean active);
    void onCarrierRoamingNtnEligibleStateChanged(in boolean eligible);
}
+1 −0
Original line number Diff line number Diff line
@@ -121,4 +121,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);
    void notifyCarrierRoamingNtnEligibleStateChanged(int subId, in boolean eligible);
}
Loading