// Signature format: 2.0
package android.app.usage {

  public class NetworkStatsManager {
    method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_STATS_PROVIDER, android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}) public void registerNetworkStatsProvider(@NonNull String, @NonNull android.net.netstats.provider.NetworkStatsProvider);
    method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_STATS_PROVIDER, android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}) public void unregisterNetworkStatsProvider(@NonNull android.net.netstats.provider.NetworkStatsProvider);
  }

}

package android.nearby {

  public interface BroadcastCallback {
    method public void onStatusChanged(int);
    field public static final int STATUS_FAILURE = 1; // 0x1
    field public static final int STATUS_FAILURE_ALREADY_REGISTERED = 2; // 0x2
    field public static final int STATUS_FAILURE_MISSING_PERMISSIONS = 4; // 0x4
    field public static final int STATUS_FAILURE_SIZE_EXCEED_LIMIT = 3; // 0x3
    field public static final int STATUS_OK = 0; // 0x0
  }

  public abstract class BroadcastRequest {
    method @NonNull public java.util.List<java.lang.Integer> getMediums();
    method @IntRange(from=0xffffff81, to=126) public int getTxPower();
    method public int getType();
    method public int getVersion();
    field public static final int BROADCAST_TYPE_NEARBY_PRESENCE = 3; // 0x3
    field public static final int BROADCAST_TYPE_UNKNOWN = -1; // 0xffffffff
    field public static final int MEDIUM_BLE = 1; // 0x1
    field public static final int PRESENCE_VERSION_UNKNOWN = -1; // 0xffffffff
    field public static final int PRESENCE_VERSION_V0 = 0; // 0x0
    field public static final int PRESENCE_VERSION_V1 = 1; // 0x1
    field public static final int UNKNOWN_TX_POWER = -127; // 0xffffff81
  }

  public final class CredentialElement implements android.os.Parcelable {
    ctor public CredentialElement(@NonNull String, @NonNull byte[]);
    method public int describeContents();
    method @NonNull public String getKey();
    method @NonNull public byte[] getValue();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.nearby.CredentialElement> CREATOR;
  }

  public final class DataElement implements android.os.Parcelable {
    ctor public DataElement(int, @NonNull byte[]);
    method public int describeContents();
    method public int getKey();
    method @NonNull public byte[] getValue();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.nearby.DataElement> CREATOR;
  }

  public abstract class NearbyDevice {
    method @NonNull public java.util.List<java.lang.Integer> getMediums();
    method @Nullable public String getName();
    method @IntRange(from=0xffffff81, to=126) public int getRssi();
    method public static boolean isValidMedium(int);
  }

  public class NearbyManager {
    method @FlaggedApi("com.android.nearby.flags.powered_off_finding") @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public int getPoweredOffFindingMode();
    method public void queryOffloadCapability(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.nearby.OffloadCapability>);
    method @FlaggedApi("com.android.nearby.flags.powered_off_finding") @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public void setPoweredOffFindingEphemeralIds(@NonNull java.util.List<byte[]>);
    method @FlaggedApi("com.android.nearby.flags.powered_off_finding") @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public void setPoweredOffFindingMode(int);
    method @RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_ADVERTISE, android.Manifest.permission.BLUETOOTH_PRIVILEGED}) public void startBroadcast(@NonNull android.nearby.BroadcastRequest, @NonNull java.util.concurrent.Executor, @NonNull android.nearby.BroadcastCallback);
    method @RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_SCAN, android.Manifest.permission.BLUETOOTH_PRIVILEGED}) public int startScan(@NonNull android.nearby.ScanRequest, @NonNull java.util.concurrent.Executor, @NonNull android.nearby.ScanCallback);
    method @RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_ADVERTISE, android.Manifest.permission.BLUETOOTH_PRIVILEGED}) public void stopBroadcast(@NonNull android.nearby.BroadcastCallback);
    method @RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_SCAN, android.Manifest.permission.BLUETOOTH_PRIVILEGED}) public void stopScan(@NonNull android.nearby.ScanCallback);
    field @FlaggedApi("com.android.nearby.flags.powered_off_finding") public static final int POWERED_OFF_FINDING_MODE_DISABLED = 1; // 0x1
    field @FlaggedApi("com.android.nearby.flags.powered_off_finding") public static final int POWERED_OFF_FINDING_MODE_ENABLED = 2; // 0x2
    field @FlaggedApi("com.android.nearby.flags.powered_off_finding") public static final int POWERED_OFF_FINDING_MODE_UNSUPPORTED = 0; // 0x0
  }

  public final class OffloadCapability implements android.os.Parcelable {
    method public int describeContents();
    method public long getVersion();
    method public boolean isFastPairSupported();
    method public boolean isNearbyShareSupported();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.nearby.OffloadCapability> CREATOR;
  }

  public static final class OffloadCapability.Builder {
    ctor public OffloadCapability.Builder();
    method @NonNull public android.nearby.OffloadCapability build();
    method @NonNull public android.nearby.OffloadCapability.Builder setFastPairSupported(boolean);
    method @NonNull public android.nearby.OffloadCapability.Builder setNearbyShareSupported(boolean);
    method @NonNull public android.nearby.OffloadCapability.Builder setVersion(long);
  }

  public final class PresenceBroadcastRequest extends android.nearby.BroadcastRequest implements android.os.Parcelable {
    method public int describeContents();
    method @NonNull public java.util.List<java.lang.Integer> getActions();
    method @NonNull public android.nearby.PrivateCredential getCredential();
    method @NonNull public java.util.List<android.nearby.DataElement> getExtendedProperties();
    method @NonNull public byte[] getSalt();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.nearby.PresenceBroadcastRequest> CREATOR;
  }

  public static final class PresenceBroadcastRequest.Builder {
    ctor public PresenceBroadcastRequest.Builder(@NonNull java.util.List<java.lang.Integer>, @NonNull byte[], @NonNull android.nearby.PrivateCredential);
    method @NonNull public android.nearby.PresenceBroadcastRequest.Builder addAction(@IntRange(from=1, to=255) int);
    method @NonNull public android.nearby.PresenceBroadcastRequest.Builder addExtendedProperty(@NonNull android.nearby.DataElement);
    method @NonNull public android.nearby.PresenceBroadcastRequest build();
    method @NonNull public android.nearby.PresenceBroadcastRequest.Builder setTxPower(@IntRange(from=0xffffff81, to=126) int);
    method @NonNull public android.nearby.PresenceBroadcastRequest.Builder setVersion(int);
  }

  public abstract class PresenceCredential {
    method @NonNull public byte[] getAuthenticityKey();
    method @NonNull public java.util.List<android.nearby.CredentialElement> getCredentialElements();
    method public int getIdentityType();
    method @NonNull public byte[] getSecretId();
    method public int getType();
    field public static final int CREDENTIAL_TYPE_PRIVATE = 0; // 0x0
    field public static final int CREDENTIAL_TYPE_PUBLIC = 1; // 0x1
    field public static final int IDENTITY_TYPE_PRIVATE = 1; // 0x1
    field public static final int IDENTITY_TYPE_PROVISIONED = 2; // 0x2
    field public static final int IDENTITY_TYPE_TRUSTED = 3; // 0x3
    field public static final int IDENTITY_TYPE_UNKNOWN = 0; // 0x0
  }

  public final class PresenceDevice extends android.nearby.NearbyDevice implements android.os.Parcelable {
    method public int describeContents();
    method @NonNull public String getDeviceId();
    method @Nullable public String getDeviceImageUrl();
    method public int getDeviceType();
    method public long getDiscoveryTimestampMillis();
    method @NonNull public byte[] getEncryptedIdentity();
    method @NonNull public java.util.List<android.nearby.DataElement> getExtendedProperties();
    method @NonNull public byte[] getSalt();
    method @NonNull public byte[] getSecretId();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.nearby.PresenceDevice> CREATOR;
  }

  public static final class PresenceDevice.Builder {
    ctor public PresenceDevice.Builder(@NonNull String, @NonNull byte[], @NonNull byte[], @NonNull byte[]);
    method @NonNull public android.nearby.PresenceDevice.Builder addExtendedProperty(@NonNull android.nearby.DataElement);
    method @NonNull public android.nearby.PresenceDevice.Builder addMedium(int);
    method @NonNull public android.nearby.PresenceDevice build();
    method @NonNull public android.nearby.PresenceDevice.Builder setDeviceImageUrl(@Nullable String);
    method @NonNull public android.nearby.PresenceDevice.Builder setDeviceType(int);
    method @NonNull public android.nearby.PresenceDevice.Builder setDiscoveryTimestampMillis(long);
    method @NonNull public android.nearby.PresenceDevice.Builder setName(@Nullable String);
    method @NonNull public android.nearby.PresenceDevice.Builder setRssi(int);
  }

  public final class PresenceScanFilter extends android.nearby.ScanFilter implements android.os.Parcelable {
    method public int describeContents();
    method @NonNull public java.util.List<android.nearby.PublicCredential> getCredentials();
    method @NonNull public java.util.List<android.nearby.DataElement> getExtendedProperties();
    method @NonNull public java.util.List<java.lang.Integer> getPresenceActions();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.nearby.PresenceScanFilter> CREATOR;
  }

  public static final class PresenceScanFilter.Builder {
    ctor public PresenceScanFilter.Builder();
    method @NonNull public android.nearby.PresenceScanFilter.Builder addCredential(@NonNull android.nearby.PublicCredential);
    method @NonNull public android.nearby.PresenceScanFilter.Builder addExtendedProperty(@NonNull android.nearby.DataElement);
    method @NonNull public android.nearby.PresenceScanFilter.Builder addPresenceAction(@IntRange(from=1, to=255) int);
    method @NonNull public android.nearby.PresenceScanFilter build();
    method @NonNull public android.nearby.PresenceScanFilter.Builder setMaxPathLoss(@IntRange(from=0, to=127) int);
  }

  public final class PrivateCredential extends android.nearby.PresenceCredential implements android.os.Parcelable {
    method public int describeContents();
    method @NonNull public String getDeviceName();
    method @NonNull public byte[] getMetadataEncryptionKey();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.nearby.PrivateCredential> CREATOR;
  }

  public static final class PrivateCredential.Builder {
    ctor public PrivateCredential.Builder(@NonNull byte[], @NonNull byte[], @NonNull byte[], @NonNull String);
    method @NonNull public android.nearby.PrivateCredential.Builder addCredentialElement(@NonNull android.nearby.CredentialElement);
    method @NonNull public android.nearby.PrivateCredential build();
    method @NonNull public android.nearby.PrivateCredential.Builder setIdentityType(int);
  }

  public final class PublicCredential extends android.nearby.PresenceCredential implements android.os.Parcelable {
    method public int describeContents();
    method @NonNull public byte[] getEncryptedMetadata();
    method @NonNull public byte[] getEncryptedMetadataKeyTag();
    method @NonNull public byte[] getPublicKey();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.nearby.PublicCredential> CREATOR;
  }

  public static final class PublicCredential.Builder {
    ctor public PublicCredential.Builder(@NonNull byte[], @NonNull byte[], @NonNull byte[], @NonNull byte[], @NonNull byte[]);
    method @NonNull public android.nearby.PublicCredential.Builder addCredentialElement(@NonNull android.nearby.CredentialElement);
    method @NonNull public android.nearby.PublicCredential build();
    method @NonNull public android.nearby.PublicCredential.Builder setIdentityType(int);
  }

  public interface ScanCallback {
    method public void onDiscovered(@NonNull android.nearby.NearbyDevice);
    method public default void onError(int);
    method public void onLost(@NonNull android.nearby.NearbyDevice);
    method public void onUpdated(@NonNull android.nearby.NearbyDevice);
    field public static final int ERROR_INVALID_ARGUMENT = 2; // 0x2
    field public static final int ERROR_PERMISSION_DENIED = 3; // 0x3
    field public static final int ERROR_RESOURCE_EXHAUSTED = 4; // 0x4
    field public static final int ERROR_UNKNOWN = 0; // 0x0
    field public static final int ERROR_UNSUPPORTED = 1; // 0x1
  }

  public abstract class ScanFilter {
    method @IntRange(from=0, to=127) public int getMaxPathLoss();
    method public int getType();
  }

  public final class ScanRequest implements android.os.Parcelable {
    method public int describeContents();
    method @NonNull public java.util.List<android.nearby.ScanFilter> getScanFilters();
    method public int getScanMode();
    method public int getScanType();
    method @NonNull public android.os.WorkSource getWorkSource();
    method public boolean isBleEnabled();
    method public boolean isOffloadOnly();
    method public static boolean isValidScanMode(int);
    method public static boolean isValidScanType(int);
    method @NonNull public static String scanModeToString(int);
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.nearby.ScanRequest> CREATOR;
    field public static final int SCAN_MODE_BALANCED = 1; // 0x1
    field public static final int SCAN_MODE_LOW_LATENCY = 2; // 0x2
    field public static final int SCAN_MODE_LOW_POWER = 0; // 0x0
    field public static final int SCAN_MODE_NO_POWER = -1; // 0xffffffff
    field public static final int SCAN_TYPE_FAST_PAIR = 1; // 0x1
    field public static final int SCAN_TYPE_NEARBY_PRESENCE = 2; // 0x2
  }

  public static final class ScanRequest.Builder {
    ctor public ScanRequest.Builder();
    method @NonNull public android.nearby.ScanRequest.Builder addScanFilter(@NonNull android.nearby.ScanFilter);
    method @NonNull public android.nearby.ScanRequest build();
    method @NonNull public android.nearby.ScanRequest.Builder setBleEnabled(boolean);
    method @NonNull public android.nearby.ScanRequest.Builder setOffloadOnly(boolean);
    method @NonNull public android.nearby.ScanRequest.Builder setScanMode(int);
    method @NonNull public android.nearby.ScanRequest.Builder setScanType(int);
    method @NonNull @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public android.nearby.ScanRequest.Builder setWorkSource(@Nullable android.os.WorkSource);
  }

}

