/*
 * Copyright (C) 2020 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.6;

import @1.0::RadioIndicationType;
import @1.5::IRadioIndication;
import @1.6::CellInfo;
import @1.6::LinkCapacityEstimate;
import @1.6::NetworkScanResult;
import @1.6::SignalStrength;
import @1.6::SetupDataCallResult;
import @1.6::PbReceivedStatus;
import @1.6::PhysicalChannelConfig;
import @1.6::PhonebookRecordInfo;

/**
 * Interface declaring unsolicited radio indications.
 */
interface IRadioIndication extends @1.5::IRadioIndication {

    /**
     * Indicates data call contexts have changed.
     *
     * This indication is updated from IRadioIndication@1.5 to report the @1.6 version of
     * SetupDataCallResult.
     *
     * @param type Type of radio indication
     * @param dcList Array of SetupDataCallResult identical to that returned by
     *        IRadio.getDataCallList(). It is the complete list of current data contexts including
     *        new contexts that have been activated. A data call is only removed from this list
     *        when any of the below conditions is matched.
     *        1. The framework sends a IRadio.deactivateDataCall().
     *        2. The radio is powered off/on.
     *        3. Unsolicited disconnect from either modem or network side.
     */
    oneway dataCallListChanged_1_6(RadioIndicationType type, vec<SetupDataCallResult> dcList);

    /**
     * The modem can explicitly set SetupDataCallResult::suggestedRetryTime after a failure in
     * IRadio@1.6::SetupDataCall. During that time, no new calls are allowed to
     * IRadio@1.6::SetupDataCall that use the same APN.
     *
     * When IRadioIndication@1.6::unthrottleApn is sent, AOSP will no longer throttle calls
     * to IRadio@1.6::SetupDataCall for the given APN.
     *
     * @param type Type of radio indication
     * @param apn Apn to unthrottle
     */
    oneway unthrottleApn(RadioIndicationType type, string apn);

    /**
     * Indicates current link capacity estimate.
     * This replaces @1.2::IRadioIndication.currentLinkCapacityEstimate().
     * This indication is sent whenever the reporting criteria, as set by
     * @1.2::IRadio.setLinkCapacityReportingCriteria, are met and the indication is not
     * suppressed by @1.2::IRadio.setIndicationFilter_1_2().
     *
     * @param type Type of radio indication
     * @param lce LinkCapacityEstimate
     */
    oneway currentLinkCapacityEstimate_1_6(RadioIndicationType type, LinkCapacityEstimate lce);

    /**
     * Indicates current signal strength of the radio.
     *
     * This is identical to currentSignalStrength_1_4 but uses an updated version of
     * SignalStrength.
     *
     * @param type Type of radio indication
     * @param signalStrength SignalStrength information
     */
    oneway currentSignalStrength_1_6(RadioIndicationType type, SignalStrength signalStrength);

    /**
     * Report all of the current cell information known to the radio.
     *
     * This indication is updated from IRadioIndication@1.5 to report the @1.6 version of
     * CellInfo.
     *
     * @param type Type of radio indication
     * @param records Current cell information
     */
    oneway cellInfoList_1_6(RadioIndicationType type, vec<CellInfo> records);

    /**
     * Incremental network scan results.
     *
     * This indication is updated from IRadioIndication@1.5 to report the @1.6 version of
     * CellInfo.
     */
    oneway networkScanResult_1_6(RadioIndicationType type, NetworkScanResult result);

    /**
     * Indicates physical channel configurations.
     *
     * An empty configs list shall be returned when the radio is in idle mode (i.e. RRC idle).
     *
     * @param type Type of radio indication
     * @param configs Vector of PhysicalChannelConfigs
     */
    oneway currentPhysicalChannelConfigs_1_6(RadioIndicationType type,
            vec<PhysicalChannelConfig> configs);

    /**
     * Indicates whether SIM phonebook is changed.
     *
     * This indication is sent whenever the SIM phonebook is changed, including SIM is
     * inserted or removed and updated by IRadio.updateSimPhonebookRecords.
     *
     * @param type Type of radio indication
     */
    oneway simPhonebookChanged(RadioIndicationType type);

    /**
     * Indicates the content of all the used records in the SIM phonebook.
     *
     * This indication is associated with the API getSimPhonebookRecords and
     * might be received more than once that is replying on the record count.
     *
     * @param type Type of radio indication
     * @param status Status of PbReceivedStatus
     * @param records Vector of PhonebookRecordInfo
     */
    oneway simPhonebookRecordsReceived(RadioIndicationType type,
            PbReceivedStatus status, vec<PhonebookRecordInfo> records);
};
