// 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 public void queryOffloadCapability(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.nearby.OffloadCapability>);
    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);
  }

  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();
  }

}

