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

syntax = "proto2";

option optimize_for = LITE_RUNTIME;

package arc;
option go_package = "go.chromium.org/chromiumos/system_api/arc_proto";

// ARC start options sent from Chrome to session manager. This message is used
// in the SessionManagerInterface.StartArcMiniContainer method for ARC
// container. It is also being used by concierge when the device is running on
// ARCVM.
message StartArcMiniInstanceRequest {
  enum PlayStoreAutoUpdate {
    // Play Store auto-update is left unchanged.
    AUTO_UPDATE_DEFAULT = 0;
    // Play Store auto-update is forced to on.
    AUTO_UPDATE_ON = 1;
    // Play Store auto-update is forced to off.
    AUTO_UPDATE_OFF = 2;
  }

  enum DalvikMemoryProfile {
    // Default dalvik memory profile suitable for all devices.
    MEMORY_PROFILE_DEFAULT = 0;
    // Dalvik memory profile suitable for 4G devices.
    MEMORY_PROFILE_4G = 1;
    // Dalvik memory profile suitable for 8G devices.
    MEMORY_PROFILE_8G = 2;
    // Dalvik memory profile suitable for 16G devices.
    MEMORY_PROFILE_16G = 3;
  }

  enum HostUreadaheadMode {
    // By default, ureadahead is in readahead mode.
    MODE_DEFAULT = 0;
    // Ureadahead is in generate mode.
    MODE_GENERATE = 1;
    // Ureadahead is in disabled mode.
    MODE_DISABLED = 2;
  }

  // Override with ndk_translation. Useful for ARC++ only, for ARCVM see
  // native_bridge_experiment in StartArcVmRequest.
  optional bool native_bridge_experiment = 1 [default = false];

  // The density value passed to "ro.sf.lcd_density" property.
  optional int32 lcd_density = 2 [default = -1];

  // Optional mode for play store auto-update.
  optional PlayStoreAutoUpdate play_store_auto_update = 4
      [default = AUTO_UPDATE_DEFAULT];

  // Optional mode for dalvik memory profile.
  optional DalvikMemoryProfile dalvik_memory_profile = 9
      [default = MEMORY_PROFILE_DEFAULT];

  // Option to disable download provider for tests that are sensetive to the
  // external components installaton. Last causes the flakiness in tests like
  // arc.CacheValidation.
  optional bool disable_download_provider = 12 [default = false];

  // Option to disable media store maintenance task scheduling. Used in tests
  // to prevent unreliable performance measurements and CPU not idle failures.
  optional bool disable_media_store_maintenance = 10 [default = false];

  // Enables additional debug settings used when generating Play Auto Install
  // rosters.
  optional bool arc_generate_pai = 11 [default = false];

  // Option to enable TTS caching
  optional bool enable_tts_caching = 14 [default = false];

  // Option to enable disable consumer auto update toggle.
  optional bool enable_consumer_auto_update_toggle = 15 [default = false];

  // Option to enable privacy hub for chrome in android settings.
  optional bool enable_privacy_hub_for_chrome = 17 [default = false];

  // Flag to switch from ARC Keymaster to ARC KeyMint. Intended for T+ only.
  // TODO(b/268706760): Remove this flag when ARC KeyMint upgrade is done.
  optional bool arc_switch_to_keymint = 18 [default = false];

  // Experimental value to test various possible values for the
  // "ro.vendor.arc.sf.maxacquired" property setting.
  optional int32 force_max_acquired_buffers_experiment = 19 [default = -1];

  // Flag to use dev caches in arccachesetup service.
  optional bool use_dev_caches = 20 [default = false];

  // Flag to set host ureadahead mode.
  optional HostUreadaheadMode host_ureadahead_mode = 21
      [default = MODE_DEFAULT];

  // Flag that indicates whether user is already signed into ARC.
  optional bool arc_signed_in = 22 [default = false];

  // Flag that would enable ARC Attestation, and would make ARC
  // RemotelyProvisionedComponentDevice visible to Keystore.
  optional bool enable_arc_attestation = 23 [default = false];

  reserved 5, 6, 7, 8, 13, 16;

  // Next ID to use: 24
}

