/* SPDX-FileCopyrightText: 2014 The Chromium Authors
 * SPDX-License-Identifier: BSD-3-Clause
 */

// Client-specific metadata used in the CryptAuth v2 Enrollment protocol, which
// is serialized and held in |client_app_metadata| of SyncKeysRequest (in file
// cryptauth_enrollment.proto).
syntax = "proto3";

package cryptauthv2;

option optimize_for = LITE_RUNTIME;

// Client specific metadata contained in SyncKeysRequest.client_app_metadata.
// Next id: 31
message ClientAppMetadata {
  // App specific metadata from the device. On Android, these should be common
  // for all the features as they come from GmsCore, however, on IOS and other
  // devices, there could be multiple apps with the feature.
  repeated ApplicationSpecificMetadata application_specific_metadata = 1;

  // Subgrouping of device identifiers.
  // Instance ID: See more info at go/gcm-in-gmscore and
  // https://g3doc.corp.google.com/java/com/google/wireless/android/iid/g3doc/index.md?cl=head
  string instance_id = 2;
  // Token to authenticate the instance ID.
  string instance_id_token = 3;
  // Checkin android id of the device.
  fixed64 android_device_id = 4;
  // Chrome and iOS use a UUID in the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
  // Where x is a lowercase hex digit.
  // For iOS, this UUID is the IDFV.
  // For backward compatibility with some Chrome long_device_ids, this can also
  // be something else.
  // For the same reason, this field is case sensitive, even with valid UUIDs.
  string long_device_id = 5;

  // Subgrouping of device features field. These help in targeting specific
  // class of devices, for ex: Tablets vs phones etc.
  // Locale of the device.
  string locale = 6;
  // The Operating System version.
  string device_os_version = 7;
  // The Operating System version number on the device.
  int64 device_os_version_code = 8;
  // The Operating system release on the device.
  string device_os_release = 9;
  // The Operating system codename on the device.
  string device_os_codename = 10;
  // Size of the display in thousandths of an inch (e.g. 7000 mils = 7 in)
  int32 device_display_diagonal_mils = 11;
  // Device's model name (e.g., an android.os.Build.MODEL)
  string device_model = 12;
  // The device manufacturer name.
  string device_manufacturer = 13;
  // The type of device this is.
  enum DeviceType {
    UNKNOWN = 0;
    ANDROID = 1;
    CHROME = 2;
    IOS = 3;
    BROWSER = 4;
    OSX = 5;
  }
  DeviceType device_type = 14;

  // Subgrouping of lock screen related fields. Used by many identity features.
  // Is this device using a secure screenlock (e.g., a pattern or pin unlock).
  bool using_secure_screenlock = 15;
  // Is auto-unlocking the screenlock supported ?
  bool auto_unlock_screenlock_supported = 16;
  // Is auto-unlocking the screenlock (e.g., when at "home") enabled ?
  bool auto_unlock_screenlock_enabled = 17;

  // Subgrouping of bluetooth state related fields on the device. Used by many
  // features.
  // Does the device have a Bluetooth (classic) radio?
  bool bluetooth_radio_supported = 18;
  // Is the Bluetooth (classic) radio on?
  bool bluetooth_radio_enabled = 19;
  // Does the device have a ble radio?
  bool ble_radio_supported = 20;

  // Does the device hardware support a mobile data connection?
  bool mobile_data_supported = 21;
  // Does the device support tethering ?
  bool tethering_supported = 22;
  // If a feature wants to upload some metadata common to all its keys.
  repeated FeatureMetadata feature_metadata = 23;

  // Bluetooth address for EasyUnlock.
  string bluetooth_address = 24;

  // Is the device a "Pixel Experience" Android device?
  bool pixel_experience = 25;
  // Is the device running in the ARC++ container on a chromebook?
  bool arc_plus_plus = 26;
  // Does the device support user presence that is backed by hardware
  // (unspoofable by malware)?
  bool hardware_user_presence_supported = 27;
  // Does the device support user verification (E.g., passcode, biometrics)?
  bool user_verification_supported = 28;
  // Does the device support creating a key in trusted execution environment?
  bool trusted_execution_environment_supported = 29;
  // Does the device support creating a key in a dedicated secure element
  // hardware?
  bool dedicated_secure_element_supported = 30;

  // The response blob generated by the DroidGuard client on the device.
  string droid_guard_response = 31;
}

// Metadata that's app specific.
// Next id: 6
message ApplicationSpecificMetadata {
  // Used for device_address of DeviceInfo field 2, but for GCM capable devices.
  bytes gcm_registration_id = 1;
  // Does the user have notifications enabled for the given device address.
  bool notification_enabled = 2;
  // The software version running on the device.
  string device_software_version = 3;
  // The software version number running on the device.
  int64 device_software_version_code = 4;
  // Software package information if applicable.
  string device_software_package = 5;
  // Whether the user has Bluetooth enabled for the given device address.
  bool bluetooth_enabled = 6;
}

// Metadata which is same for different keys belonging to a particular feature.
message FeatureMetadata {
  enum Feature {
    UNKNOWN = 0;
    AUTHZEN = 1;
    BETTER_TOGETHER = 2;
  }
  Feature feature_type = 1;
  bytes metadata = 2;
}
