// Copyright 2022 Google LLC
//
// 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
//
//     https://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.

syntax = "proto3";

package nearby.fastpair.proto;

import "third_party/nearby/fastpair/proto/data.proto";

// Represents the type of device that is being registered.
enum DeviceType {
  // Unspecified device type.
  DEVICE_TYPE_UNSPECIFIED = 0;
  // Headphones or Earbuds.
  HEADPHONES = 1;
  // Speaker.
  SPEAKER = 2;
  // Wearable such as a watch.
  WEARABLE = 3;
  // Input devices such as keyboards, mice, etc.
  INPUT_DEVICE = 4;
  // Cars.
  AUTOMOTIVE = 5;
  // OTHER (referencing how Status is structured).
  OTHER = 6;
  // True Wireless headphones (these include additional configuration options).
  TRUE_WIRELESS_HEADPHONES = 7;
  // WearOS watch. This should trigger explicit functionality on clients when
  // used, such as specifying BR/EDR transport type when creating a bond. It is
  // a subset of wearables working around specific issues on that platform.
  WEAR_OS = 8;
  // Android Auto has the particular Fast Pair UX flows which may not be bought
  // in by some car manufacturers (e.g. BMW). Sees go/fastpair-android-auto for
  // more details.
  ANDROID_AUTO = 9;
  // Glass has the particular Fast Pair UX requiring passkey confirmation
  // to show up on the screen in order to pair it with a smartphone.
  GLASS = 10;
  // Locator tags.
  LOCATOR_TAG = 11;
  // ChromeOS device.
  CHROME_OS = 12;
  // Android phone.
  ANDROID_PHONE = 13;
}

// Represents the format of the final device notification (which is directly
// correlated to the action taken by the notification).
enum NotificationType {
  // Unspecified notification type.
  NOTIFICATION_TYPE_UNSPECIFIED = 0;
  // Notification launches the fast pair intent.
  // Example Notification Title: "Bose SoundLink II"
  // Notification Description: "Tap to pair with this device"
  FAST_PAIR = 1;
  // Notification launches an app.
  // Notification Title: "[X]" where X is type/name of the device.
  // Notification Description: "Tap to setup this device"
  APP_LAUNCH = 2;
  // Notification launches for Nearby Setup. The notification title and
  // description is the same as APP_LAUNCH.
  NEARBY_SETUP = 3;
  // Notification launches the fast pair intent, but doesn't include an anti-
  // spoofing key. The notification title and description is the same as
  // FAST_PAIR.
  FAST_PAIR_ONE = 4;
  // Notification launches Smart Setup on devices.
  // These notifications are identical to APP_LAUNCH except that they always
  // launch Smart Setup intents within GMSCore.
  SMART_SETUP = 5;
}

message Device {
  // Output only. The server-generated ID of the device.
  int64 id = 1;

  // The pantheon project number the device is created under. Only Nearby admins
  // can change this.
  int64 project_number = 2;

  // How the notification will be displayed to the user
  NotificationType notification_type = 3;

  // The image to show on the notification.
  string image_url = 4;

  // The name of the device.
  string name = 5;

  // The intent that will be launched via the notification.
  string intent_uri = 6;

  // The transmit power of the device's BLE chip.
  int32 ble_tx_power = 7;

  // The distance that the device must be within to show a notification.
  // If no distance is set, we default to 0.6 meters. Only Nearby admins can
  // change this.
  float trigger_distance = 8;

  // Output only. Fast Pair only - The anti-spoofing key pair for the device.
  AntiSpoofingKeyPair anti_spoofing_key_pair = 9;

  // Fast Pair only - The type of device being registered.
  DeviceType device_type = 13;

  // Fast Pair only - Additional images for true wireless headsets.
  TrueWirelessHeadsetImages true_wireless_images = 15;

  // Name of the device that is displayed on the console.
  string display_name = 21;
}

// An anti-spoofing key pair for a device that allows us to verify the device is
// broadcasting legitimately.
message AntiSpoofingKeyPair {
  // The private key (restricted to only be viewable by trusted clients).
  bytes private_key = 1;

  // The public key.
  bytes public_key = 2;
}

