/*
 * Copyright (C) 2025 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.media;

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

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

extend Atom {
  optional MediaRouterEventReported media_router_event_reported = 1017
      [(module) = "mediarouter"];
  optional RoutingChangeReported routing_change_reported = 1142
      [(module) = "mediarouter"];
  optional RouteListingPreferenceUpdated route_listing_preference_updated = 1168
      [(module) = "mediarouter"];
  optional DeviceSuggestionsInteractionReported device_suggestions_interaction_reported = 1180
      [(module) = "mediarouter"];
}

/**
 * Pushed atom. Logs an event for media router.
 *
 * Logged from:
 *   frameworks/base/media/java/android/media/
 * Estimated Logging Rate:
 *   Avg: 10 per device per day
 */
message MediaRouterEventReported {
  // The media router event being logged. For example: session start, transfer to route, etc.
  optional android.media.router.EventType event_type = 1;
  // Result of the media router event.
  optional android.media.router.Result result = 2;
  // Point where the routing event originated from (Output switcher, Unified Media Object card, etc.)
  optional android.media.router.EntryPoint entry_point = 3;
  // Whether the device where media is being routed was a device suggestion.
  optional bool is_suggested_device = 4;
}

/**
 * Pushed atom. Logs an event when there is a change in media routing.
 *
 * Logged from:
 *   frameworks/base/media/java/android/media/
 * Estimated Logging Rate:
 *   Avg: 10 per device per day
 */
message RoutingChangeReported {
  // Point where the routing session originated from (Output switcher, Unified Media Object notification card, etc.)
  optional android.media.router.EntryPoint entry_point = 1;
  // Client app package uid for which the media is being routed.
  optional int32 client_package_uid = 2 [(is_uid) = true];
  // Whether the session routes media to system routes (BUILT_IN_SPEAKERS, BT Devices, etc.)
  optional bool is_system_session = 3;
  // The reason for the session being transferred.
  optional android.media.router.TransferReason transfer_reason = 4;
  // Whether the device where media is being routed was an intelligent device suggestion.
  optional bool is_suggested_device = 5;
  // Length of the media routing session in millis.
  optional int64 session_length_millis = 6;
  // Whether the route had an active suggestion from the active route listing preference.
  optional bool is_suggested_by_rlp = 7;
  // Whether the route had an active device suggestion from the media app.
  optional bool is_device_suggestion_by_media_app = 8;
  // Whether the route had an active device suggestion from an app other than the media app.
  optional bool is_device_suggestion_by_another_app = 9;

}

/**
 * Pushed atom. Logs an event at the end of a media router lifecycle with the
 * number of route listing preference API calls made on that router.
 *
 * Logged from:
 *   frameworks/base/media/java/android/media/
 * Estimated Logging Rate:
 *   Avg: 10 per device per day
 */
 message RouteListingPreferenceUpdated {
  // The package calling the API to set route listing preference.
  optional int32 calling_package_uid = 1 [(is_uid) = true];
  // The count of the API calls made in the lifecycle of the media router.
  optional int64 call_count = 2;
  // The count of the API calls made in the lifecycle of the media router which have the suggested flag set.
  optional int64 suggested_flag_call_count = 3;
}

/**
 * Pushed atom. Logs an event at the end of a media router lifecycle with the
 * number of device suggestion calls made on that router. It captures updates of device suggestions
 * made by a suggesting package as well as calls made to fetch device suggestions.
 *
 * Logged from:
 *   frameworks/base/media/java/android/media/
 * Estimated Logging Rate:
 *   Avg: 10 per device per day
 */
 message DeviceSuggestionsInteractionReported {
  // The package for which devices are suggested.
  optional int32 target_package_uid = 1 [(is_uid) = true];
  // The package suggesting the devices.
  optional int32 suggesting_package_uid = 2 [(is_uid) = true];
  // The count of the calls made in the lifecycle of the media router to update device suggestions.
  optional int64 update_call_count = 3;
  // The count of the calls made in the lifecycle of the media router to request device suggestions.
  optional int64 request_call_count = 4;
}
