/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * 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
 *
 *      http://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 = "proto2";

package android.os.statsd.settings;

import "frameworks/proto_logging/stats/atoms.proto";
import "frameworks/proto_logging/stats/atom_field_options.proto";
import "frameworks/proto_logging/stats/enums/app/settings/settings_enums.proto";

option java_package = "com.android.os.settings";
option java_multiple_files = true;

extend Atom {
  optional SettingsSpaReported settings_spa_reported = 622 [(module) = "settings"];
  optional SettingsExtApiReported settings_extapi_reported = 1001 [(module) = "settings"];
  optional SettingsBiometricsOnboarding settings_biometrics_onboarding = 1060 [(module) = "settings"];
  optional ExternalDisplaySettingsChanged external_display_settings_changed = 1184 [(module) = "settings"];
}


/**
 * Logs when Settings SPA UI has changed.
 *
 * Logged from:
 *   packages/apps/Settings
 */
message SettingsSpaReported {
  // Settings SPA session type.
  optional android.app.settings.SessionType session_type = 1;

  // The id value of SettingsPage.
  optional string page_id = 2;

  // The id value of target page.
  optional string target = 3;

  // What the UI action is.
  optional android.app.settings.Action action = 4;

  // The value of entry id
  optional string key = 5;

  // The value of any type (string, int, boolean etc),
  // cast the value into string type.
  optional string value = 6;

  // Keeps the previous value while data changing.
  optional string previous_value = 7;

  // Data about elapsed time since setup wizard finished.
  optional int64 elapsed_time_millis = 8;
}

/**
 * Logs when Settings External API has been requested.
 *
 * Logged from:
 *   framework/base/packages/SettingsLib/Graph
 *
 * Estimated Logging Rate:
 *   Peak: 5 times in 1 min | Avg: 40 times per device per day
 */
message SettingsExtApiReported {
  // Package calling the API.
  optional string package_name = 1;

  // Setting ID assembled by screen name and setting key.
  optional string setting_id = 2;

  // Settings external API request type.
  optional android.app.settings.ExtApiRequestType type = 3;

  // Settings external API result type.
  optional android.app.settings.ExtApiResultType result = 4;

  // Latency between the request and result made by the external API.
  optional int64 latency_millis = 5;

  // Action enum associated with the preference.
  optional android.app.settings.Action action = 6;
}

/**
 * Logs when a biometric onboarding flow happens.
 *
 * Logged from:
 *   packages/apps/Settings/
 *
 * Keep in sync with packages/apps/Settings/protos/biometrics_onboarding.proto
 */
message SettingsBiometricsOnboarding {
  // Face or fingerprint
  optional android.app.settings.Modality modality = 1;

  // From SUW/Settings/SafetyCenter...
  optional android.app.settings.FromSource from_source = 2;

  // The associated user. Eg: 0 for owners, 10+ for others.
  optional int32 user = 3;

  // The enrolled count during this onboarding flow.
  optional int32 enrolled_count = 4;

  // Duration of the onboarding flow in millis.
  optional int64 duration_millis = 5;

  // The capybara status.
  optional int32 capybara_status = 6;

  // The result code of the onboarding flow
  optional android.app.settings.OnboardingResult result_code = 7;

  // The error code
  optional int32 error_code = 8;

  // All screen infos that a user navigates through the onboarding flow.
  optional RepeatedOnboardingScreenInfo onboarding_screen_info_list = 9 [(log_mode) = MODE_BYTES];
}

message OnboardingScreenInfo {
  // The onboarding screen
  optional android.app.settings.OnboardingScreen onboarding_screen = 1;
  // The actions that user performs on this screen
  repeated android.app.settings.OnboardingAction onboarding_actions = 2;
  // The time in ms that user stays on this screen
  optional int64 dwell_time_millis = 3;
}

message RepeatedOnboardingScreenInfo {
  // The onboarding screen info list
  repeated OnboardingScreenInfo info_list = 1;
}

/**
 * Logs when user changed external display settings.
 * Logged from:
 *     packages/apps/Settings/src/com/android/settings/display/ExternalDisplaySettingsFragment.java
*/
message ExternalDisplaySettingsChanged {
    enum ExternalDisplaySetting {
        UNKNOWN = 0;
        DISPLAY_SIZE = 1;
        RESOLUTION = 2;
        ROTATION = 3;
        TOPOLOGY = 4;
    }
    // The settings that were changed.
    optional ExternalDisplaySetting setting = 1;
    // The width of the display in pixels.
    optional int32 display_width = 2;
    // The height of the display in pixels.
    optional int32 display_height = 3;
    // The rotation of the display in degrees. 0, 90, 180, 270.
    optional int32 display_rotation = 4;
    // The size of the display in percentage.
    optional float display_size = 5;
}
