chromium/chrome/common/chromeos/extensions/api/telemetry.idl

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Use the <code>chrome.os.telemetry</code> API to get telemetry data.
[implemented_in = "chrome/browser/chromeos/extensions/telemetry/api/telemetry/telemetry_api.h"]
namespace os.telemetry {
// Note: Please update documentation as well when this interface is changed.
// The documentation lives here: //docs/telemetry_extension/api_overview.md.
// LINT.IfChange

  dictionary AudioInputNodeInfo {
    double? id;
    DOMString? name;
    DOMString? deviceName;
    boolean? active;
    long? nodeGain;
  };

  dictionary AudioOutputNodeInfo {
    double? id;
    DOMString? name;
    DOMString? deviceName;
    boolean? active;
    long? nodeVolume;
  };

  dictionary AudioInfo {
    boolean? outputMute;
    boolean? inputMute;
    long? underruns;
    long? severeUnderruns;
    AudioOutputNodeInfo[] outputNodes;
    AudioInputNodeInfo[] inputNodes;
  };

  callback AudioInfoCallback = void (AudioInfo audioInfo);

  dictionary BatteryInfo {
    double? cycleCount;
    double? voltageNow;
    DOMString? vendor;
    DOMString? serialNumber;
    double? chargeFullDesign;
    double? chargeFull;
    double? voltageMinDesign;
    DOMString? modelName;
    double? chargeNow;
    double? currentNow;
    DOMString? technology;
    DOMString? status;
    DOMString? manufactureDate;
    double? temperature;
  };

  callback BatteryInfoCallback = void (BatteryInfo batteryInfo);

  dictionary NonRemovableBlockDeviceInfo {
    DOMString? name;
    DOMString? type;
    double? size;
  };

  dictionary NonRemovableBlockDeviceInfoResponse {
    NonRemovableBlockDeviceInfo[] deviceInfos;
  };

  callback NonRemovableBlockDevicesInfoCallback = void (
      NonRemovableBlockDeviceInfoResponse deviceInfoResponse);

  enum CpuArchitectureEnum {
    unknown,
    x86_64,
    aarch64,
    armv7l
  };

  dictionary CpuCStateInfo {
    // Name of the state.
    DOMString? name;
    // Time spent in the state since the last reboot, in microseconds.
    double? timeInStateSinceLastBootUs;
  };

  dictionary LogicalCpuInfo {
    // The max CPU clock speed in kHz.
    long? maxClockSpeedKhz;
    // Maximum frequency the CPU is allowed to run at, by policy.
    long? scalingMaxFrequencyKhz;
    // Current frequency the CPU is running at.
    long? scalingCurrentFrequencyKhz;
    // Idle time since last boot, in milliseconds.
    double? idleTimeMs;
    // Information about the logical CPU's time in various C-states.
    CpuCStateInfo[] cStates;
    // The core number this logical CPU corresponds to.
    long? coreId;
  };

  dictionary PhysicalCpuInfo {
    DOMString? modelName;
    LogicalCpuInfo[] logicalCpus;
  };

  dictionary CpuInfo {
    long? numTotalThreads;
    CpuArchitectureEnum architecture;
    PhysicalCpuInfo[] physicalCpus;
  };

  callback CpuInfoCallback = void (CpuInfo cpuInfo);

  // An enumeration of display input type.
  enum DisplayInputType {
    // Unknown enum value.
    unknown,
    // Digital input.
    digital,
    // Analog input.
    analog
  };

  dictionary EmbeddedDisplayInfo {
    // Privacy screen is supported or not.
    boolean? privacyScreenSupported;
    // Privacy screen is enabled or not.
    boolean? privacyScreenEnabled;
    // Display width in millimeters.
    long? displayWidth;
    // Display height in millimeters.
    long? displayHeight;
    // Horizontal resolution.
    long? resolutionHorizontal;
    // Vertical resolution.
    long? resolutionVertical;
    // Refresh rate.
    double? refreshRate;
    // Three letter manufacturer ID.
    DOMString? manufacturer;
    // Manufacturer product code.
    long? modelId;
    // 32 bits serial number.
    long? serialNumber;
    // Week of manufacture.
    long? manufactureWeek;
    // Year of manufacture.
    long? manufactureYear;
    // EDID version.
    DOMString? edidVersion;
    // Digital or analog input.
    DisplayInputType inputType;
    // Name of display product.
    DOMString? displayName;
  };

  dictionary ExternalDisplayInfo {
    // Display width in millimeters.
    long? displayWidth;
    // Display height in millimeters.
    long? displayHeight;
    // Horizontal resolution.
    long? resolutionHorizontal;
    // Vertical resolution.
    long? resolutionVertical;
    // Refresh rate.
    double? refreshRate;
    // Three letter manufacturer ID.
    DOMString? manufacturer;
    // Manufacturer product code.
    long? modelId;
    // 32 bits serial number.
    long? serialNumber;
    // Week of manufacture.
    long? manufactureWeek;
    // Year of manufacture.
    long? manufactureYear;
    // EDID version.
    DOMString? edidVersion;
    // Digital or analog input.
    DisplayInputType inputType;
    // Name of display product.
    DOMString? displayName;
  };

