//
// 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 com_android_nfc;

option java_package = "com.android.nfc.proto";
option java_outer_classname = "NfcEventProto";

// Proto used to format NFC event logs.
message EventList {
  repeated Event events = 1;
}

message Event {
  required string timestamp = 1;
  required EventType event_type = 2;
}

// Union of events.
message EventType {
  oneof _EventType {
    NfcBootupState bootup_state = 1;
    NfcStateChange state_change = 2;
    NfcReaderModeChange reader_mode_change = 3;
    NfcCeUnroutableAid ce_unroutable_aid = 4;
    NfcObserveModeChange observe_mode_change = 5;
    NfcWalletRoleHolderChange wallet_role_holder_change = 6;
    NfcHostCardEmulationStateChange host_card_emulation_state_change = 7;
    NfcHostCardEmulationData host_card_emulation_data = 8;
    NfcRemoteFieldStateChange remote_field_state_change = 9;
    NfcDiscoveryTechnologyUpdate discovery_technology_update = 10;
    NfcSecureChange secure_change = 11;
    NfcWlcStateChange wlc_state_change = 12;
    NfcReaderOptionChange reader_option_change = 13;
    NfcClearPreference clear_preference = 14;
    NfcCeRoutedAid ce_routed_aid = 15;
    NfcAidRegistration aid_registration = 16;
    NfcPollingLoopRegistration polling_loop_registration = 17;
    NfcDataMigrationInProgress data_migration_in_progress = 18;
    NfcPaymentServiceBindState payment_service_bind_state = 19;
    NfcServiceOtherStateChange service_other_state_change = 20;
  }
}

message NfcBootupState {
  required bool enabled = 1;
}

message NfcAppInfo {
  optional string package_name = 1;
  optional int32 uid = 2;
}

message NfcComponentInfo {
  optional string package_name = 1;
  optional string class_name = 2;
}

message NfcStateChange {
  required NfcAppInfo app_info = 1;
  required bool enabled = 2;
}

message NfcReaderModeChange {
  optional NfcAppInfo app_info = 1;
  required int32 flags = 2;
}

message NfcCeUnroutableAid {
  required string aid = 1;
}

message NfcObserveModeChange {
  optional NfcAppInfo app_info = 1;
  required bool enable = 2;
  required bool result = 3;
  required int32 latency_ms = 4;
  optional bool fw_triggered = 5;
}

message NfcWalletRoleHolderChange {
  optional string package_name = 1;
}

message NfcHostCardEmulationStateChange {
  required int32 technology = 1;
  required bool enable = 2;
}

message NfcHostCardEmulationData {
  required int32 technology = 1;
  required bytes data = 2;
}

message NfcRemoteFieldStateChange {
  required bool field_on = 1;
}

message NfcDiscoveryTechnologyUpdate {
  required NfcAppInfo app_info = 1;
  required int32 poll_tech = 2;
  required int32 listen_tech = 3;
}

message NfcSecureChange {
  required bool enable = 1;
}

message NfcWlcStateChange {
  required bool enable = 1;
}

message NfcReaderOptionChange {
  required bool enable = 1;
  required NfcAppInfo app_info = 2;
}

message NfcClearPreference {}

message NfcCeRoutedAid {
  required string aid = 1;
  required NfcComponentInfo component_info = 2;
}

message NfcAidRegistration {
  required NfcAppInfo app_info = 1;
  required NfcComponentInfo component_info = 2;
  required bool is_registration = 3;
  repeated string aids = 4;
}

message NfcPollingLoopRegistration {
  required NfcAppInfo app_info = 1;
  required NfcComponentInfo component_info = 2;
  required bool is_registration = 3;
  required string polling_loop_filter = 4;
}

message NfcDataMigrationInProgress {
  required NfcAppInfo app_info = 1;
  required bool in_progress = 2;
}

enum BindState {
  SERVICE_CONNECTED = 0;
  SERVICE_DISCONNECTED = 1;
  SERVICE_BINDING_DIED = 2;
}

message NfcPaymentServiceBindState {
  required NfcComponentInfo component_info = 1;
  required BindState bind_state = 2;
}

message NfcServiceOtherStateChange {
  required NfcAppInfo app_info = 1;
  required NfcComponentInfo component_info = 2;
  required bool enabled = 3;
}