package android.net {

  public class EthernetManager {
    method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK, android.Manifest.permission.MANAGE_ETHERNET_NETWORKS}) public void disableInterface(@NonNull String, @Nullable java.util.concurrent.Executor, @Nullable android.os.OutcomeReceiver<java.lang.String,android.net.EthernetNetworkManagementException>);
    method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK, android.Manifest.permission.MANAGE_ETHERNET_NETWORKS}) public void enableInterface(@NonNull String, @Nullable java.util.concurrent.Executor, @Nullable android.os.OutcomeReceiver<java.lang.String,android.net.EthernetNetworkManagementException>);
    method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_STACK, android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}) public android.net.EthernetManager.TetheredInterfaceRequest requestTetheredInterface(@NonNull java.util.concurrent.Executor, @NonNull android.net.EthernetManager.TetheredInterfaceCallback);
    method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK, android.Manifest.permission.MANAGE_ETHERNET_NETWORKS}) public void updateConfiguration(@NonNull String, @NonNull android.net.EthernetNetworkUpdateRequest, @Nullable java.util.concurrent.Executor, @Nullable android.os.OutcomeReceiver<java.lang.String,android.net.EthernetNetworkManagementException>);
  }

  public static interface EthernetManager.TetheredInterfaceCallback {
    method public void onAvailable(@NonNull String);
    method public void onUnavailable();
  }

  public static class EthernetManager.TetheredInterfaceRequest {
    method public void release();
  }

  public final class EthernetNetworkManagementException extends java.lang.RuntimeException implements android.os.Parcelable {
    ctor public EthernetNetworkManagementException(@NonNull String);
    method public int describeContents();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.net.EthernetNetworkManagementException> CREATOR;
  }

  public final class EthernetNetworkUpdateRequest implements android.os.Parcelable {
    method public int describeContents();
    method @Nullable public android.net.IpConfiguration getIpConfiguration();
    method @Nullable public android.net.NetworkCapabilities getNetworkCapabilities();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.net.EthernetNetworkUpdateRequest> CREATOR;
  }

  public static final class EthernetNetworkUpdateRequest.Builder {
    ctor public EthernetNetworkUpdateRequest.Builder();
    ctor public EthernetNetworkUpdateRequest.Builder(@NonNull android.net.EthernetNetworkUpdateRequest);
    method @NonNull public android.net.EthernetNetworkUpdateRequest build();
    method @NonNull public android.net.EthernetNetworkUpdateRequest.Builder setIpConfiguration(@Nullable android.net.IpConfiguration);
    method @NonNull public android.net.EthernetNetworkUpdateRequest.Builder setNetworkCapabilities(@Nullable android.net.NetworkCapabilities);
  }

  public class IpSecManager {
    method @RequiresPermission(android.Manifest.permission.MANAGE_IPSEC_TUNNELS) public void applyTunnelModeTransform(@NonNull android.net.IpSecManager.IpSecTunnelInterface, int, @NonNull android.net.IpSecTransform) throws java.io.IOException;
    method @NonNull @RequiresPermission(android.Manifest.permission.MANAGE_IPSEC_TUNNELS) public android.net.IpSecManager.IpSecTunnelInterface createIpSecTunnelInterface(@NonNull java.net.InetAddress, @NonNull java.net.InetAddress, @NonNull android.net.Network) throws java.io.IOException, android.net.IpSecManager.ResourceUnavailableException;
    method @RequiresPermission(android.Manifest.permission.MANAGE_IPSEC_TUNNELS) public void startTunnelModeTransformMigration(@NonNull android.net.IpSecTransform, @NonNull java.net.InetAddress, @NonNull java.net.InetAddress);
  }

  public static final class IpSecManager.IpSecTunnelInterface implements java.lang.AutoCloseable {
    method @RequiresPermission(android.Manifest.permission.MANAGE_IPSEC_TUNNELS) public void addAddress(@NonNull java.net.InetAddress, int) throws java.io.IOException;
    method public void close();
    method @NonNull public String getInterfaceName();
    method @RequiresPermission(android.Manifest.permission.MANAGE_IPSEC_TUNNELS) public void removeAddress(@NonNull java.net.InetAddress, int) throws java.io.IOException;
    method @RequiresPermission(android.Manifest.permission.MANAGE_IPSEC_TUNNELS) public void setUnderlyingNetwork(@NonNull android.net.Network) throws java.io.IOException;
  }

  public static class IpSecTransform.Builder {
    method @NonNull @RequiresPermission(android.Manifest.permission.MANAGE_IPSEC_TUNNELS) public android.net.IpSecTransform buildTunnelModeTransform(@NonNull java.net.InetAddress, @NonNull android.net.IpSecManager.SecurityParameterIndex) throws java.io.IOException, android.net.IpSecManager.ResourceUnavailableException, android.net.IpSecManager.SpiUnavailableException;
  }

  public final class NetworkStats implements java.lang.Iterable<android.net.NetworkStats.Entry> android.os.Parcelable {
    ctor public NetworkStats(long, int);
    method @NonNull public android.net.NetworkStats add(@NonNull android.net.NetworkStats);
    method @NonNull public android.net.NetworkStats addEntry(@NonNull android.net.NetworkStats.Entry);
    method public android.net.NetworkStats clone();
    method public int describeContents();
    method @NonNull public java.util.Iterator<android.net.NetworkStats.Entry> iterator();
    method @NonNull public android.net.NetworkStats subtract(@NonNull android.net.NetworkStats);
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.net.NetworkStats> CREATOR;
    field public static final int DEFAULT_NETWORK_ALL = -1; // 0xffffffff
    field public static final int DEFAULT_NETWORK_NO = 0; // 0x0
    field public static final int DEFAULT_NETWORK_YES = 1; // 0x1
    field public static final String IFACE_VT = "vt_data0";
    field public static final int METERED_ALL = -1; // 0xffffffff
    field public static final int METERED_NO = 0; // 0x0
    field public static final int METERED_YES = 1; // 0x1
    field public static final int ROAMING_ALL = -1; // 0xffffffff
    field public static final int ROAMING_NO = 0; // 0x0
    field public static final int ROAMING_YES = 1; // 0x1
    field public static final int SET_ALL = -1; // 0xffffffff
    field public static final int SET_DEFAULT = 0; // 0x0
    field public static final int SET_FOREGROUND = 1; // 0x1
    field public static final int TAG_NONE = 0; // 0x0
    field public static final int UID_ALL = -1; // 0xffffffff
    field public static final int UID_TETHERING = -5; // 0xfffffffb
  }

  public static class NetworkStats.Entry {
    ctor public NetworkStats.Entry(@Nullable String, int, int, int, int, int, int, long, long, long, long, long);
    method public int getDefaultNetwork();
    method public int getMetered();
    method public long getOperations();
    method public int getRoaming();
    method public long getRxBytes();
    method public long getRxPackets();
    method public int getSet();
    method public int getTag();
    method public long getTxBytes();
    method public long getTxPackets();
    method public int getUid();
  }

  public class TrafficStats {
    method public static void setThreadStatsTagApp();
    method public static void setThreadStatsTagBackup();
    method public static void setThreadStatsTagRestore();
    field public static final int TAG_NETWORK_STACK_IMPERSONATION_RANGE_END = -113; // 0xffffff8f
    field public static final int TAG_NETWORK_STACK_IMPERSONATION_RANGE_START = -128; // 0xffffff80
    field public static final int TAG_NETWORK_STACK_RANGE_END = -257; // 0xfffffeff
    field public static final int TAG_NETWORK_STACK_RANGE_START = -768; // 0xfffffd00
    field public static final int TAG_SYSTEM_IMPERSONATION_RANGE_END = -241; // 0xffffff0f
    field public static final int TAG_SYSTEM_IMPERSONATION_RANGE_START = -256; // 0xffffff00
  }

}

