// Copyright (C) 2023 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

// This is the schema definition for aconfig files. Modifications need to be
// either backwards compatible, or include updates to all aconfig files in the
// Android tree.

syntax = "proto2";

package android.aconfig;

// messages used in both aconfig input and output

enum flag_state {
  ENABLED = 1;
  DISABLED = 2;
}

enum flag_permission {
  READ_ONLY = 1;
  READ_WRITE = 2;
}

// aconfig input messages: flag declarations and values

message flag_declaration {
  optional string name = 1;
  optional string namespace = 2;
  optional string description = 3;
  repeated string bug = 4;
};

message flag_declarations {
  optional string package = 1;
  repeated flag_declaration flag = 2;
};

message flag_value {
  optional string package = 1;
  optional string name = 2;
  optional flag_state state = 3;
  optional flag_permission permission = 4;
};

message flag_values {
  repeated flag_value flag_value = 1;
};

// aconfig output messages: parsed and verified flag declarations and values

message tracepoint {
  // path to declaration or value file relative to $TOP
  optional string source = 1;
  optional flag_state state = 2;
  optional flag_permission permission = 3;
}

message parsed_flag {
  optional string package = 1;
  optional string name = 2;
  optional string namespace = 3;
  optional string description = 4;
  repeated string bug = 5;
  optional flag_state state = 6;
  optional flag_permission permission = 7;
  repeated tracepoint trace = 8;
}

message parsed_flags {
  repeated parsed_flag parsed_flag = 1;
}
