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

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

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

extend Atom {
  optional NotificationAdjustmentPreferences notification_adjustment_preferences = 10231 [(module) = "framework"];
  optional NotificationAssistantEventReported notification_assistant_event_reported = 1055 [(module) = "extservices"];
  optional NotificationAssistantDurationReceived notification_assistant_duration_received = 1056 [(module) = "extservices"];
}

/**
 * Atom that records a user's preferences for assistant-based adjustments to notifications.
 * The key of the adjustment specifies which kind of adjustment this atom pertains to. These
 * adjustments may include notification classification or summarization. Users can choose to allow
 * or disallow specific types of notification adjustments via Settings.
 *
 * For notification bundling (classification) specifically, we additionally log a list of a user's
 * notification bundle preferences. Bundles are system-provided groupings of notifications based on
 * notifications being classified as belonging to a particular type (e.g., news).
 *
 * Logged from:
 *   frameworks/base/services/core/java/com/android/server/notification/NotificationManagerService.java
 *
 * Next id: 6
 */
message NotificationAdjustmentPreferences {
  // The event_id (as for UiEventReported).
  optional int32 event_id = 1;

  // Whether this type of adjustment is allowed at all. Opting-out of the adjustment sets to false.
  optional bool adjustment_allowed = 2;

  // For bundles only: which types of bundles are allowed. Bundle types are a limited set, so this
  // repeated field will never be larger than the total number of bundle types.
  repeated android.stats.notification.BundleTypes allowed_bundle_types = 3;

  // The adjustment key that this set of preferences pertains to.
  optional android.stats.notification.AdjustmentKey key = 4;

  // The android user ID (0, 1, 10, ...) for which these preferences apply. May be a full user
  // or a profile user.
  optional int32 user_id = 5;
}

/**
 * Atom that records NotificationAssistant event stats.
 *
 * Logged from:
 *   packages/modules/ExtServices/java/src/android/ext/services/notification/Assistant.java
 */
message NotificationAssistantEventReported {
  enum NotificationAssistantEventType {
    UNKNOWN = 0;
    NOTIFICATION_ENQUEUED = 1;
    TC_FOR_OTP_DETECTION_ENABLED = 2;
    OTP_CHECKED = 3;
    OTP_CHECK_SKIPPED_DUE_TO_LOAD = 4;
    OTP_DETECTED = 5;
  }
  optional NotificationAssistantEventType event_type = 1;
}

/**
 * Atom that records NotificationAssistant duration stats.
 *
 * Logged from:
 *   packages/modules/ExtServices/java/src/android/ext/services/notification/Assistant.java
 */
message NotificationAssistantDurationReceived {
  optional int64 otp_detection_duration_ms = 1;
}
