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

Commit 7ed2706d authored by Sarah Chin's avatar Sarah Chin Committed by Gerrit Code Review
Browse files

Merge "Add RIL Interface for UsageSetting"

parents 2c423a88 c51af7c9
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -2750,4 +2750,20 @@ public interface CommandsInterface {
     * @param h Handler to be removed from the registrant list.
     */
     public void unregisterForSimPhonebookRecordsReceived(Handler h);

    /**
     * Set the UE's usage setting.
     *
     * @param result Callback message containing the success or failure status.
     * @param usageSetting the UE's usage setting, either VOICE_CENTRIC or DATA_CENTRIC.
     */
    default void setUsageSetting(Message result,
            /* @TelephonyManager.UsageSetting */ int usageSetting) {}

    /**
     * Get the UE's usage setting.
     *
     * @param result Callback message containing the usage setting (or a failure status).
     */
    default void getUsageSetting(Message result) {}
}
+16 −0
Original line number Diff line number Diff line
@@ -448,4 +448,20 @@ public class NetworkResponse extends IRadioNetworkResponse.Stub {
            int retriesRemaining) {
        RadioResponse.responseInts(mRil, responseInfo, retriesRemaining);
    }

    /**
     * @param responseInfo Response info struct containing response type, serial no. and error
     */
    public void setUsageSettingResponse(RadioResponseInfo responseInfo) {
        RadioResponse.responseVoid(mRil, responseInfo);
    }

    /**
     * @param responseInfo Response info struct containing response type, serial no. and error
     * @param usageSetting the cellular usage setting
     */
    public void getUsageSettingResponse(RadioResponseInfo responseInfo,
            /* @TelephonyManager.UsageSetting */ int usageSetting) {
        RadioResponse.responseInts(mRil, responseInfo, usageSetting);
    }
}
+70 −0
Original line number Diff line number Diff line
@@ -4971,6 +4971,76 @@ public class RIL extends BaseCommands implements CommandsInterface {
        }
    }

    /**
     * Set the UE's usage setting.
     *
     * @param result Callback message containing the success or failure status.
     * @param usageSetting the UE's usage setting, either VOICE_CENTRIC or DATA_CENTRIC.
     */
    @Override
    public void setUsageSetting(Message result,
            /* @TelephonyManager.UsageSetting */ int usageSetting) {
        RadioNetworkProxy networkProxy = getRadioServiceProxy(RadioNetworkProxy.class, result);
        if (networkProxy.isEmpty()) return;
        if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_2_0)) {
            RILRequest rr = obtainRequest(RIL_REQUEST_SET_USAGE_SETTING, result,
                    mRILDefaultWorkSource);

            if (RILJ_LOGD) {
                riljLog(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest));
            }

            try {
                networkProxy.setUsageSetting(rr.mSerial, usageSetting);
            } catch (RemoteException | RuntimeException e) {
                handleRadioProxyExceptionForRR(NETWORK_SERVICE, "setUsageSetting", e);
            }
        } else {
            if (RILJ_LOGD) {
                Rlog.d(RILJ_LOG_TAG, "setUsageSetting: REQUEST_NOT_SUPPORTED");
            }
            if (result != null) {
                AsyncResult.forMessage(result, null,
                        CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED));
                result.sendToTarget();
            }
        }
    }

    /**
     * Get the UE's usage setting.
     *
     * @param result Callback message containing the usage setting (or a failure status).
     */
    @Override
    public void getUsageSetting(Message result) {
        RadioNetworkProxy networkProxy = getRadioServiceProxy(RadioNetworkProxy.class, result);
        if (networkProxy.isEmpty()) return;
        if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_2_0)) {
            RILRequest rr = obtainRequest(RIL_REQUEST_GET_USAGE_SETTING, result,
                    mRILDefaultWorkSource);

            if (RILJ_LOGD) {
                riljLog(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest));
            }

            try {
                networkProxy.getUsageSetting(rr.mSerial);
            } catch (RemoteException | RuntimeException e) {
                handleRadioProxyExceptionForRR(NETWORK_SERVICE, "getUsageSetting", e);
            }
        } else {
            if (RILJ_LOGD) {
                Rlog.d(RILJ_LOG_TAG, "getUsageSetting: REQUEST_NOT_SUPPORTED");
            }
            if (result != null) {
                AsyncResult.forMessage(result, null,
                        CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED));
                result.sendToTarget();
            }
        }
    }

    //***** Private Methods
    /**
     * This is a helper function to be called when an indication callback is called for any radio
+6 −0
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_SLOT_S
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_SMSC_ADDRESS;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_SYSTEM_SELECTION_CHANNELS;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_UICC_APPLICATIONS_ENABLEMENT;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_USAGE_SETTING;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GSM_BROADCAST_ACTIVATION;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GSM_GET_BROADCAST_CONFIG;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GSM_SET_BROADCAST_CONFIG;
@@ -173,6 +174,7 @@ import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SET_TTY_MO
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SET_UICC_SUBSCRIPTION;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SET_USAGE_SETTING;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SHUTDOWN;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SIGNAL_STRENGTH;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SIM_AUTHENTICATION;
@@ -4934,6 +4936,10 @@ public class RILUtils {
                return "ENABLE_VONR";
            case RIL_REQUEST_IS_VONR_ENABLED:
                return "IS_VONR_ENABLED";
            case RIL_REQUEST_SET_USAGE_SETTING:
                return "SET_USAGE_SETTING";
            case RIL_REQUEST_GET_USAGE_SETTING:
                return "GET_USAGE_SETTING";
            default:
                return "<unknown request " + request + ">";
        }
+27 −0
Original line number Diff line number Diff line
@@ -789,4 +789,31 @@ public class RadioNetworkProxy extends RadioServiceProxy {
            mRadioProxy.supplyNetworkDepersonalization(serial, netPin);
        }
    }

    /**
     * Call IRadioNetwork#getUsageSetting()
     * @param serial Serial number of request
     * @throws RemoteException
     */
    public void getUsageSetting(int serial) throws RemoteException {
        if (isEmpty()) return;
        if (isAidl()) {
            mNetworkProxy.getUsageSetting(serial);
        }
        // Only supported on AIDL.
    }

    /**
     * Call IRadioNetwork#setUsageSetting()
     * @param serial Serial number of request
     * @throws RemoteException
     */
    public void setUsageSetting(int serial,
            /* TelephonyManager.UsageSetting */ int usageSetting) throws RemoteException {
        if (isEmpty()) return;
        if (isAidl()) {
            mNetworkProxy.setUsageSetting(serial, usageSetting);
        }
        // Only supported on AIDL.
    }
}