  dictionary DisplayInfo {
    // Embedded display info.
    EmbeddedDisplayInfo embeddedDisplay;
    // External display info.
    ExternalDisplayInfo[] externalDisplays;
  };

  callback DisplayInfoCallback = void (DisplayInfo displayInfo);

  dictionary MarketingInfo {
    DOMString? marketingName;
  };

  callback MarketingInfoCallback = void (MarketingInfo marketingInfo);

  dictionary MemoryInfo {
    long? totalMemoryKiB;
    long? freeMemoryKiB;
    long? availableMemoryKiB;
    double? pageFaultsSinceLastBoot;
  };

  callback MemoryInfoCallback = void (MemoryInfo cpuInfo);

  enum NetworkType {
    cellular,
    ethernet,
    tether,
    vpn,
    wifi
  };

  enum NetworkState {
    // The network type is available but not yet initialized.
    uninitialized,
    // The network type is available but disabled or disabling.
    disabled,
    // The network type is prohibited by policy.
    prohibited,
    // The network type is available and enabled or enabling, but no network
    // connection has been established.
    not_connected,
    // The network type is available and enabled, and a network connection is in
    // progress.
    connecting,
    // The network is in a portal state.
    portal,
    // The network is in a connected state, but connectivity is limited.
    connected,
    // The network is connected and online.
    online
  };

  dictionary NetworkInfo {
    NetworkType? type;
    NetworkState? state;
    DOMString? macAddress;
    DOMString? ipv4Address;
    DOMString[] ipv6Addresses;
    double? signalStrength;
  };

  dictionary InternetConnectivityInfo {
    NetworkInfo[] networks;
  };

  callback InternetConnectivityInfoCallback = void (
      InternetConnectivityInfo networkInfo);

  dictionary OemData {
    // OEM data. This field used to store battery serial number by some OEMs.
    DOMString? oemData;
  };

  callback OemDataCallback = void (OemData oemData);

  dictionary OsVersionInfo {
    DOMString? releaseMilestone;
    DOMString? buildNumber;
    DOMString? patchNumber;
    DOMString? releaseChannel;
  };

  callback OsVersionInfoCallback = void (OsVersionInfo osVersionInfo);

  // The info related to usb interfaces.
  dictionary UsbBusInterfaceInfo {
    // The zero-based number (index) of the interface.
    double? interfaceNumber;
    // These fields can be used to classify / identify the usb interfaces. See
    // the usb.ids database for the values. (https://github.com/gentoo/hwids)
    double? classId;
    double? subclassId;
    double? protocolId;
    // The driver used by the device. This is the name of the matched driver
    // which is registered in the kernel. See "{kernel root}/drivers/" for the
    // list of the built in drivers.
    DOMString? driver;
  };

  // An enumeration of the formats of firmware version in fwpud. See the fwupd
  // repo for the values. (https://github.com/fwupd/fwupd)
  enum FwupdVersionFormat {
    // An unidentified format text string.
    plain,
    // A single integer version number.
    number,
    // Two AABB.CCDD version numbers.
    pair,
    // Microsoft-style AA.BB.CCDD version numbers.
    triplet,
    // UEFI-style AA.BB.CC.DD version numbers.
    quad,
    // Binary coded decimal notation.
    bcd,
    // Intel ME-style bitshifted notation.
    intelMe,
    // Intel ME-style A.B.CC.DDDD notation.
    intelMe2,
    // Legacy Microsoft Surface 10b.12b.10b.
    surfaceLegacy,
    // Microsoft Surface 8b.16b.8b.
    surface,
    // Dell BIOS BB.CC.DD style.
    dellBios,
    // Hexadecimal 0xAABCCDD style.
    hex
  };

  // The info related to a firmware version obtained from fwupd.
  dictionary FwupdFirmwareVersionInfo {
    // The string form of the firmware version.
    DOMString? version;
    // The format for parsing the version string.
    FwupdVersionFormat? version_format;
  };

  enum UsbVersion {
    // Can't determine the usb version.
    unknown,
    // Usb 1.
    usb1,
    // Usb 2.
    usb2,
    // Usb 3.
    usb3
  };

  // An enumeration of the usb spec speed in Mbps.
  // Source:
  //   - https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-bus-usb
  //   - https://www.kernel.org/doc/Documentation/ABI/stable/sysfs-bus-usb
  //   - https://en.wikipedia.org/wiki/USB
  //
  enum UsbSpecSpeed {
    // Unknown speed.
    unknown,
    // Low speed.
    n1_5Mbps,
    // Full speed.
    n12Mbps,
    // High Speed.
    n480Mbps,
    // Super Speed.
    n5Gbps,
    // Super Speed+.
    n10Gbps,
    // Super Speed+ Gen 2x2.
    n20Gbps
  };