package android.net.netstats.provider {

  public abstract class NetworkStatsProvider {
    ctor public NetworkStatsProvider();
    method public void notifyAlertReached();
    method public void notifyLimitReached();
    method public void notifyStatsUpdated(int, @NonNull android.net.NetworkStats, @NonNull android.net.NetworkStats);
    method public void notifyWarningReached();
    method public abstract void onRequestStatsUpdate(int);
    method public abstract void onSetAlert(long);
    method public abstract void onSetLimit(@NonNull String, long);
    method public void onSetWarningAndLimit(@NonNull String, long, long);
    field public static final int QUOTA_UNLIMITED = -1; // 0xffffffff
  }

}

package android.net.nsd {

  public final class NsdManager {
    method @FlaggedApi("com.android.net.flags.register_nsd_offload_engine_api") @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK}) public void registerOffloadEngine(@NonNull String, long, long, @NonNull java.util.concurrent.Executor, @NonNull android.net.nsd.OffloadEngine);
    method @FlaggedApi("com.android.net.flags.register_nsd_offload_engine_api") @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK}) public void unregisterOffloadEngine(@NonNull android.net.nsd.OffloadEngine);
  }

  @FlaggedApi("com.android.net.flags.register_nsd_offload_engine_api") public interface OffloadEngine {
    method public void onOffloadServiceRemoved(@NonNull android.net.nsd.OffloadServiceInfo);
    method public void onOffloadServiceUpdated(@NonNull android.net.nsd.OffloadServiceInfo);
    field public static final int OFFLOAD_CAPABILITY_BYPASS_MULTICAST_LOCK = 1; // 0x1
    field public static final int OFFLOAD_TYPE_FILTER_QUERIES = 2; // 0x2
    field public static final int OFFLOAD_TYPE_FILTER_REPLIES = 4; // 0x4
    field public static final int OFFLOAD_TYPE_REPLY = 1; // 0x1
  }

  @FlaggedApi("com.android.net.flags.register_nsd_offload_engine_api") public final class OffloadServiceInfo implements android.os.Parcelable {
    ctor public OffloadServiceInfo(@NonNull android.net.nsd.OffloadServiceInfo.Key, @NonNull java.util.List<java.lang.String>, @NonNull String, @Nullable byte[], @IntRange(from=0, to=java.lang.Integer.MAX_VALUE) int, long);
    method public int describeContents();
    method @NonNull public String getHostname();
    method @NonNull public android.net.nsd.OffloadServiceInfo.Key getKey();
    method @Nullable public byte[] getOffloadPayload();
    method public long getOffloadType();
    method public int getPriority();
    method @NonNull public java.util.List<java.lang.String> getSubtypes();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.net.nsd.OffloadServiceInfo> CREATOR;
  }

  public static final class OffloadServiceInfo.Key implements android.os.Parcelable {
    ctor public OffloadServiceInfo.Key(@NonNull String, @NonNull String);
    method public int describeContents();
    method @NonNull public String getServiceName();
    method @NonNull public String getServiceType();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.net.nsd.OffloadServiceInfo.Key> CREATOR;
  }

}

