/*
 * Copyright (C) 2024 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.desktopmode;
option java_package = "com.android.os.desktopmode";

import "frameworks/proto_logging/stats/atoms.proto";
import "frameworks/proto_logging/stats/atom_field_options.proto";
import "frameworks/proto_logging/stats/enums/desktopmode/enums.proto";

extend Atom {
  optional DesktopModeUIChanged desktop_mode_ui_changed = 818 [(module) = "framework"];
  optional DesktopModeSessionTaskUpdate desktop_mode_session_task_update = 819 [(module) = "framework"];
  optional DesktopModeTaskSizeUpdated desktop_mode_task_size_updated = 935 [(module) = "framework"];
}

/**
* Logged when there is a change to the Desktop mode UI
*
* Logged from
* frameworks/base/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeEventLogger.kt
*
* Needs to be in sync with the google3 version ../protos/enums/android/desktopmode/enums.proto.
*/
message DesktopModeUIChanged {
  // User interactions with desktopmode
  enum Event {
    UNKNOWN_EVENT = 0;
    ENTER = 1;
    EXIT = 2;
  }

  optional Event event = 1;
  // What triggered desktopmode (if the event is ENTER)
  optional EnterReason enter_reason = 2;
  // What triggered leaving desktopmode (if the event is EXIT)
  optional ExitReason exit_reason = 3;
  // An id used to identify a desktop mode instance
  optional int32 session_id = 4;
}

/**
* Logged when there is a task update in the desktop mode session
*
* Logged from
* frameworks/base/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeEventLogger.kt
*
* Needs to be in sync with the google3 version ../protos/enums/android/desktopmode/enums.proto.
*/
message DesktopModeSessionTaskUpdate {
  // The event associated with this app update
  optional TaskEvent task_event = 1;
  // The instance_id of this task
  optional int32 instance_id = 2;
  // The uid of the app associated with this task
  optional int32 uid = 3 [(is_uid) = true];
  // The height of this task in px
  optional int32 task_height = 4;
  // The width of this task in px
  optional int32 task_width = 5;
  // the x-coordinate of the top-left corner
  optional int32 task_x = 6;
  // the y-coordinate of the top-right corner
  optional int32 task_y = 7;
  // An id used to identify a desktop mode instance
  optional int32 session_id = 8;
  // The reason the task was minimized
  optional MinimizeReason minimize_reason = 9;
  // The reason the task was unminimized
  optional UnminimizeReason unminimize_reason = 10;
  // The number of visible tasks
  optional int32 visible_task_count = 11 [
    (state_field_option).exclusive_state = true,
    (state_field_option).nested = false
  ];
  // The reason this task was focused
  optional FocusReason focus_reason = 12;
}

/**
* Logged when a task size is updated (resizing, snapping or maximizing to
* stable bounds) during a desktop mode session.
*
* Logged from
* frameworks/base/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeEventLogger.kt
*
* * Needs to be in sync with the google3 version ../protos/enums/android/desktopmode/enums.proto.
*/
message DesktopModeTaskSizeUpdated {
  // How this task was resized
  optional ResizeTrigger resize_trigger = 1;
  // The stage of resizing this task
  optional ResizingStage resizing_stage = 2;
  // The input method for resizing this task
  optional InputMethod input_method = 3;
  // ID used to identify the Desktop mode session
  optional int32 desktop_mode_session_id = 4;
  // The instance_id of this task
  optional int32 instance_id = 5;
  // The UID of the app associated with this task
  optional int32 uid = 6 [(is_uid) = true];
  // The height of this task in dp
  optional int32 task_height = 7;
  // The width of this task in dp
  optional int32 task_width = 8;
  // The display area of the device in dp^2
  optional int32 display_area = 9;
}