// ARC upgrade options sent from Chrome to session manager. This message is used
// in the SessionManagerInterface.UpgradeArcContainer method.
message UpgradeArcContainerRequest {
  enum PackageCacheMode {
    // Performs packages cache setup if the pre-generated cache exists.
    DEFAULT = 0;
    // Performs packages cache setup if the pre-generated cache exists and
    // copies resulting packages.xml to the temporary location after
    // SystemServer initialized the package manager.
    COPY_ON_INIT = 1;
    // Skips packages cache setup and copies resulting packages.xml to the
    // temporary location after SystemServer initialized the package manager.
    SKIP_SETUP_COPY_ON_INIT = 2;
  }

  enum ManagementTransition {
    // No transition necessary.
    NONE = 0;
    // Child user is transitioning to regular account, need to lift supervision.
    CHILD_TO_REGULAR = 1;
    // Regular user is transitioning to child account, need to enable
    // supervision.
    REGULAR_TO_CHILD = 2;
    // Unmanaged user is transitioning to managed state, need to enable
    // management.
    UNMANAGED_TO_MANAGED = 3;
  }

  // Account ID of the user to start ARC for. This must be the same as the
  // one given in StartSession.
  required string account_id = 1;

  // Whether the account is managed.
  optional bool is_account_managed = 14;

  // Whether adb sideloading is allowed when the account and/or the device is
  // managed.
  optional bool is_managed_adb_sideloading_allowed = 16;

  // Option to disable ACTION_BOOT_COMPLETED broadcast for 3rd party apps.
  optional bool skip_boot_completed_broadcast = 2 [default = false];

  // Optional mode for packages cache tests.
  optional PackageCacheMode packages_cache_mode = 4 [default = DEFAULT];

  // Option to disable GMS CORE cache.
  optional bool skip_gms_core_cache = 13 [default = false];

  // Whether the container is being upgraded for a Chrome OS demo session.
  optional bool is_demo_session = 10;

  // Non-empty only if the ARC container is being upgraded for a Chrome OS demo
  // session. The absolute path to the squashfs image that contains the set of
  // Android apps to be pre-installed into demo sessions. Note that arc-setup
  // expects this to be a path loaded by the imageloader service.
  optional string demo_session_apps_path = 6;

  // Locale to set in Android container during the boot.
  optional string locale = 7;

  // Preferred languages to set in Android container during the boot.
  repeated string preferred_languages = 8;

  // Option to notify ARC that it should transition from a managed state to an
  // unmanaged state, and vice-versa.
  optional ManagementTransition management_transition = 11;

  // Option to enable Arc Nearby Share.
  optional bool enable_arc_nearby_share = 17 [default = false];

  // Option to skip pregenerated TTS cache setup.
  optional bool skip_tts_cache = 18 [default = false];

  reserved 9, 15;

  // Next ID to use: 19
}

// It requests to execute a command on ARC shell.
// Available requests are managed by ArcCroshService in ARC.
// ArcCroshServiceProvider in Chrome proxies and translates the message for
// ArcCroshService.
message ArcShellExecutionRequest {
  // Supported shell commands to execute on ARC shell.
  enum ArcShellCommand {
    TOP = 0;
    CPUINFO = 1;
    MEMINFO = 2;
  }

  // The requested command is executed on ARC shell.
  optional ArcShellCommand command = 1;

  // User id of the requesting user.
  // Only request from the primary user is received in ArcCroshServiceProvider
  // since ARC is tied to the primary user.
  optional string user_id = 2;

  // Next ID to use: 3
}

// It contains the execution result of ArcShellExecutionRequest.
// ArcCroshService in ARC creates the original mojo message,
// then ArcCroshServiceProvider in Chrome translates it into
// ArcShellExecutionResult and proxies to crosh.
message ArcShellExecutionResult {
  oneof payload {
    // Acquired output if the execution successes.
    string stdout = 1;

    // Error message if the execution fails.
    string error = 2;
  }

  // Next ID to use: 3
}
