/*
 * 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.pdf;

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

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

extend Atom {
  optional PdfLoadReported pdf_load_reported = 859 [(module) = "mediaprovider"];

  optional PdfApiUsageReported pdf_api_usage_reported = 860 [(module) = "mediaprovider"];

  optional PdfSearchReported pdf_search_reported = 861 [(module) = "mediaprovider"];
}
/**
 * Logs when client app calls the PDFViewer to load the pdf.
 * Logged from:
 *  packages/providers/MediaProvider/pdf.....
 */
message PdfLoadReported {
  // The UID of the app which calls the PDFViewer.
  // Required.
  optional int32 uid = 1 [(is_uid) = true];

  // Time taken to parse and successfully load the pdf. Excludes rendering time.
  // Required.
  optional int64 duration_millis = 2;

  // The size of the pdf in KB.
  // Required.
  optional float file_size_in_kb = 3;

  // The result of the pdf load.
  // Required.
  optional android.pdf.PdfLoadResult load_result = 4;

  // Optional.
  optional android.pdf.PdfLinearizedType type = 5;

  // Required.
  optional int32 number_of_pages = 6;

  // Unique identifier for a particular loaded document.
  // Note: This identifier will be different even if the same pdf document is loaded twice.
  // Required.
  optional int64 doc_id = 7;
}

/**
 * Logs when PdfRenderer APIs are called.
 * Logged from:
 *  packages/providers/MediaProvider/pdf.....
 */
message PdfApiUsageReported {
  // The UID of the app which calls the PDFViewer.
  // Required.
  optional int32 uid = 1 [(is_uid) = true];

  // Unique identifier for a particular loaded document
  // Required
  optional int64 doc_id = 2;

  // The type of the API invoked
  // Required.
  optional android.pdf.ApiType api_type = 3;

  // API Response status
  // Required.
  optional android.pdf.ApiResponseStatus api_response_status = 4;

  // Type of operation (add, remove, update, list)
  // Optional.
  optional android.pdf.OperationType operation_type = 5;
}

/**
 * Logs when a search API is called.
 * Logged from:
 *  packages/providers/MediaProvider/pdf/.....
 */
message PdfSearchReported {
  // The UID of the app which calls the PDFViewer.
  // Required.
  optional int32 uid = 1 [(is_uid) = true];

  // Time taken to return list of search results from PDF.
  // Required.
  optional int64 duration_millis = 2;

  // The length of the search query string.
  // Required.
  optional int32 query_length = 3;

  // The page number at which the query was made.
  // Required.
  optional int32 query_page_number = 4;

  // Result of the API call.
  // Required.
  optional android.pdf.ApiResponseStatus api_response_status = 5;

  // Unique identifier for a particular loaded document
  // Required.
  optional int64 doc_id = 6;

  // Number of pages in the PDF
  // Optional.
  optional int32 num_pages = 7;

  // Optional.
  optional int32 match_count = 8;
}
