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

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

Merge "Add new API to notify carrier roaming ntn mode changes." into 24D1-dev

parents ff20a753 e95561b9
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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) {
+40 −1
Original line number Diff line number Diff line
@@ -643,6 +643,15 @@ public class TelephonyCallback {
    @SystemApi
    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
     */
@@ -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 {
@@ -1685,6 +1695,24 @@ public class TelephonyCallback {
                @TelephonyManager.EmergencyCallbackModeStopReason int reason);
    }

    /**
     * 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.
@@ -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)));
        }
    }
}
+22 −0
Original line number Diff line number Diff line
@@ -1072,6 +1072,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}.
     *
@@ -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;
    }

+1 −0
Original line number Diff line number Diff line
@@ -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);
}
+1 −0
Original line number Diff line number Diff line
@@ -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);
}
Loading