// Copyright 2020 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Definitions for the event API exposed by the cros_healthd daemon. This API is // normally consumed by the browser. // NOTE: This mojom should be kept in sync with the copy in Chromium OS's repo // in src/platform2/diagnostics/mojom/public/cros_healthd_events.mojom. module ash.cros_healthd.mojom; import "ash/system/diagnostics/mojom/input.mojom"; import "chromeos/ash/services/cros_healthd/public/mojom/cros_healthd_probe.mojom"; import "chromeos/ash/services/cros_healthd/public/mojom/nullable_primitives.mojom"; import "mojo/public/mojom/base/time.mojom"; // Implemented by clients who desire Bluetooth notifications. // // NextMinVersion: 1, NextIndex: 6 [Stable] interface CrosHealthdBluetoothObserver { // Fired when a Bluetooth adapter is added. OnAdapterAdded@0(); // Fired when a Bluetooth adapter is removed. OnAdapterRemoved@1(); // Fired when a property of a Bluetooth adapter is changed. OnAdapterPropertyChanged@2(); // Fired when a Bluetooth device is added. OnDeviceAdded@3(); // Fired when a Bluetooth device is removed. OnDeviceRemoved@4(); // Fired when a property of a Bluetooth device is changed. OnDevicePropertyChanged@5(); }; // Implemented by clients who desire lid notifications. // // NextMinVersion: 1, NextIndex: 2 [Stable] interface CrosHealthdLidObserver { // Fired when the device's lid is closed. OnLidClosed@0(); // Fired when the device's lid is opened. OnLidOpened@1(); }; // Implemented by clients who desire power notifications. // // NextMinVersion: 1, NextIndex: 4 [Stable] interface CrosHealthdPowerObserver { // Fired when the device begins consuming from an external power source. OnAcInserted@0(); // Fired when the device stops consuming from an external power source. OnAcRemoved@1(); // Fired when the system receives a suspend request. OnOsSuspend@2(); // Fired when the system completes a suspend request. OnOsResume@3(); }; // Implemented by clients who desire audio notifications. // // NextMinVersion: 1, NextIndex: 2 [Stable] interface CrosHealthdAudioObserver { // Fired when the audio underrun happens. OnUnderrun@0(); // Fired when the audio severe underrun happens. OnSevereUnderrun@1(); }; // Implemented by clients who desire Thunderbolt notifications. // // NextMinVersion: 1, NextIndex: 4 [Stable] interface CrosHealthdThunderboltObserver { // Fired when the Thunderbolt plug in. OnAdd@0(); // Fired when the Thunderbolt plug out. OnRemove@1(); // Fired when the Thunderbolt device is authorized. OnAuthorized@2(); // Fired when the Thunderbolt device is unauthorized. OnUnAuthorized@3(); }; // USB event info. // // NextMinVersion: 2, NextIndex: 6 [Stable] struct UsbEventInfo { // Vendor name. string vendor@0; // Name, model name or product name. string name@1; // Vendor ID. uint16 vid@2; // Product ID. uint16 pid@3; // USB device categories. // https://www.usb.org/defined-class-codes array categories@4; [Stable, Extensible] enum State { // This is required for backwards compatibility, should not be used. [Default] kUnmappedEnumField = 0, // USB plugs in. kAdd = 1, // USB unplugs. kRemove = 2, }; [MinVersion=1] State state@5; }; // Implemented by clients who desire USB notifications. // // NextMinVersion: 1, NextIndex: 2 [Stable] interface CrosHealthdUsbObserver { // Fired when the USB plug in. OnAdd@0(UsbEventInfo info); // Fired when the USB plug out. OnRemove@1(UsbEventInfo info); }; // Implemented by clients who desire SD Card notifications. // // NextMinVersion: 1, NextIndex: 2 [Stable] interface CrosHealthdSdCardObserver { // Fired when the SD Card plug in. OnAdd@0(); // Fired when the SD Card plug out. OnRemove@1(); }; // Thunderbolt event info. // // NextMinVersion: 1, NextIndex: 1 [Stable] struct ThunderboltEventInfo { [Stable, Extensible] enum State { // This is required for backwards compatibility, should not be used. [Default] kUnmappedEnumField = 0, // Thunderbolt plug in. kAdd = 1, // Thunderbolt plug out. kRemove = 2, // Thunderbolt device is authorized. kAuthorized = 3, // Thunderbolt device is unauthorized. kUnAuthorized = 4, }; State state@0; }; // Lid event info. // // NextMinVersion: 1, NextIndex: 1 [Stable] struct LidEventInfo { [Stable, Extensible] enum State { // This is required for backwards compatibility, should not be used. [Default] kUnmappedEnumField = 0, // Lid closed. kClosed = 1, // Lid opened. kOpened = 2, }; State state@0; }; // Bluetooth event info. // // NextMinVersion: 1, NextIndex: 1 [Stable] struct BluetoothEventInfo { [Stable, Extensible] enum State { // This is required for backwards compatibility, should not be used. [Default] kUnmappedEnumField = 0, // Adapter is added. kAdapterAdded = 1, // Adapter is removed. kAdapterRemoved = 2, // Adapter property is changed. kAdapterPropertyChanged = 3, // Device is added. kDeviceAdded = 4, // Device is removed. kDeviceRemoved = 5, // Device property is changed. kDevicePropertyChanged = 6, }; State state@0; }; // Power event info. // // NextMinVersion: 1, NextIndex: 1 [Stable] struct PowerEventInfo { [Stable, Extensible] enum State { // This is required for backwards compatibility, should not be used. [Default] kUnmappedEnumField = 0, // Device begins consuming from an external power source. kAcInserted = 1, // Device stops consuming from an external power source. kAcRemoved = 2, // System receives a suspend request. kOsSuspend = 3, // System completes a suspend request. kOsResume = 4, }; State state@0; }; // Audio event info. // // NextMinVersion: 1, NextIndex: 1 [Stable] struct AudioEventInfo { [Stable, Extensible] enum State { // This is required for backwards compatibility, should not be used. [Default] kUnmappedEnumField = 0, // Audio underrun happens. kUnderrun = 1, // Audio severe underrun happens. kSevereUnderrun = 2, }; State state@0; }; // Audio jack event info. // // NextMinVersion: 2, NextIndex: 2 [Stable] struct AudioJackEventInfo { [Stable, Extensible] enum State { // This is required for backwards compatibility, should not be used. [Default] kUnmappedEnumField, // Audio jack added. kAdd, // Aduio jack removed. kRemove, }; State state@0; [Stable, Extensible] enum DeviceType { // This is required for backwards compatibility, should not be used. [Default] kUnmappedEnumField, // The device is a headphone. kHeadphone, // The device is a microphone. kMicrophone, }; [MinVersion=1] DeviceType device_type@1; }; // SD Card event info. // // NextMinVersion: 1, NextIndex: 1 [Stable] struct SdCardEventInfo { [Stable, Extensible] enum State { // This is required for backwards compatibility, should not be used. [Default] kUnmappedEnumField, // SD Card added. kAdd, // SD Card removed. kRemove, }; State state@0; }; // An enumeration of input touch buttons. // // NextMinVersion: 1, NextIndex: 4 [Stable, Extensible] enum InputTouchButton { // This is required for backwards compatibility, should not be used. [Default] kUnmappedEnumField = 0, // Left key. kLeft = 1, // Middle key. kMiddle = 2, // Right key. kRight = 3, }; // Emitted when some touchpad button is pressed or released. // // NextMinVersion: 1, NextIndex: 2 [Stable] struct TouchpadButtonEvent { // The button corresponds to this event. InputTouchButton button@0; // True when if the button is pressed. False if the button is released. bool pressed@1; }; // Touch point info. // // NextMinVersion: 1, NextIndex: 6 [Stable] struct TouchPointInfo { // An id to track an initiated contact throughout its life cycle. uint32 tracking_id@0; // The x position. uint32 x@1; // The y position. uint32 y@2; // The pressure applied to the touch contact. NullableUint32? pressure@3; // The length of the longer dimension of the touch contact. NullableUint32? touch_major@4; // The length of the shorter dimension of the touch contact. NullableUint32? touch_minor@5; }; // Emitted when new touch points are updated. // // NextMinVersion: 1, NextIndex: 1 [Stable] struct TouchpadTouchEvent { // The touch points reported by the touchpad. array touch_points@0; }; // Emitted once the observer get connected to the touchpad events. This will be // the first event from the touchpad. // // NextMinVersion: 1, NextIndex: 4 [Stable] struct TouchpadConnectedEvent { // The maximum possible x position of touch points. uint32 max_x@0; // The maximum possible y position of touch points. uint32 max_y@1; // The maximum possible pressure of touch points, or 0 if pressure is not // supported. uint32 max_pressure@2; // The supported buttons; array buttons@3; }; // Union of touchpad events. // // NextMinVersion: 1, NextIndex: 4 [Stable, Extensible] union TouchpadEventInfo { // The default value for forward compatibility. All the unknown type will be // mapped to this. [Default] uint8 default_type@0; TouchpadButtonEvent button_event@1; TouchpadTouchEvent touch_event@2; TouchpadConnectedEvent connected_event@3; }; // External Display event info. // // NextMinVersion: 1, NextIndex: 1 [Stable] struct ExternalDisplayEventInfo { [Stable, Extensible] enum State { // This is required for backwards compatibility, should not be used. [Default] kUnmappedEnumField, // External display plugs in. kAdd, // External display plugs out. kRemove, }; State state@0; // On external display event, also report information about the display. [MinVersion=1] ExternalDisplayInfo? display_info@1; }; // Emitted when new touch points are updated. // // NextMinVersion: 1, NextIndex: 1 [Stable] struct TouchscreenTouchEvent { // The touch points reported by the touchscreen. array touch_points@0; }; // Emitted once the observer get connected to the touchscreen events. This will // be the first event from the touchscreen. // // NextMinVersion: 1, NextIndex: 3 [Stable] struct TouchscreenConnectedEvent { // The maximum possible x position of touch points. uint32 max_x@0; // The maximum possible y position of touch points. uint32 max_y@1; // The maximum possible pressure of touch points, or 0 if pressure is not // supported. uint32 max_pressure@2; }; // Union of Touchscreen events. // // NextMinVersion: 1, NextIndex: 3 [Stable, Extensible] union TouchscreenEventInfo { // The default value for forward compatibility. All the unknown type will be // mapped to this. [Default] uint8 default_type@0; TouchscreenTouchEvent touch_event@1; TouchscreenConnectedEvent connected_event@2; }; // Stylus garage event info. // // NextMinVersion: 1, NextIndex: 1 [Stable] struct StylusGarageEventInfo { [Stable, Extensible] enum State { // This is required for backwards compatibility, should not be used. [Default] kUnmappedEnumField, // Stylus inserted into the garage. kInserted, // Stylus removed from the garage. kRemoved, }; State state@0; }; // Stylus touch point info. // // NextMinVersion: 1, NextIndex: 3 [Stable] struct StylusTouchPointInfo { // The x position. uint32 x@0; // The y position. uint32 y@1; // The pressure applied to the touch contact. NullableUint32? pressure@2; }; // Emitted when new touch point is updated. // // NextMinVersion: 1, NextIndex: 1 [Stable] struct StylusTouchEvent { // The info of the stylus touch point. A null touch point means the stylus // leaves the contact. StylusTouchPointInfo? touch_point@0; }; // Emitted once the observer get connected to the stylus events. This will be // the first event from the stylus. // // NextMinVersion: 1, NextIndex: 3 [Stable] struct StylusConnectedEvent { // The maximum possible x position of touch points. uint32 max_x@0; // The maximum possible y position of touch points. uint32 max_y@1; // The maximum possible pressure of touch points, or 0 if pressure is not // supported. uint32 max_pressure@2; }; // Union of stylus events. // // NextMinVersion: 1, NextIndex: 3 [Stable, Extensible] union StylusEventInfo { // The default value for forward compatibility. All the unknown type will be // mapped to this. [Default] uint8 default_type@0; StylusTouchEvent touch_event@1; StylusConnectedEvent connected_event@2; }; // Emitted within CrashEventInfo. Contains information available for uploaded // crash events only. // // NextMinVersion: 1, NextIndex: 3 [Stable] struct CrashUploadInfo { // Corresponding to "upload_id" in uploads.log. string crash_report_id@0; // The creation time of the uploads.log file. // Used to distinguish uploads.log file in case it has been deleted and // recreated. mojo_base.mojom.Time creation_time@1; // Number of valid logs before this event in uploads.log. Useful to inform // subscribers that need to distinguish whether a crash event has been // encountered before. uint64 offset@2; }; // Emitted once the observer gets new crash events. // // NextMinVersion: 1, NextIndex: 4 [Stable] struct CrashEventInfo { // NextMinVersion: 2, NextIndex: 4 [Stable, Extensible] enum CrashType { [Default] kUnknown = 0, kKernel, kEmbeddedController, [MinVersion=1] kChrome, }; // Type of the crash. Corresponding to "fatal_crash_type" in uploads.log. CrashType crash_type@0; // ID that represents crash locally. Corresponding to "path_hash" in // uploads.log. string local_id@1; // The time at which the crash event is captured by the system. Corresponding // to "capture_time" in uploads.log. mojo_base.mojom.Time capture_time@2; // Information available for uploaded crash events only. Missing if the crash // hasn't been uploaded by crash_sender yet. CrashUploadInfo? upload_info@3; }; // Implemented by clients who desire events. // // NextMinVersion: 1, NextIndex: 1 [Stable] interface EventObserver { // Fired when an event happens. OnEvent@0(EventInfo info); }; // Union of event info. // // NextMinVersion: 10, NextIndex: 16 [Stable, Extensible] union EventInfo { // The default value for forward compatibility. All the unknown type will be // mapped to this. [Default] uint8 default_type@0; // USB event info. UsbEventInfo usb_event_info@1; // Thunderbolt event info. ThunderboltEventInfo thunderbolt_event_info@2; // Lid event info. LidEventInfo lid_event_info@3; // Bluetooth event info. BluetoothEventInfo bluetooth_event_info@4; // Power event info. PowerEventInfo power_event_info@5; // Audio event info. AudioEventInfo audio_event_info@6; // Audio jack event info. [MinVersion=1] AudioJackEventInfo audio_jack_event_info@7; // SD Card event info. [MinVersion=2] SdCardEventInfo sd_card_event_info@8; // Keyboard diagnostics event info. It is fired when users completed a // keyboard diagnostic in the Diagnostics App. [MinVersion=3] ash.diagnostics.mojom.KeyboardDiagnosticEventInfo keyboard_diagnostic_event_info@9; // Touchpad event info. [MinVersion=4] TouchpadEventInfo touchpad_event_info@10; // External Display event info. [MinVersion=5] ExternalDisplayEventInfo external_display_event_info@11; // Touchscreen event info. [MinVersion=6] TouchscreenEventInfo touchscreen_event_info@12; // Stylus garagge event info. [MinVersion=7] StylusGarageEventInfo stylus_garage_event_info@13; // Stylus event info. [MinVersion=8] StylusEventInfo stylus_event_info@14; // Crash event info. [MinVersion=9] CrashEventInfo crash_event_info@15; }; // An enumeration of event categories. // // NextMinVersion: 11, NextIndex: 17 [Stable, Extensible] enum EventCategoryEnum { // This is required for backwards compatibility, should not be used. [Default] kUnmappedEnumField = 0, kUsb = 1, kThunderbolt = 2, kLid = 3, kBluetooth = 4, kPower = 5, kAudio = 6, [MinVersion=1] kAudioJack = 7, [MinVersion=2] kSdCard = 8, [MinVersion=3] kNetwork = 9, [MinVersion=4] kKeyboardDiagnostic = 10, [MinVersion=5] kTouchpad = 11, [MinVersion=6] kExternalDisplay = 12, [MinVersion=7] kTouchscreen = 13, [MinVersion=8] kStylusGarage = 14, [MinVersion=9] kStylus = 15, [MinVersion=10] kCrash = 16, };