/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.radio@1.3;

import @1.2::IRadio;
import @1.1::RadioAccessSpecifier;

/**
 * Note: IRadio 1.3 is an intermediate layer between Android P and Android Q. It's specifically
 * designed for CBRS related interfaces. All other interfaces for Q are added in IRadio 1.4.
 *
 * This interface is used by telephony and telecom to talk to cellular radio.
 * All the functions have minimum one parameter:
 * serial: which corresponds to serial no. of request. Serial numbers must only be memorized for the
 * duration of a method call. If clients provide colliding serials (including passing the same
 * serial to different methods), multiple responses (one for each method call) must still be served.
 * setResponseFunctions must work with @1.1::IRadioResponse and @1.1::IRadioIndication.
 */
interface IRadio extends @1.2::IRadio {
    /**
     * Specify which bands modem's background scan must act on.
     * If specifyChannels is true, it only scans bands specified in specifiers.
     * If specifyChannels is false, it scans all bands.
     *
     * For example, CBRS is only on LTE band 48. By specifying this band,
     * modem saves more power.
     *
     * @param serial Serial number of request.
     * @param specifyChannels whether to scan bands defined in specifiers.
     * @param specifiers which bands to scan. Only used if specifyChannels is true.
     *
     * Response callback is IRadioResponse.setSystemSelectionChannelsResponse()
     */
    oneway setSystemSelectionChannels(int32_t serial, bool specifyChannels,
            vec<RadioAccessSpecifier> specifiers);

   /**
    * Toggle logical modem on/off. This is similar to @1.0::IRadio.setRadioPower(), however that
    * does not enforce that radio power is toggled only for the corresponding radio and certain
    * vendor implementations do it for all radios. This new API should affect only the modem for
    * which it is called. A modem stack must be on/active only when both setRadioPower() and
    * enableModem() are set to on for it.
    *
    * SIM must be read if available even if modem is off/inactive.
    *
    * @param serial Serial number of request.
    * @param on True to turn on the logical modem, otherwise turn it off.
    *
    * Response function is IRadioResponse.enableModemResponse()
    */
    oneway enableModem(int32_t serial, bool on);

   /**
    * Request status of logical modem. It returns isEnabled=true if the logical modem is on.
    * This method is the getter method for enableModem.
    *
    * @param serial Serial number of request.
    *
    * Response function is IRadioResponse.getModemStackStatusResponse()
    */
    oneway getModemStackStatus(int32_t serial);
};