package android.net.thread {

  @FlaggedApi("com.android.net.thread.flags.thread_enabled") public final class ActiveOperationalDataset implements android.os.Parcelable {
    method public int describeContents();
    method @NonNull public static android.net.thread.ActiveOperationalDataset fromThreadTlvs(@NonNull byte[]);
    method @NonNull public android.net.thread.OperationalDatasetTimestamp getActiveTimestamp();
    method @IntRange(from=0, to=65535) public int getChannel();
    method @NonNull @Size(min=1) public android.util.SparseArray<byte[]> getChannelMask();
    method @IntRange(from=0, to=255) public int getChannelPage();
    method @NonNull @Size(android.net.thread.ActiveOperationalDataset.LENGTH_EXTENDED_PAN_ID) public byte[] getExtendedPanId();
    method @NonNull public android.net.IpPrefix getMeshLocalPrefix();
    method @NonNull @Size(android.net.thread.ActiveOperationalDataset.LENGTH_NETWORK_KEY) public byte[] getNetworkKey();
    method @NonNull @Size(min=android.net.thread.ActiveOperationalDataset.LENGTH_MIN_NETWORK_NAME_BYTES, max=android.net.thread.ActiveOperationalDataset.LENGTH_MAX_NETWORK_NAME_BYTES) public String getNetworkName();
    method @IntRange(from=0, to=65534) public int getPanId();
    method @NonNull @Size(android.net.thread.ActiveOperationalDataset.LENGTH_PSKC) public byte[] getPskc();
    method @NonNull public android.net.thread.ActiveOperationalDataset.SecurityPolicy getSecurityPolicy();
    method @NonNull public byte[] toThreadTlvs();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field public static final int CHANNEL_MAX_24_GHZ = 26; // 0x1a
    field public static final int CHANNEL_MIN_24_GHZ = 11; // 0xb
    field public static final int CHANNEL_PAGE_24_GHZ = 0; // 0x0
    field @NonNull public static final android.os.Parcelable.Creator<android.net.thread.ActiveOperationalDataset> CREATOR;
    field public static final int LENGTH_EXTENDED_PAN_ID = 8; // 0x8
    field public static final int LENGTH_MAX_DATASET_TLVS = 254; // 0xfe
    field public static final int LENGTH_MAX_NETWORK_NAME_BYTES = 16; // 0x10
    field public static final int LENGTH_MESH_LOCAL_PREFIX_BITS = 64; // 0x40
    field public static final int LENGTH_MIN_NETWORK_NAME_BYTES = 1; // 0x1
    field public static final int LENGTH_NETWORK_KEY = 16; // 0x10
    field public static final int LENGTH_PSKC = 16; // 0x10
  }

  public static final class ActiveOperationalDataset.Builder {
    ctor public ActiveOperationalDataset.Builder(@NonNull android.net.thread.ActiveOperationalDataset);
    ctor public ActiveOperationalDataset.Builder();
    method @NonNull public android.net.thread.ActiveOperationalDataset build();
    method @NonNull public android.net.thread.ActiveOperationalDataset.Builder setActiveTimestamp(@NonNull android.net.thread.OperationalDatasetTimestamp);
    method @NonNull public android.net.thread.ActiveOperationalDataset.Builder setChannel(@IntRange(from=0, to=255) int, @IntRange(from=0, to=65535) int);
    method @NonNull public android.net.thread.ActiveOperationalDataset.Builder setChannelMask(@NonNull @Size(min=1) android.util.SparseArray<byte[]>);
    method @NonNull public android.net.thread.ActiveOperationalDataset.Builder setExtendedPanId(@NonNull @Size(android.net.thread.ActiveOperationalDataset.LENGTH_EXTENDED_PAN_ID) byte[]);
    method @NonNull public android.net.thread.ActiveOperationalDataset.Builder setMeshLocalPrefix(@NonNull android.net.IpPrefix);
    method @NonNull public android.net.thread.ActiveOperationalDataset.Builder setNetworkKey(@NonNull @Size(android.net.thread.ActiveOperationalDataset.LENGTH_NETWORK_KEY) byte[]);
    method @NonNull public android.net.thread.ActiveOperationalDataset.Builder setNetworkName(@NonNull @Size(min=android.net.thread.ActiveOperationalDataset.LENGTH_MIN_NETWORK_NAME_BYTES, max=android.net.thread.ActiveOperationalDataset.LENGTH_MAX_NETWORK_NAME_BYTES) String);
    method @NonNull public android.net.thread.ActiveOperationalDataset.Builder setPanId(@IntRange(from=0, to=65534) int);
    method @NonNull public android.net.thread.ActiveOperationalDataset.Builder setPskc(@NonNull @Size(android.net.thread.ActiveOperationalDataset.LENGTH_PSKC) byte[]);
    method @NonNull public android.net.thread.ActiveOperationalDataset.Builder setSecurityPolicy(@NonNull android.net.thread.ActiveOperationalDataset.SecurityPolicy);
  }

  public static final class ActiveOperationalDataset.SecurityPolicy {
    ctor public ActiveOperationalDataset.SecurityPolicy(@IntRange(from=1, to=65535) int, @NonNull @Size(min=android.net.thread.ActiveOperationalDataset.SecurityPolicy.LENGTH_MIN_SECURITY_POLICY_FLAGS) byte[]);
    method @NonNull @Size(min=android.net.thread.ActiveOperationalDataset.SecurityPolicy.LENGTH_MIN_SECURITY_POLICY_FLAGS) public byte[] getFlags();
    method @IntRange(from=1, to=65535) public int getRotationTimeHours();
    field public static final int DEFAULT_ROTATION_TIME_HOURS = 672; // 0x2a0
    field public static final int LENGTH_MIN_SECURITY_POLICY_FLAGS = 1; // 0x1
  }

  @FlaggedApi("com.android.net.thread.flags.thread_enabled") public final class OperationalDatasetTimestamp {
    ctor public OperationalDatasetTimestamp(@IntRange(from=0, to=281474976710655L) long, @IntRange(from=0, to=32767) int, boolean);
    method @NonNull public static android.net.thread.OperationalDatasetTimestamp fromInstant(@NonNull java.time.Instant);
    method @IntRange(from=0, to=281474976710655L) public long getSeconds();
    method @IntRange(from=0, to=32767) public int getTicks();
    method public boolean isAuthoritativeSource();
    method @NonNull public java.time.Instant toInstant();
  }

  @FlaggedApi("com.android.net.thread.flags.thread_enabled") public final class PendingOperationalDataset implements android.os.Parcelable {
    ctor public PendingOperationalDataset(@NonNull android.net.thread.ActiveOperationalDataset, @NonNull android.net.thread.OperationalDatasetTimestamp, @NonNull java.time.Duration);
    method public int describeContents();
    method @NonNull public static android.net.thread.PendingOperationalDataset fromThreadTlvs(@NonNull byte[]);
    method @NonNull public android.net.thread.ActiveOperationalDataset getActiveOperationalDataset();
    method @NonNull public java.time.Duration getDelayTimer();
    method @NonNull public android.net.thread.OperationalDatasetTimestamp getPendingTimestamp();
    method @NonNull public byte[] toThreadTlvs();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.net.thread.PendingOperationalDataset> CREATOR;
  }

  @FlaggedApi("com.android.net.thread.flags.thread_enabled") public final class ThreadNetworkController {
    method public void createRandomizedDataset(@NonNull String, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<android.net.thread.ActiveOperationalDataset,android.net.thread.ThreadNetworkException>);
    method public int getThreadVersion();
    method public static boolean isAttached(int);
    method @RequiresPermission("android.permission.THREAD_NETWORK_PRIVILEGED") public void join(@NonNull android.net.thread.ActiveOperationalDataset, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.net.thread.ThreadNetworkException>);
    method @RequiresPermission("android.permission.THREAD_NETWORK_PRIVILEGED") public void leave(@NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.net.thread.ThreadNetworkException>);
    method @RequiresPermission(allOf={android.Manifest.permission.ACCESS_NETWORK_STATE, "android.permission.THREAD_NETWORK_PRIVILEGED"}) public void registerOperationalDatasetCallback(@NonNull java.util.concurrent.Executor, @NonNull android.net.thread.ThreadNetworkController.OperationalDatasetCallback);
    method @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) public void registerStateCallback(@NonNull java.util.concurrent.Executor, @NonNull android.net.thread.ThreadNetworkController.StateCallback);
    method @RequiresPermission("android.permission.THREAD_NETWORK_PRIVILEGED") public void scheduleMigration(@NonNull android.net.thread.PendingOperationalDataset, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.net.thread.ThreadNetworkException>);
    method @RequiresPermission("android.permission.THREAD_NETWORK_PRIVILEGED") public void setEnabled(boolean, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.net.thread.ThreadNetworkException>);
    method @RequiresPermission(allOf={android.Manifest.permission.ACCESS_NETWORK_STATE, "android.permission.THREAD_NETWORK_PRIVILEGED"}) public void unregisterOperationalDatasetCallback(@NonNull android.net.thread.ThreadNetworkController.OperationalDatasetCallback);
    method @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) public void unregisterStateCallback(@NonNull android.net.thread.ThreadNetworkController.StateCallback);
    field public static final int DEVICE_ROLE_CHILD = 2; // 0x2
    field public static final int DEVICE_ROLE_DETACHED = 1; // 0x1
    field public static final int DEVICE_ROLE_LEADER = 4; // 0x4
    field public static final int DEVICE_ROLE_ROUTER = 3; // 0x3
    field public static final int DEVICE_ROLE_STOPPED = 0; // 0x0
    field public static final int STATE_DISABLED = 0; // 0x0
    field public static final int STATE_DISABLING = 2; // 0x2
    field public static final int STATE_ENABLED = 1; // 0x1
    field public static final int THREAD_VERSION_1_3 = 4; // 0x4
  }

  public static interface ThreadNetworkController.OperationalDatasetCallback {
    method public void onActiveOperationalDatasetChanged(@Nullable android.net.thread.ActiveOperationalDataset);
    method public default void onPendingOperationalDatasetChanged(@Nullable android.net.thread.PendingOperationalDataset);
  }

  public static interface ThreadNetworkController.StateCallback {
    method public void onDeviceRoleChanged(int);
    method public default void onPartitionIdChanged(long);
    method public default void onThreadEnableStateChanged(int);
  }

  @FlaggedApi("com.android.net.thread.flags.thread_enabled") public class ThreadNetworkException extends java.lang.Exception {
    ctor public ThreadNetworkException(int, @NonNull String);
    method public int getErrorCode();
    field public static final int ERROR_ABORTED = 2; // 0x2
    field public static final int ERROR_BUSY = 5; // 0x5
    field public static final int ERROR_FAILED_PRECONDITION = 6; // 0x6
    field public static final int ERROR_INTERNAL_ERROR = 1; // 0x1
    field public static final int ERROR_REJECTED_BY_PEER = 8; // 0x8
    field public static final int ERROR_RESOURCE_EXHAUSTED = 10; // 0xa
    field public static final int ERROR_RESPONSE_BAD_FORMAT = 9; // 0x9
    field public static final int ERROR_THREAD_DISABLED = 12; // 0xc
    field public static final int ERROR_TIMEOUT = 3; // 0x3
    field public static final int ERROR_UNAVAILABLE = 4; // 0x4
    field public static final int ERROR_UNKNOWN = 11; // 0xb
    field public static final int ERROR_UNSUPPORTED_CHANNEL = 7; // 0x7
  }

  @FlaggedApi("com.android.net.thread.flags.thread_enabled") public final class ThreadNetworkManager {
    method @NonNull public java.util.List<android.net.thread.ThreadNetworkController> getAllThreadNetworkControllers();
  }

}

