/*
 * 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.fastboot@1.0;

/**
 * IFastboot interface implements vendor specific fastboot commands.
 */
interface IFastboot {
    /**
     * Returns the file system type of the partition. This is only required for
     * physical partitions that need to be wiped and reformatted.
     *
     * @return type Can be ext4, f2fs or raw.
     * @return result SUCCESS if the operation is successful,
     *     FAILURE_UNKNOWN if the partition is invalid or does not require
     *     reformatting.
     */
    getPartitionType(string partitionName) generates (FileSystemType type, Result result);

    /**
     * Executes a fastboot OEM command.
     *
     * @param oemCmd The oem command that is passed to the fastboot HAL.
     * @return result Returns the status SUCCESS if the operation is successful,
     *     INVALID_ARGUMENT for bad arguments,
     *     FAILURE_UNKNOWN for an invalid/unsupported command.
     */
    doOemCommand(string oemCmd) generates (Result result);

    /**
     * Returns an OEM-defined string indicating the variant of the device, for
     * example, US and ROW.
     *
     * @return variant Indicates the device variant.
     * @return result Returns the status SUCCESS if the operation is successful,
     *     FAILURE_UNKNOWN otherwise.
     */
    getVariant() generates (string variant, Result result);

    /**
     * Returns whether off-mode-charging is enabled. If enabled, the device
     * autoboots into a special mode when power is applied.
     *
     * @return state Returns whether off mode charging is enabled.
     * @return result Returns the status SUCCESS if the operation is successful,
     *     FAILURE_UNKNOWN otherwise.
     */
    getOffModeChargeState() generates (bool state, Result result);

    /**
     * Returns the minimum battery voltage required for flashing in mV.
     *
     * @return batteryVoltage Minimum batterery voltage (in mV) required for
     *     flashing to be successful.
     * @return result Returns the status SUCCESS if the operation is successful,
     *     FAILURE_UNKNOWN otherwise.
     */
    getBatteryVoltageFlashingThreshold() generates (int32_t batteryVoltage, Result result);
};
