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

syntax = "proto2";

package android.corenetworking.connectivity;

option java_outer_classname = "ConnectivityProtoEnums";
option java_multiple_files = true;

// Signal strength levels, as defined in android/telephony/SignalStrength.java.
enum SignalStrength {
  SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
  SIGNAL_STRENGTH_POOR = 1;
  SIGNAL_STRENGTH_MODERATE = 2;
  SIGNAL_STRENGTH_GOOD = 3;
  SIGNAL_STRENGTH_GREAT = 4;
}

// Radio Access Technology(RAT) will only consider the RAT type of (WIFI/2G/3G/4G/5G).
// So in addition to the above RAT types, others(BT, ethernet or no RAT) will be classified
// as RT_UNKNOWN.
enum RatType {
    RT_UNKNOWN = 0;
    RT_WIFI = 1;
    RT_2G = 2;
    RT_3G = 3;
    RT_4G = 4;
    RT_5G = 5;
}

// Network request states
// * Network request is in the NETWORK_REQUEST_STATE_RECEIVED state when it
// was just registered by the Connectivity service;
// * Network request is in the NETWORK_REQUEST_STATE_REMOVED state when it was
// just removed by the Connectivity service;
enum NetworkRequestState {
  NETWORK_REQUEST_STATE_UNKNOWN = 0;
  NETWORK_REQUEST_STATE_RECEIVED = 1;
  NETWORK_REQUEST_STATE_REMOVED = 2;
}

// Prefix as enum of NetworkStatsRecorder, as defined in
// android.net.netstats.NetworkStatsDataMigrationUtils#PREFIX_*.
enum RecorderPrefix {
  PREFIX_UNKNOWN = 0;
  PREFIX_XT = 1;
  PREFIX_UID = 2;
  PREFIX_UIDTAG = 3;
}

// Type of NetworkStatsRecorder file operations.
enum RecorderOperationType {
  ROT_UNKNOWN = 0;
  ROT_READ = 1;
  ROT_WRITE = 2;
}

// State of applying FastDataInput feature.
enum FastDataInputState {
  FDIS_UNKNOWN = 0;
  FDIS_ENABLED= 1;
  FDIS_DISABLED = 2;
}