// Strings to be displayed in notifications surfaced for a device.
message ObservedDeviceStrings {
  // The locale of all of the strings.
  string locale = 1;

  // The notification description for when the device is initially discovered.
  string initial_notification_description = 2;

  // The notification description for when the device is initially discovered
  // and no account is logged in.
  string initial_notification_description_no_account = 3;

  // The notification description for once we have finished pairing and the
  // companion app has been opened. For Bisto devices, this string will point
  // users to setting up the assistant.
  string open_companion_app_description = 4;

  // The notification description for once we have finished pairing and the
  // companion app needs to be updated before use.
  string update_companion_app_description = 5;

  // The notification description for once we have finished pairing and the
  // companion app needs to be installed.
  string download_companion_app_description = 6;

  // The notification title when a pairing fails.
  string unable_to_connect_title = 7;

  // The notification summary when a pairing fails.
  string unable_to_connect_description = 8;

  // The description that helps user initially paired with device.
  string initial_pairing_description = 9;

  // The description that let user open the companion app.
  string connect_success_companion_app_installed = 10;

  // The description that let user download the companion app.
  string connect_success_companion_app_not_installed = 11;

  // The description that reminds user there is a paired device nearby.
  string subsequent_pairing_description = 12;

  // The description that reminds users opt in their device.
  string retroactive_pairing_description = 13;

  // The description that indicates companion app is about to launch.
  string wait_launch_companion_app_description = 14;

  // The description that indicates go to bluetooth settings when connection
  // fail.
  string fail_connect_go_to_settings_description = 15;

  // The title of the UI to ask the user to confirm the pin code.
  string confirm_pin_title = 16;

  // The description of the UI to ask the user to confirm the pin code.
  string confirm_pin_description = 17;

  // The title of the UI to ask the user to confirm to sync contacts.
  string sync_contacts_title = 18;

  // The description of the UI to ask the user to confirm to sync contacts.
  string sync_contacts_description = 19;

  // The title of the UI to ask the user to confirm to sync SMS.
  string sync_sms_title = 20;

  // The description of the UI to ask the user to confirm to sync SMS.
  string sync_sms_description = 21;

  // The description in half sheet to ask user setup google assistant
  string assistant_setup_half_sheet = 22;

  // The description in notification to ask user setup google assistant
  string assistant_setup_notification = 23;

  // Description of the connect device action on TV, when user is not logged in.
  string fast_pair_tv_connect_device_no_account_description = 24;

  // The description of the slice to ask user setup the wear os.
  string wear_os_tap_to_set_up = 25;

  string finder_enable_sheet_title = 26;

  string finder_enable_sheet_find_device_toggle = 27;

  string finder_enable_sheet_finder_network_title = 28;

  string finder_enable_sheet_finder_network_toggle = 29;

  string finder_enable_sheet_description_find_nearby_devices_info = 30;

  string finder_enable_sheet_description_location_anonymous_info = 31;

  string finder_enable_sheet_description_location_encrypted_info = 32;

  string finder_enable_sheet_description_turn_off_in_settings = 33;

  // If present then this title will be used for the initial connect half sheet.
  string initial_connect_sheet_title = 36;

  // Deleted fields.
  reserved 34, 35;
}

// Request for getting an observed device.
message GetObservedDeviceRequest {
  // The mode the requesting device is currently in, eg release or debug.
  enum Mode {
    // Unknown mode.
    MODE_UNKNOWN = 0;

    // Release mode.
    MODE_RELEASE = 1;

    // Debug mode.
    MODE_DEBUG = 2;
  }

  // The ID of the device to find.
  int64 device_id = 1;

  // The request mode for the device.
  Mode mode = 2;

  // The locale to get a translated description for.
  string locale = 3;

  // 6-hexdigit Device Id and will be auto-converted and used instead of
  // device_id. If both device_id and hex_device_id, device_id will be used and
  // hex_device_id will be ignored
  string hex_device_id = 4;

  // The max size of an icon to be displayed in pixels.
  int64 max_icon_size_pixels = 5;
}

// Response containing an observed device.
message GetObservedDeviceResponse {
  // The device from the request.
  Device device = 1;

  // The image icon that shows in the notification
  bytes image = 3;

  ObservedDeviceStrings strings = 4;

  reserved 2;
}

// Request to read the user's devices.
message UserReadDevicesRequest {
  // Optional secondary ID that can be used for lookups.
  bytes secondary_id = 1;
}

// Response containing the list of devices for a user.
message UserReadDevicesResponse {
  repeated .nearby.fastpair.proto.FastPairInfo fast_pair_info = 1;
}

// Request to write a new device to a user.
message UserWriteDeviceRequest {
  .nearby.fastpair.proto.FastPairInfo fast_pair_info = 1;
}

// Response to writing a new device to a user.
message UserWriteDeviceResponse {}

// Request to delete an existing device from a user's account.
message UserDeleteDeviceRequest {
  // The account key to be deleted, encoded in base16 (hex).  This should use
  // all upper-case letters with no padding or prefex (i.e. 0123456789ABCDEF).
  string hex_account_key = 2;
}

// Response to deleting a new device from a user's account.
message UserDeleteDeviceResponse {
  bool success = 1;
  repeated string error_messages = 2;
}
