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

Commit 5deac06f authored by Jack Nudelman's avatar Jack Nudelman
Browse files

Allow for DataThrottling APIs to be call the radio impl.

Add ability to set reason for radio's power state.

go/telephony-thermal-mitigation

Bug: 158872959
Test: make, cts

Change-Id: I40d77d84ae86b76b350aa3bd9e412ad179d7fee2
Merged-In: I40d77d84ae86b76b350aa3bd9e412ad179d7fee2
parent 95162a3a
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -2594,8 +2594,9 @@ public interface CommandsInterface {
     * @param workSource calling Worksource
     * @param workSource calling Worksource
     * @param dataThrottlingAction the DataThrottlingAction that is being requested.
     * @param dataThrottlingAction the DataThrottlingAction that is being requested.
     *      Defined in android.hardware.radio@1.6.types.
     *      Defined in android.hardware.radio@1.6.types.
     * @param completionWindowSecs seconds in which data throttling action has to be achieved.
     * @param completionWindowMillis milliseconds in which data throttling action has to be
     *      achieved.
     */
     */
    default void setDataThrottling(Message result, WorkSource workSource,
    default void setDataThrottling(Message result, WorkSource workSource,
            int dataThrottlingAction, int completionWindowSecs) {};
            int dataThrottlingAction, long completionWindowMillis) {};
}
}
+9 −1
Original line number Original line Diff line number Diff line
@@ -1654,7 +1654,15 @@ public class GsmCdmaPhone extends Phone {
    @Override
    @Override
    public void setRadioPower(boolean power, boolean forEmergencyCall,
    public void setRadioPower(boolean power, boolean forEmergencyCall,
            boolean isSelectedPhoneForEmergencyCall, boolean forceApply) {
            boolean isSelectedPhoneForEmergencyCall, boolean forceApply) {
        mSST.setRadioPower(power, forEmergencyCall, isSelectedPhoneForEmergencyCall, forceApply);
        setRadioPowerForReason(power, forEmergencyCall, isSelectedPhoneForEmergencyCall, forceApply,
                Phone.RADIO_POWER_REASON_USER);
    }

    @Override
    public void setRadioPowerForReason(boolean power, boolean forEmergencyCall,
            boolean isSelectedPhoneForEmergencyCall, boolean forceApply, int reason) {
        mSST.setRadioPowerForReason(power, forEmergencyCall, isSelectedPhoneForEmergencyCall,
                forceApply, reason);
    }
    }


    private void storeVoiceMailNumber(String number) {
    private void storeVoiceMailNumber(String number) {
+5 −4
Original line number Original line Diff line number Diff line
@@ -4185,11 +4185,12 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
     * @param workSource calling Worksource
     * @param workSource calling Worksource
     * @param dataThrottlingAction the DataThrottlingAction that is being requested. Defined in
     * @param dataThrottlingAction the DataThrottlingAction that is being requested. Defined in
     *      android.telephony.TelephonyManger.
     *      android.telephony.TelephonyManger.
     * @param completionWindowSecs seconds in which data throttling action has to be achieved.
     * @param completionWindowMillis milliseconds in which data throttling action has to be
     *      achieved.
     */
     */
    public void setDataThrottling(Message result, WorkSource workSource,
    public void setDataThrottling(Message result, WorkSource workSource,
            int dataThrottlingAction, int completionWindowSecs) {
            int dataThrottlingAction, long completionWindowMillis) {
        mCi.setDataThrottling(result, workSource, dataThrottlingAction, completionWindowSecs);
        mCi.setDataThrottling(result, workSource, dataThrottlingAction, completionWindowMillis);
    }
    }


    /**
    /**
+72 −3
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package com.android.internal.telephony;
package com.android.internal.telephony;


import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.NonNull;
import android.compat.annotation.UnsupportedAppUsage;
import android.compat.annotation.UnsupportedAppUsage;
import android.os.Build;
import android.os.Build;
@@ -33,6 +34,8 @@ import android.telephony.TelephonyManager;


import com.android.internal.telephony.PhoneConstants.DataState;
import com.android.internal.telephony.PhoneConstants.DataState;


import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List;
import java.util.List;


/**
/**
@@ -162,6 +165,16 @@ public interface PhoneInternalInterface {
    static final String REASON_DATA_ENABLED_OVERRIDE = "dataEnabledOverride";
    static final String REASON_DATA_ENABLED_OVERRIDE = "dataEnabledOverride";
    static final String REASON_IWLAN_DATA_SERVICE_DIED = "iwlanDataServiceDied";
    static final String REASON_IWLAN_DATA_SERVICE_DIED = "iwlanDataServiceDied";


    // Reasons for Radio being powered off
    int RADIO_POWER_REASON_USER = 0;
    int RADIO_POWER_REASON_THERMAL = 1;
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = {"RADIO_POWER_REASON_"},
        value = {
            RADIO_POWER_REASON_USER,
            RADIO_POWER_REASON_THERMAL})
    public @interface RadioPowerReason {}

    // Used for band mode selection methods
    // Used for band mode selection methods
    static final int BM_UNSPECIFIED = RILConstants.BAND_MODE_UNSPECIFIED; // automatic
    static final int BM_UNSPECIFIED = RILConstants.BAND_MODE_UNSPECIFIED; // automatic
    static final int BM_EURO_BAND   = RILConstants.BAND_MODE_EURO;
    static final int BM_EURO_BAND   = RILConstants.BAND_MODE_EURO;
@@ -513,7 +526,10 @@ public interface PhoneInternalInterface {
     * <strong>Note: </strong>This request is asynchronous.
     * <strong>Note: </strong>This request is asynchronous.
     * getServiceState().getState() will not change immediately after this call.
     * getServiceState().getState() will not change immediately after this call.
     * registerForServiceStateChanged() to find out when the
     * registerForServiceStateChanged() to find out when the
     * request is complete.
     * request is complete. This will set the reason for radio power state as {@link
     * #RADIO_POWER_REASON_USER}. This will not guarantee that the requested radio power state will
     * actually be set. See {@link #setRadioPowerForReason(boolean, boolean, boolean, boolean, int)}
     * for details.
     *
     *
     * @param power true means "on", false means "off".
     * @param power true means "on", false means "off".
     */
     */
@@ -529,7 +545,10 @@ public interface PhoneInternalInterface {
     * <strong>Note: </strong>This request is asynchronous.
     * <strong>Note: </strong>This request is asynchronous.
     * getServiceState().getState() will not change immediately after this call.
     * getServiceState().getState() will not change immediately after this call.
     * registerForServiceStateChanged() to find out when the
     * registerForServiceStateChanged() to find out when the
     * request is complete.
     * request is complete. This will set the reason for radio power state as {@link
     * #RADIO_POWER_REASON_USER}. This will not guarantee that the requested radio power state will
     * actually be set. See {@link #setRadioPowerForReason(boolean, boolean, boolean, boolean, int)}
     * for details.
     *
     *
     * @param power true means "on", false means "off".
     * @param power true means "on", false means "off".
     * @param forEmergencyCall true means the purpose of turning radio power on is for emergency
     * @param forEmergencyCall true means the purpose of turning radio power on is for emergency
@@ -543,7 +562,57 @@ public interface PhoneInternalInterface {
     *                   power on again with forEmergencyCall being false.
     *                   power on again with forEmergencyCall being false.
     */
     */
    default void setRadioPower(boolean power, boolean forEmergencyCall,
    default void setRadioPower(boolean power, boolean forEmergencyCall,
            boolean isSelectedPhoneForEmergencyCall, boolean forceApply) {}
            boolean isSelectedPhoneForEmergencyCall, boolean forceApply) {
        setRadioPowerForReason(power, forEmergencyCall, isSelectedPhoneForEmergencyCall, forceApply,
                RADIO_POWER_REASON_USER);
    }

    /**
     * Sets the radio power on/off state (off is sometimes
     * called "airplane mode") for the specified reason, if possible. Current state can be gotten
     * via {@link #getServiceState()}.{@link
     * android.telephony.ServiceState#getState() getState()}.
     * <strong>Note: </strong>This request is asynchronous.
     * getServiceState().getState() will not change immediately after this call.
     * registerForServiceStateChanged() to find out when the
     * request is complete. Radio power will not be set if it is currently off for a reason other
     * than the reason for which it is being turned on. However, if forEmergency call is {@code
     * true}, it will forcefully turn radio power on.
     *
     * @param power true means "on", false means "off".
     * @param reason RadioPowerReason constant defining the reason why the radio power was set.
     */
    default void setRadioPowerForReason(boolean power, @RadioPowerReason int reason) {
        setRadioPowerForReason(power, false, false, false, reason);
    }

    /**
     * Sets the radio power on/off state with option to specify whether it's for emergency call
     * (off is sometimes called "airplane mode") and option to set the reason for setting the power
     * state. Current state can be gotten via {@link #getServiceState()}.
     * {@link android.telephony.ServiceState#getState() getState()}.
     * <strong>Note: </strong>This request is asynchronous.
     * getServiceState().getState() will not change immediately after this call.
     * registerForServiceStateChanged() to find out when the
     * request is complete. Radio power will not be set if it is currently off for a reason other
     * than the reason for which it is being turned on. However, if forEmergency call is {@code
     * true}, it will forcefully turn radio power on.
     *
     * @param power true means "on", false means "off".
     * @param forEmergencyCall true means the purpose of turning radio power on is for emergency
     *                         call. No effect if power is set false.
     * @param isSelectedPhoneForEmergencyCall true means this phone / modem is selected to place
     *                                  emergency call after turning power on. No effect if power
     *                                  or forEmergency is set false.
     * @param forceApply true means always call setRadioPower HAL API without checking against
     *                   current radio power state. It's needed when: radio was powered on into
     *                   emergency call mode, to exit from that mode, we set radio
     *                   power on again with forEmergencyCall being false.
     * @param reason RadioPowerReason constant defining the reason why the radio power was set.
     */
    default void setRadioPowerForReason(boolean power, boolean forEmergencyCall,
            boolean isSelectedPhoneForEmergencyCall, boolean forceApply,
            @RadioPowerReason int reason) {}


    /**
    /**
     * Get the line 1 phone number (MSISDN). For CDMA phones, the MDN is returned
     * Get the line 1 phone number (MSISDN). For CDMA phones, the MDN is returned
+5 −5
Original line number Original line Diff line number Diff line
@@ -4862,11 +4862,11 @@ public class RIL extends BaseCommands implements CommandsInterface {
     * @param workSource calling Worksource
     * @param workSource calling Worksource
     * @param dataThrottlingAction the DataThrottlingAction that is being requested. Defined in
     * @param dataThrottlingAction the DataThrottlingAction that is being requested. Defined in
     *      android.hardware.radio@1.6.types.
     *      android.hardware.radio@1.6.types.
     * @param completionWindowSecs seconds in which full throttling has to be achieved.
     * @param completionWindowMillis milliseconds in which full throttling has to be achieved.
     */
     */
    @Override
    @Override
    public void setDataThrottling(Message result, WorkSource workSource, int dataThrottlingAction,
    public void setDataThrottling(Message result, WorkSource workSource, int dataThrottlingAction,
            int completionWindowSecs) {
            long completionWindowMillis) {
        IRadio radioProxy = getRadioProxy(result);
        IRadio radioProxy = getRadioProxy(result);
        if (radioProxy != null) {
        if (radioProxy != null) {
            if (mRadioVersion.less(RADIO_HAL_VERSION_1_6)) {
            if (mRadioVersion.less(RADIO_HAL_VERSION_1_6)) {
@@ -4887,12 +4887,12 @@ public class RIL extends BaseCommands implements CommandsInterface {
                riljLog(rr.serialString() + "> "
                riljLog(rr.serialString() + "> "
                        + requestToString(rr.mRequest)
                        + requestToString(rr.mRequest)
                        + " dataThrottlingAction = " + dataThrottlingAction
                        + " dataThrottlingAction = " + dataThrottlingAction
                        + " completionWindowSecs " + completionWindowSecs);
                        + " completionWindowMillis " + completionWindowMillis);
            }
            }


            try {
            try {
                radioProxy16.setDataThrottling(rr.mSerial, dataThrottlingAction,
                radioProxy16.setDataThrottling(rr.mSerial, dataThrottlingAction,
                        completionWindowSecs);
                        completionWindowMillis);
            } catch (RemoteException | RuntimeException e) {
            } catch (RemoteException | RuntimeException e) {
                handleRadioProxyExceptionForRR(rr, "setDataThrottling", e);
                handleRadioProxyExceptionForRR(rr, "setDataThrottling", e);
            }
            }
Loading