import { NativeEventEmitter } from 'react-native'; import { CaptivePortalState, IpConfiguration, NetworkCapability, IpType, NetworkInterface, NetworkInterfaceType, NetworkState, NetworkProxyInfo, UnifiedNetworkEventData, UnifiedNetworkState, Status } from './types/NetCommon'; /** * @brief callback class for applications to receive notifications on changes * in network state, captive portal, and to unified network state. * @remarks Applications must implement 'NetworkEventCallback' and * register it via {@link NetworkManager.registerNetworkEventCallback} to * receive the notifications. */ export declare class NetworkEventCallback { /** * @brief Called when a network interface changes the network state. * @param networkInterfaceId - the identifier of the network interface. * @param type - IP Type. * @param oldState - previous network state before the network state changes. * @param newState - new network state after the network state changes */ onNetworkStateChanged: ((networkInterfaceId: number, type: IpType, oldState: NetworkState, newState: NetworkState) => void) | undefined; /** * @brief Called when a new captive portal state is available. * @param networkInterfaceId - the identifier of the network interface. * @param result - new captive portal state. */ onCaptivePortalEvaluated: ((networkInterfaceId: number, result: CaptivePortalState) => void) | undefined; /** * @brief Called when an unified network event happens. * @param networkInterfaceId - the identifier of the network interface * where the unified network event is raised. * @param eventCode - {@link UnifiedNetworkState} indicates the unified * network event code. * @param data - extra data for the event. */ onUnifiedNetworkEvent?: ((networkInterfaceId: number, eventCode: UnifiedNetworkState, data?: UnifiedNetworkEventData) => void) | undefined; } /** * @brief 'NetworkManager' allows applications to manage network interfaces. * @remarks 'NetworkManager' provides APIs to monitor network state * changes and network events, to enable or disable network interfaces, * to query current network status and information. */ export declare class NetworkManager extends NativeEventEmitter { private static sNetworkEventCallback; private captivePortalEvaluatedListener?; private onNetworkStateChangedListener?; private onUnifiedNetworkEventReceivedListener?; constructor(); /** * @brief Get the major version. * @returns the major version. */ static getMajorVersion(): number; /** * @brief Get the minor version. * @returns the minor version. */ static getMinorVersion(): number; /** * @brief Get the patch version. * @returns the patch version. */ static getPatchVersion(): number; /** * @brief Register {@link NetworkEventCallback}. The caller must implement * a {@link NetworkEventCallback} to receive notifications about changes * in the network status, captive portal state, and unified events. * @param callback - a callback which will be called back to notify * the caller of the network state change, captive portal change, and unified * events. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. */ registerNetworkEventCallback(callback: NetworkEventCallback): Status; /** * @brief Unregister {@link NetworkEventCallback}. */ unregisterNetworkEventCallback(): void; /** * @brief Get an array of {@link NetworkInterface} * for {@link NetworkInterfaceType}. * @remarks The given array of {@link NetworkInterface} * will be reset and new {@link NetworkInterface} will be added. * @param type - {@link NetworkInterfaceType} to query. * {@link NetworkInterfaceType.NONE} will query all types of * network interfaces. * @param interfaces - the array of {@link NetworkInterface} to be set. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. */ getNetworkInterfaces(type: NetworkInterfaceType, interfaces: Array): Status; /** * @brief Get the default active {@link NetworkInterface} utilized for * Internet access. * @param networkInterface - {@link NetworkInterface} to be set. This * value cannot be null or undefined. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. */ getActiveNetworkInterface(networkInterface: NetworkInterface): Status; /** * @brief Enable or disable network interface. * @remarks App needs to declare com.amazon.privilege.net-admin in application * manifest. * @param networkInterfaceId - the identifier of the network interface * to query. * @param enableDisable - enable or disable the network interface. * @param persist - persistent after restart. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. * - {@link Status.PERMISSION_DENIED} if the caller does not have * required permission. */ enableNetworkInterface(networkInterfaceId: number, enableDisable: boolean, persist: boolean): Status; /** * @brief Check whether the given network interface is enabled. * @param networkInterfaceId - the identifier of the network interface * to query. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. * - {@link Status.PERMISSION_DENIED} if the caller does not have * required permission. * * {@link boolean} true if the network interface is enabled. * * {@link boolean} true if the network interface is is persistently enabled * after restart. */ isNetworkInterfaceEnabled(networkInterfaceId: number): [Status, boolean, boolean]; /** * @brief Retrieve IP configuration from the network interface. * @param networkInterfaceId - the identifier of the network interface * to query. Use 0 for the default network interface. * @param type - IP version to query. * @param ipConfiguration - {@link IpConfiguration} that contains * the IP information. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. */ getIpConfig(networkInterfaceId: number, type: IpType, ipConfiguration: IpConfiguration): Status; /** * @brief Set IP configuration on the network interface. * @remarks App needs to declare com.amazon.network.privilege.net-admin in * application manifest. * @param networkInterfaceId - the identifier of the network interface * to query. Use 0 for the default network interface. * @param ipConfiguration - {@link IpConfiguration} that contains * the IP information to set. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. * - {@link Status.PERMISSION_DENIED} if the caller does not have * required permission. */ setIpConfig(networkInterfaceId: number, ipConfiguration: IpConfiguration): Status; /** * @brief Returns network status of the network interface. * @param networkInterfaceId - the identifier of the network interface * to query. Use 0 for the default network interface. * @param type - IP version (IPv4 or IPv6). * @returns * {@link Status} * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. * * {@link NetworkState} the network status of the given network interface. */ getNetworkState(networkInterfaceId: number, type: IpType): [Status, NetworkState]; /** * @brief Get the MAC address of the network interface. * @remarks App needs to be signed and declare * com.amazon.privilege.restricted-net-info in application manifest. * @param networkInterfaceId - the identifier of the network interface * to query. Use 0 for the default network interface. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. * * {@link string} the MAC Address. */ getMacAddress(networkInterfaceId: number): [Status, string]; /** * @brief Evaluate a captive portal asynchronously. * @remarks registered {@link NetworkEventCallback#onCaptivePortalEvaluated} * will be called when the requested captive portal evaluation completes. * App needs to declare com.amazon.network.privilege.net-admin in * application manifest. * @param networkInterfaceId - the identifier of the network interface * to evaluate a captive portal. Use 0 for the default network interface. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. * - {@link Status.PERMISSION_DENIED} if the caller does not have * required permission. */ evaluateCaptivePortal(networkInterfaceId: number): Status; /** * @brief Get the captive portal state from the network interface. * @param networkInterfaceId - the identifier of the network interface * to query the current captive portal state. Use 0 for the default network * interface. * @returns {@link CaptivePortalState} of the given network interface. */ getCaptivePortalState(networkInterfaceId: number): CaptivePortalState; /** * @brief Get {@link NetworkCapabilities} from the network interface. * @param networkInterfaceId - the identifier of the network interface * to query on. * @param capabilities - the array of {@link NetworkCapability} to be set. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. */ getNetworkCapabilities(networkInterfaceId: number, capabilities: Array): Status; /** * @brief Get the link speed for the network interface in bps. * @param networkInterfaceId - the identifier of the network interface * to query. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. * * {@link string} the link speed in bps. */ getLinkSpeed(networkInterfaceId: number): [Status, String]; /** * @brief Set network proxy information. * @remarks App needs to declare com.amazon.network.privilege.net-admin in * application manifest. * @param networkInterfaceId - the identifier of the network interface * to query. Use 0 for the default network interface. * @param info - {@link NetworkProxyInfo} that contains * network proxy information to set on the network interface. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. * - {@link Status.PERMISSION_DENIED} if the caller does not have * required permission. */ setNetworkProxy(networkInterfaceId: number, info: NetworkProxyInfo): Status; /** * @brief Get network proxy information from current active network interface. * @param networkInterfaceId - the identifier of the network interface * to query. Use 0 for the default network interface. * @param info - {@link NetworkProxyInfo} that contains Network * Proxy information of current active interface. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. * - {@link Status.PERMISSION_DENIED} if the caller does not have * required permission. */ getNetworkProxy(networkInterfaceId: number, info: NetworkProxyInfo): Status; /** * @brief Get the network speed for the network interface in bps. * @param networkInterfaceId - the identifier of the network interface * to query. Use 0 for the default network interface. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. * * {@link String} network speed in bps. */ getNetworkSpeed(networkInterfaceId: number): [Status, String]; /** * @brief Get the unified network state for the network interface. * @param networkInterfaceId - the identifier of the network interface * to query. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. * * {@link String} unified network state. */ getUnifiedNetworkState(networkInterfaceId: number): [Status, UnifiedNetworkState]; private captivePortalEventDispatcher; private networkStateEventDispatcher; private unifiedNetworkEventDispatcher; }