  // The info related to usb.
  dictionary UsbBusInfo {
    // These fields can be used to classify / identify the usb devices. See the
    // usb.ids database for the values. (https://github.com/gentoo/hwids)
    double? classId;
    double? subclassId;
    double? protocolId;
    double? vendorId;
    double? productId;
    // The usb interfaces under the device. A usb device has at least one
    // interface. Each interface may or may not work independently, based on
    // each device. This allows a usb device to provide multiple features.
    // The interfaces are sorted by the `interface_number` field.
    UsbBusInterfaceInfo[] interfaces;
    // The firmware version obtained from fwupd.
    FwupdFirmwareVersionInfo? fwupdFirmwareVersionInfo;
    // The recognized usb version. It may not be the highest USB version
    // supported by the hardware.
    UsbVersion? version;
    // The spec usb speed.
    UsbSpecSpeed? spec_speed;
  };

  dictionary UsbBusDevices {
    UsbBusInfo[] devices;
  };

  callback UsbBusDevicesCallback = void (UsbBusDevices UsbBusDevices);

  dictionary VpdInfo {
    // Device activate date. Format: YYYY-WW.
    DOMString? activateDate;

    // Device model name.
    DOMString? modelName;

    // Device serial number.
    DOMString? serialNumber;

    // Device SKU number, a.k.a. model number.
    DOMString? skuNumber;
  };

  callback VpdInfoCallback = void (VpdInfo vpdInfo);

  dictionary StatefulPartitionInfo {
    double? availableSpace;
    double? totalSpace;
  };

  callback StatefulPartitionInfoCallback = void (
      StatefulPartitionInfo statefulPartitionInfo);

  enum ThermalSensorSource {
    unknown,
    ec,
    sysFs
  };

  dictionary ThermalSensorInfo {
    // Name of the thermal sensor.
    DOMString? name;
    // Temperature detected by the thermal sensor in celsius.
    double? temperatureCelsius;
    // Where the thermal sensor is detected from.
    ThermalSensorSource? source;
  };

  dictionary ThermalInfo {
    // An array containing all the information retrieved for thermal sensors.
    ThermalSensorInfo[] thermalSensors;
  };

  callback ThermalInfoCallback = void (ThermalInfo thermalInfo);

  enum TpmGSCVersion {
    not_gsc,
    cr50,
    ti50
  };

  dictionary TpmVersion {
    // GSC version.
    TpmGSCVersion? gscVersion;
    // TPM family. We use the TPM 2.0 style encoding, e.g.:
    //  * TPM 1.2: "1.2" -> 0x312e3200
    //  * TPM 2.0: "2.0" -> 0x322e3000
    long? family;
    // TPM spec level.
    double? specLevel;
    // Manufacturer code.
    long? manufacturer;
    // TPM model number.
    long? tpmModel;
    // Firmware version.
    double? firmwareVersion;
    // Vendor specific information.
    DOMString? vendorSpecific;
  };

  dictionary TpmStatus {
    // Whether a TPM is enabled on the system.
    boolean? enabled;
    // Whether the TPM has been owned.
    boolean? owned;
    // Whether the owner password is still retained.
    boolean? ownerPasswordIsPresent;
  };

  dictionary TpmDictionaryAttack {
    // The current dictionary attack counter value.
    long? counter;
    // The current dictionary attack counter threshold.
    long? threshold;
    // Whether the TPM is in some form of dictionary attack lockout.
    boolean? lockoutInEffect;
    // The number of seconds remaining in the lockout.
    long? lockoutSecondsRemaining;
  };

  dictionary TpmInfo {
    // TPM version related information.
    TpmVersion version;
    // TPM status related information.
    TpmStatus status;
    // TPM dictionary attack (DA) related information.
    TpmDictionaryAttack dictionaryAttack;
  };

  callback TpmInfoCallback = void (TpmInfo tpmInfo);

  interface Functions {
    static void getAudioInfo(AudioInfoCallback callback);

    static void getBatteryInfo(BatteryInfoCallback callback);

    static void getNonRemovableBlockDevicesInfo(
        NonRemovableBlockDevicesInfoCallback callback);

    static void getCpuInfo(CpuInfoCallback callback);

    static void getInternetConnectivityInfo(
        InternetConnectivityInfoCallback callback);

    static void getMarketingInfo(MarketingInfoCallback callback);

    static void getMemoryInfo(MemoryInfoCallback callback);

    static void getOemData(OemDataCallback callback);

    static void getOsVersionInfo(OsVersionInfoCallback callback);

    static void getUsbBusInfo(UsbBusDevicesCallback callback);

    static void getVpdInfo(VpdInfoCallback callback);

    static void getStatefulPartitionInfo(
        StatefulPartitionInfoCallback callback);

    static void getTpmInfo(TpmInfoCallback callback);

    static void getDisplayInfo(DisplayInfoCallback callback);

    static void getThermalInfo(ThermalInfoCallback callback);
  };

  // LINT.ThenChange(//docs/telemetry_extension/api_overview.md)
  // The following is an empty definition, since the IDL compiler only accepts
  // comments over valid definitions.
  callback EOF = void();
};