// Type of terrible error.
enum TerribleErrorType {
  TYPE_UNKNOWN = 0;
  // Indicate the error state that the NetworkAgent sent messages to
  // connectivity service before it is connected.
  TYPE_MESSAGE_QUEUED_BEFORE_CONNECT = 1;
  // Indicate the error state that the ConnectivityService attempts to
  // cleanup the bypassing VPN permission for a delegate UID, however,
  // netd doesn't know about this UID and allowBypassVpnOnNetwork API
  // returns ENOENT.
  TYPE_DISALLOW_BYPASS_VPN_FOR_DELEGATE_UID_ENOENT = 2;
  // Indicate the error state that the legacy TetheringManager#tether API was called for Wifi.
  TYPE_LEGACY_TETHER_WITH_TYPE_WIFI = 3;
  // Indicate the error state that the legacy TetheringManager#tether API was called for Wifi P2P.
  TYPE_LEGACY_TETHER_WITH_TYPE_WIFI_P2P = 4;
  // Indicate the error state that the legacy TetheringManager#tether API was called for Wifi and
  // tethering succeeded.
  TYPE_LEGACY_TETHER_WITH_TYPE_WIFI_SUCCESS = 5;
  // Indicate the error state that the legacy TetheringManager#tether API was called for Wifi P2P
  // and tethering succeeded.
  TYPE_LEGACY_TETHER_WITH_TYPE_WIFI_P2P_SUCCESS = 6;
  // Indicate the error state that the entitlement check failed to
  // createContextAsUser because the tethering package is not installed
  // on that user.
  TYPE_ENTITLEMENT_CREATE_CONTEXT_AS_USER_THROWS = 7;
  // Indicate the error state that tethering was started with a placeholder request (i.e. we
  // couldn't find a pending request for the link layer event).
  TYPE_TETHER_WITH_PLACEHOLDER_REQUEST = 8;
  // Indicate the error state that the ConnectivityService attempts to clean up
  // the bypassing private DNS permission for a delegate UID, however, the DNS
  // resolver doesn't know about this UID and setAllowBypassPrivateDnsOnNetwork API
  // returns ENOENT.
  TYPE_DISALLOW_BYPASS_PRIVATE_DNS_FOR_DELEGATE_UID_ENOENT = 9;
  // Indicate the error state that the ConnectivityService attempts to
  // set to allow bypassing the VPN permission for a delegate UID, however,
  // allowBypassVpnOnNetwork API returns a non EEXIST error.
  TYPE_ALLOW_BYPASS_VPN_FOR_DELEGATE_UID_ERROR = 10;
  // Indicate the error state that the ConnectivityService attempts to
  // set to allow bypassing the private DNS permission for a delegate UID,
  // however, setAllowBypassPrivateDnsOnNetwork API returns a non EEXIST
  // error.
  TYPE_ALLOW_BYPASS_PRIVATE_DNS_FOR_DELEGATE_UID_ERROR = 11;
  // Indicate WiFi tethering was enabled with an interface name that maps to a different type.
  TYPE_TETHER_WIFI_TYPE_MISMATCH = 12;
  // Indicate WiFi P2P tethering was enabled with an interface name that maps to a different type.
  TYPE_TETHER_WIFIP2P_TYPE_MISMATCH = 13;
  // Indicate Wi-Fi report firmware support APF version 0.
  TYPE_WIFI_REPORT_APF_VERSION_ZERO = 14;
  // Indicate BPF shim not initialized, it should be kernel uapi bug mentioned in b/438099891.
  TYPE_BPF_COORDINATOR_SHIM_INIT_ERROR = 15;
  // Indicate an unexpected reflection error occurred in specifier redaction methods (e.g.
  // redact(long) and getApplicationRedactions()).
  TYPE_SPECIFIER_REDACTION_REFLECTION_ERROR = 16;
}

// Type of critical bytes event.
enum CriticalBytesEventType {
  CRITICAL_BYTES_EVENT_TYPE_UNKNOWN = 0;

  /**
   * Reports tx/rx bytes generated on satellite networks.
   * Logged when the last satellite network disconnects.
   */
  CRITICAL_BYTES_EVENT_TYPE_SATELLITE_COARSE_TX_USAGE = 1;
  CRITICAL_BYTES_EVENT_TYPE_SATELLITE_COARSE_RX_USAGE = 2;
}

// Type of critical counts event.
enum CriticalCountsEventType {
  CRITICAL_COUNTS_EVENT_TYPE_UNKNOWN = 0;
  // Counts the number of requests when a local network is satisfied by requests in a rematch.
  CRITICAL_COUNTS_EVENT_TYPE_SATISFIED_BY_LOCAL_NETWORK = 1;
  // Counts QUIC connection closures when a UID loses network access.
  CRITICAL_COUNTS_EVENT_TYPE_QUIC_CONNECTION_CLOSE_LOST_ACCESS = 2;
  // Counts QUIC connection closures when the socket is destroyed.
  CRITICAL_COUNTS_EVENT_TYPE_QUIC_CONNECTION_CLOSE_SOCKET_DESTROY = 3;
}

// Type of NetworkRequest. See android.net.NetworkRequest.
enum NetworkRequestType {
    NETWORK_REQUEST_TYPE_UNSPECIFIED = 0;
    NETWORK_REQUEST_TYPE_LISTEN = 1;
    NETWORK_REQUEST_TYPE_TRACK_DEFAULT = 2;
    NETWORK_REQUEST_TYPE_REQUEST = 3;
    NETWORK_REQUEST_TYPE_BACKGROUND_REQUEST = 4;
    NETWORK_REQUEST_TYPE_TRACK_SYSTEM_DEFAULT =5;
    NETWORK_REQUEST_TYPE_LISTEN_FOR_BEST = 6;
    NETWORK_REQUEST_TYPE_RESERVATION = 7;
}
