Android 网络服务类提供的服务接口
1. NetworkManagementService
继承了 INetworkManagementService.Stub,因此提供对应的 AIDL 定义的服务:
在 frameworks/base/core/java/android/os/INetworkManagementService.aidl 中定义
interface INetworkManagementService
{/* Register and unregister an observer to receive events. */
void registerObserver(INetworkManagementEventObserver obs);
void unregisterObserver(INetworkManagementEventObserver obs);/* Returns a list of currently known network interfaces */
String[] listInterfaces();/* Retrieves the specified interface config */
InterfaceConfiguration getInterfaceConfig(String iface);/* Sets the configuration of the specified interface */
void setInterfaceConfig(String iface, in InterfaceConfiguration cfg);/* Clear all IP addresses on the specified interface */
void clearInterfaceAddresses(String iface);/* Set interface up or down */
void setInterfaceDown(String iface);
void setInterfaceUp(String iface);... /* IPv6 related */
/* Add or remove the specified route to the interface.*/
void addRoute(int netId, in RouteInfo route);
void removeRoute(int netId, in RouteInfo route);/* Set the specified MTU size */
void setMtu(String iface, int mtu);/* Shuts down the service */
void shutdown();....../* tethering related */
/* Set or remove quota for an interface. */
void setInterfaceQuota(String iface, long quotaBytes);
void removeInterfaceQuota(String iface);/* Set or remove alert for an interface; requires that iface already has quota. */
void setInterfaceAlert(String iface, long alertBytes);
void removeInterfaceAlert(String iface);/* Set alert across all interfaces. */
void setGlobalAlert(long alertBytes);/* Control network activity of a UID over interfaces with a quota limit. */
void setUidMeteredNetworkDenylist(int uid, boolean enable);
void setUidMeteredNetworkAllowlist(int uid, boolean enable);
boolean setDataSaverModeEnabled(boolean enable);void setUidCleartextNetworkPolicy(int uid, int policy);
/* Return status of bandwidth control module. */
boolean isBandwidthControlEnabled();/* Sets or remove idletimer for an interface.
*
* This either initializes a new idletimer or increases its
* reference-counting if an idletimer already exists for given
* {@code iface}.
*
* {@code type} is the type of the interface, such as TYPE_MOBILE.
*
* Every {@code addIdleTimer} should be paired with a
* {@link removeIdleTimer} to cleanup when the network disconnects.
*/
void addIdleTimer(String iface, int timeout, int type);
void removeIdleTimer(String iface);void setFirewallEnabled(boolean enabled);
boolean isFirewallEnabled();
void setFirewallInterfaceRule(String iface, boolean allow);
void setFirewallUidRule(int chain, int uid, int rule);
void setFirewallUidRules(int chain, in int[] uids, in int[] rules);
void setFirewallChainEnabled(int chain, boolean enable);/* VPN related */
void addVpnUidRanges(int netId, in UidRange[] ranges);
void removeVpnUidRanges(int netId, in UidRange[] ranges);/* Start listening for mobile activity state changes. */
void registerNetworkActivityListener(INetworkActivityListener listener);/* Stop listening for mobile activity state changes.*/
void unregisterNetworkActivityListener(INetworkActivityListener listener);/* Check whether the mobile radio is currently active. */
boolean isNetworkActive();/* Add or remove an interface to a network. */
void addInterfaceToNetwork(String iface, int netId);
void removeInterfaceFromNetwork(String iface, int netId);void addLegacyRouteForNetId(int netId, in RouteInfo routeInfo, int uid);
void setDefaultNetId(int netId);
void clearDefaultNetId();/* Set permission for a network.
* @param permission PERMISSION_NONE to clear permissions.
* PERMISSION_NETWORK or PERMISSION_SYSTEM to set permission.
*/
void setNetworkPermission(int netId, int permission);/* Allow or deny UID to call protect(). */
void allowProtect(int uid);
void denyProtect(int uid);void addInterfaceToLocalNetwork(String iface, in List<RouteInfo> routes);
void removeInterfaceFromLocalNetwork(String iface);
int removeRoutesFromLocalNetwork(in List<RouteInfo> routes);boolean isNetworkRestricted(int uid);
}
2. WIFI_SERVICE_CLASS 服务
初始化发生在 WifiService 类,实际实现在 WifiServiceImpl 类,而继承了 BaseWifiService,实现了 IWifiManager (IWifiManager.Stub)的接口,即为对客户端层面需要提供的服务。
IWifiManager 定义如下:
文件为:frameworks/base/wifi/java/android/net/wifi/IWifiManager.aidl
interface IWifiManager
{
long getSupportedFeatures();oneway void getWifiActivityEnergyInfoAsync(in IOnWifiActivityEnergyInfoListener listener);
ParceledListSlice getConfiguredNetworks(String packageName, String featureId);
ParceledListSlice getPrivilegedConfiguredNetworks(String packageName, String featureId);
Map getAllMatchingFqdnsForScanResults(in List<ScanResult> scanResult);
Map getMatchingOsuProviders(in List<ScanResult> scanResult);
Map getMatchingPasspointConfigsForOsuProviders(in List<OsuProvider> osuProviders);
int addOrUpdateNetwork(in WifiConfiguration config, String packageName);
boolean addOrUpdatePasspointConfiguration(in PasspointConfiguration config, String packageName);
boolean removePasspointConfiguration(in String fqdn, String packageName);
List<PasspointConfiguration> getPasspointConfigurations(in String packageName);
List<WifiConfiguration> getWifiConfigsForPasspointProfiles(in List<String> fqdnList);
void queryPasspointIcon(long bssid, String fileName);
int matchProviderWithCurrentNetwork(String fqdn);
void deauthenticateNetwork(long holdoff, boolean ess);
boolean removeNetwork(int netId, String packageName);
boolean enableNetwork(int netId, boolean disableOthers, String packageName);
boolean disableNetwork(int netId, String packageName);
void allowAutojoinGlobal(boolean choice);
void allowAutojoin(int netId, boolean choice);
void allowAutojoinPasspoint(String fqdn, boolean enableAutoJoin);
void setMacRandomizationSettingPasspointEnabled(String fqdn, boolean enable);
void setPasspointMeteredOverride(String fqdn, int meteredOverride);
boolean startScan(String packageName, String featureId);
List<ScanResult> getScanResults(String callingPackage, String callingFeatureId);
boolean disconnect(String packageName);
boolean reconnect(String packageName);
boolean reassociate(String packageName);
WifiInfo getConnectionInfo(String callingPackage, String callingFeatureId);
boolean setWifiEnabled(String packageName, boolean enable);
int getWifiEnabledState();
String getCountryCode();
boolean is5GHzBandSupported();
boolean is6GHzBandSupported();
boolean isWifiStandardSupported(int standard);
DhcpInfo getDhcpInfo();
void setScanAlwaysAvailable(boolean isAvailable);
boolean isScanAlwaysAvailable();
boolean acquireWifiLock(IBinder lock, int lockType, String tag, in WorkSource ws);
void updateWifiLockWorkSource(IBinder lock, in WorkSource ws);
boolean releaseWifiLock(IBinder lock);
void initializeMulticastFiltering();
boolean isMulticastEnabled();
void acquireMulticastLock(IBinder binder, String tag);
void releaseMulticastLock(String tag);
void updateInterfaceIpState(String ifaceName, int mode);
boolean startSoftAp(in WifiConfiguration wifiConfig);
boolean startTetheredHotspot(in SoftApConfiguration softApConfig);
boolean stopSoftAp();
int startLocalOnlyHotspot(in ILocalOnlyHotspotCallback callback, String packageName,
String featureId, in SoftApConfiguration customConfig);void stopLocalOnlyHotspot();
void startWatchLocalOnlyHotspot(in ILocalOnlyHotspotCallback callback);
void stopWatchLocalOnlyHotspot();
@UnsupportedAppUsage
int getWifiApEnabledState();@UnsupportedAppUsage
WifiConfiguration getWifiApConfiguration();SoftApConfiguration getSoftApConfiguration();
boolean setWifiApConfiguration(in WifiConfiguration wifiConfig, String packageName);
boolean setSoftApConfiguration(in SoftApConfiguration softApConfig, String packageName);
void notifyUserOfApBandConversion(String packageName);
void enableTdls(String remoteIPAddress, boolean enable);
void enableTdlsWithMacAddress(String remoteMacAddress, boolean enable);
String getCurrentNetworkWpsNfcConfigurationToken();
void enableVerboseLogging(int verbose);
int getVerboseLoggingLevel();
void disableEphemeralNetwork(String SSID, String packageName);
void factoryReset(String packageName);
@UnsupportedAppUsage
Network getCurrentNetwork();byte[] retrieveBackupData();
void restoreBackupData(in byte[] data);
byte[] retrieveSoftApBackupData();
SoftApConfiguration restoreSoftApBackupData(in byte[] data);
void restoreSupplicantBackupData(in byte[] supplicantData, in byte[] ipConfigData);
void startSubscriptionProvisioning(in OsuProvider provider, in IProvisioningCallback callback);
void registerSoftApCallback(in IBinder binder, in ISoftApCallback callback, int callbackIdentifier);
void unregisterSoftApCallback(int callbackIdentifier);
void addOnWifiUsabilityStatsListener(in IBinder binder, in IOnWifiUsabilityStatsListener listener, int listenerIdentifier);
void removeOnWifiUsabilityStatsListener(int listenerIdentifier);
void registerTrafficStateCallback(in IBinder binder, in ITrafficStateCallback callback, int callbackIdentifier);
void unregisterTrafficStateCallback(int callbackIdentifier);
void registerNetworkRequestMatchCallback(in IBinder binder, in INetworkRequestMatchCallback callback, int callbackIdentifier);
void unregisterNetworkRequestMatchCallback(int callbackIdentifier);
int addNetworkSuggestions(in List<WifiNetworkSuggestion> networkSuggestions, in String packageName,
in String featureId);int removeNetworkSuggestions(in List<WifiNetworkSuggestion> networkSuggestions, in String packageName);
List<WifiNetworkSuggestion> getNetworkSuggestions(in String packageName);
String[] getFactoryMacAddresses();
void setDeviceMobilityState(int state);
void startDppAsConfiguratorInitiator(in IBinder binder, in String enrolleeUri,
int selectedNetworkId, int netRole, in IDppCallback callback);void startDppAsEnrolleeInitiator(in IBinder binder, in String configuratorUri,
in IDppCallback callback);void stopDppSession();
void updateWifiUsabilityScore(int seqNum, int score, int predictionHorizonSec);
oneway void connect(in WifiConfiguration config, int netId, in IBinder binder, in IActionListener listener, int callbackIdentifier);
oneway void save(in WifiConfiguration config, in IBinder binder, in IActionListener listener, int callbackIdentifier);
oneway void forget(int netId, in IBinder binder, in IActionListener listener, int callbackIdentifier);
void registerScanResultsCallback(in IScanResultsCallback callback);
void unregisterScanResultsCallback(in IScanResultsCallback callback);
void registerSuggestionConnectionStatusListener(in IBinder binder, in ISuggestionConnectionStatusListener listener, int listenerIdentifier, String packageName, String featureId);
void unregisterSuggestionConnectionStatusListener(int listenerIdentifier, String packageName);
int calculateSignalLevel(int rssi);
List<WifiConfiguration> getWifiConfigForMatchedNetworkSuggestionsSharedWithUser(in List<ScanResult> scanResults);
boolean setWifiConnectedNetworkScorer(in IBinder binder, in IWifiConnectedNetworkScorer scorer);
void clearWifiConnectedNetworkScorer();
/**
* Return the Map of {@link WifiNetworkSuggestion} and the list of <ScanResult>
*/
Map getMatchingScanResults(in List<WifiNetworkSuggestion> networkSuggestions, in List<ScanResult> scanResults, String callingPackage, String callingFeatureId);void setScanThrottleEnabled(boolean enable);
boolean isScanThrottleEnabled();
Map getAllMatchingPasspointProfilesForScanResults(in List<ScanResult> scanResult);
void setAutoWakeupEnabled(boolean enable);
boolean isAutoWakeupEnabled();
}
3. WifiScanningService 服务
同样的服务在 WifiScanningService 类初始化,在 WifiScanningServiceImpl 类实现,直接继承了 IWifiScanner.Stub,实现了 IWifiScanner 的接口。它的定义很简单,只有两个接口:
interface IWifiScanner
{
Messenger getMessenger();Bundle getAvailableChannels(int band, String packageName, String featureId);
}
其原因在于 WifiScanningService 于 WifiScanner(客户端)之间并不是都通过 binder 的接口调用方式进行服务提供,而是建立了 AsyncChannel 通信渠道实现了相互之间的双向通信,在WifiScanningService 服务端通过 ClientHandler 处理相应的请求路由过程,三个扫描状态机控制扫描状态。后面再做详细分析。
4. ConnectivityService 服务
由 ConnectivityServiceInitializer 类初始化,实现在 ConnectivityService 类,继承并实现了 IConnectivityManager.Stub 的方法来完成相关的服务。IConnectivityManager 定义如下:
文件在 frameworks/base/core/java/android/net/IConnectivityManager.aidl
interface IConnectivityManager
{
Network getActiveNetwork();
Network getActiveNetworkForUid(int uid, boolean ignoreBlocked);
@UnsupportedAppUsage
NetworkInfo getActiveNetworkInfo();
NetworkInfo getActiveNetworkInfoForUid(int uid, boolean ignoreBlocked);
@UnsupportedAppUsage(maxTargetSdk = 28)
NetworkInfo getNetworkInfo(int networkType);
NetworkInfo getNetworkInfoForUid(in Network network, int uid, boolean ignoreBlocked);
@UnsupportedAppUsage
NetworkInfo[] getAllNetworkInfo();
Network getNetworkForType(int networkType);
Network[] getAllNetworks();
NetworkCapabilities[] getDefaultNetworkCapabilitiesForUser(
int userId, String callingPackageName);boolean isNetworkSupported(int networkType);
@UnsupportedAppUsage
LinkProperties getActiveLinkProperties();
LinkProperties getLinkPropertiesForType(int networkType);
LinkProperties getLinkProperties(in Network network);NetworkCapabilities getNetworkCapabilities(in Network network, String callingPackageName);
@UnsupportedAppUsage
NetworkState[] getAllNetworkState();NetworkQuotaInfo getActiveNetworkQuotaInfo();
boolean isActiveNetworkMetered();boolean requestRouteToHostAddress(int networkType, in byte[] hostAddress,
String callingPackageName, String callingAttributionTag);@UnsupportedAppUsage(maxTargetSdk = 29,
publicAlternatives = "Use {@code TetheringManager#getLastTetherError} as alternative")
int getLastTetherError(String iface);@UnsupportedAppUsage(maxTargetSdk = 29,
publicAlternatives = "Use {@code TetheringManager#getTetherableIfaces} as alternative")
String[] getTetherableIfaces();@UnsupportedAppUsage(maxTargetSdk = 29,
publicAlternatives = "Use {@code TetheringManager#getTetheredIfaces} as alternative")
String[] getTetheredIfaces();@UnsupportedAppUsage(maxTargetSdk = 29,
publicAlternatives = "Use {@code TetheringManager#getTetheringErroredIfaces} "
+ "as Alternative")
String[] getTetheringErroredIfaces();@UnsupportedAppUsage(maxTargetSdk = 29,
publicAlternatives = "Use {@code TetheringManager#getTetherableUsbRegexs} as alternative")
String[] getTetherableUsbRegexs();@UnsupportedAppUsage(maxTargetSdk = 29,
publicAlternatives = "Use {@code TetheringManager#getTetherableWifiRegexs} as alternative")
String[] getTetherableWifiRegexs();@UnsupportedAppUsage(maxTargetSdk = 28)
void reportInetCondition(int networkType, int percentage);void reportNetworkConnectivity(in Network network, boolean hasConnectivity);
ProxyInfo getGlobalProxy();
void setGlobalProxy(in ProxyInfo p);
ProxyInfo getProxyForNetwork(in Network nework);
boolean prepareVpn(String oldPackage, String newPackage, int userId);
void setVpnPackageAuthorization(String packageName, int userId, int vpnType);
ParcelFileDescriptor establishVpn(in VpnConfig config);
boolean provisionVpnProfile(in VpnProfile profile, String packageName);
void deleteVpnProfile(String packageName);
void startVpnProfile(String packageName);
void stopVpnProfile(String packageName);
VpnConfig getVpnConfig(int userId);
@UnsupportedAppUsage
void startLegacyVpn(in VpnProfile profile);LegacyVpnInfo getLegacyVpnInfo(int userId);
boolean updateLockdownVpn();
boolean isAlwaysOnVpnPackageSupported(int userId, String packageName);
boolean setAlwaysOnVpnPackage(int userId, String packageName, boolean lockdown,
in List<String> lockdownWhitelist);
String getAlwaysOnVpnPackage(int userId);
boolean isVpnLockdownEnabled(int userId);
List<String> getVpnLockdownWhitelist(int userId);int checkMobileProvisioning(int suggestedTimeOutMs);
String getMobileProvisioningUrl();
void setProvisioningNotificationVisible(boolean visible, int networkType, in String action);
void setAirplaneMode(boolean enable);
boolean requestBandwidthUpdate(in Network network);
int registerNetworkFactory(in Messenger messenger, in String name);
void unregisterNetworkFactory(in Messenger messenger);int registerNetworkProvider(in Messenger messenger, in String name);
void unregisterNetworkProvider(in Messenger messenger);void declareNetworkRequestUnfulfillable(in NetworkRequest request);
Network registerNetworkAgent(in Messenger messenger, in NetworkInfo ni, in LinkProperties lp,
in NetworkCapabilities nc, int score, in NetworkAgentConfig config,
in int factorySerialNumber);NetworkRequest requestNetwork(in NetworkCapabilities networkCapabilities,
in Messenger messenger, int timeoutSec, in IBinder binder, int legacy,
String callingPackageName, String callingAttributionTag);NetworkRequest pendingRequestForNetwork(in NetworkCapabilities networkCapabilities,
in PendingIntent operation, String callingPackageName, String callingAttributionTag);void releasePendingNetworkRequest(in PendingIntent operation);
NetworkRequest listenForNetwork(in NetworkCapabilities networkCapabilities,
in Messenger messenger, in IBinder binder, String callingPackageName);void pendingListenForNetwork(in NetworkCapabilities networkCapabilities,
in PendingIntent operation, String callingPackageName);void releaseNetworkRequest(in NetworkRequest networkRequest);
void setAcceptUnvalidated(in Network network, boolean accept, boolean always);
void setAcceptPartialConnectivity(in Network network, boolean accept, boolean always);
void setAvoidUnvalidated(in Network network);
void startCaptivePortalApp(in Network network);
void startCaptivePortalAppInternal(in Network network, in Bundle appExtras);boolean shouldAvoidBadWifi();
int getMultipathPreference(in Network Network);NetworkRequest getDefaultRequest();
int getRestoreDefaultNetworkDelay(int networkType);
boolean addVpnAddress(String address, int prefixLength);
boolean removeVpnAddress(String address, int prefixLength);
boolean setUnderlyingNetworksForVpn(in Network[] networks);void factoryReset();
void startNattKeepalive(in Network network, int intervalSeconds,
in ISocketKeepaliveCallback cb, String srcAddr, int srcPort, String dstAddr);void startNattKeepaliveWithFd(in Network network, in FileDescriptor fd, int resourceId,
int intervalSeconds, in ISocketKeepaliveCallback cb, String srcAddr,
String dstAddr);void startTcpKeepalive(in Network network, in FileDescriptor fd, int intervalSeconds,
in ISocketKeepaliveCallback cb);void stopKeepalive(in Network network, int slot);
String getCaptivePortalServerUrl();
byte[] getNetworkWatchlistConfigHash();
int getConnectionOwnerUid(in ConnectionInfo connectionInfo);
boolean isCallerCurrentAlwaysOnVpnApp();
boolean isCallerCurrentAlwaysOnVpnLockdownApp();void registerConnectivityDiagnosticsCallback(in IConnectivityDiagnosticsCallback callback,
in NetworkRequest request, String callingPackageName);
void unregisterConnectivityDiagnosticsCallback(in IConnectivityDiagnosticsCallback callback);IBinder startOrGetTestNetworkService();
void simulateDataStall(int detectionMethod, long timestampMillis, in Network network,
in PersistableBundle extras);void systemReady();
}
5. NetworkPolicyManagerService 的定义
文件在 frameworks/base/core/java/android/net/INetworkPolicyManager.aidl
interface INetworkPolicyManager {
/** Control UID policies. */
@UnsupportedAppUsage
void setUidPolicy(int uid, int policy);
void addUidPolicy(int uid, int policy);
void removeUidPolicy(int uid, int policy);
@UnsupportedAppUsage
int getUidPolicy(int uid);
int[] getUidsWithPolicy(int policy);void registerListener(INetworkPolicyListener listener);
void unregisterListener(INetworkPolicyListener listener);/** Control network policies atomically. */
@UnsupportedAppUsage
void setNetworkPolicies(in NetworkPolicy[] policies);
NetworkPolicy[] getNetworkPolicies(String callingPackage);/** Snooze limit on policy matching given template. */
@UnsupportedAppUsage
void snoozeLimit(in NetworkTemplate template);/** Control if background data is restricted system-wide. */
@UnsupportedAppUsage
void setRestrictBackground(boolean restrictBackground);
@UnsupportedAppUsage
boolean getRestrictBackground();/** Gets the restrict background status based on the caller's UID:
1 - disabled
2 - whitelisted
3 - enabled
*/
int getRestrictBackgroundByCaller();void setDeviceIdleMode(boolean enabled);
void setWifiMeteredOverride(String networkId, int meteredOverride);@UnsupportedAppUsage
NetworkQuotaInfo getNetworkQuotaInfo(in NetworkState state);SubscriptionPlan[] getSubscriptionPlans(int subId, String callingPackage);
void setSubscriptionPlans(int subId, in SubscriptionPlan[] plans, String callingPackage);
String getSubscriptionPlansOwner(int subId);
void setSubscriptionOverride(int subId, int overrideMask, int overrideValue, long timeoutMillis, String callingPackage);void factoryReset(String subscriber);
boolean isUidNetworkingBlocked(int uid, boolean meteredNetwork);
}
6. NetworkScoreService 的定义
文件在 frameworks/base/core/java/android/net/INetworkScoreService.aidl
interface INetworkScoreService
{
/**
* Update scores.
* @return whether the update was successful.
* @throws SecurityException if the caller is not the current active scorer.
*/
boolean updateScores(in ScoredNetwork[] networks);/**
* Clear all scores.
* @return whether the clear was successful.
* @throws SecurityException if the caller is neither the current active scorer nor the system.
*/
boolean clearScores();/**
* Set the active scorer and clear existing scores.
* @param packageName the package name of the new scorer to use.
* @return true if the operation succeeded, or false if the new package is not a valid scorer.
* @throws SecurityException if the caller is not the system or a network scorer.
*/
boolean setActiveScorer(in String packageName);/**
* Disable the current active scorer and clear existing scores.
* @throws SecurityException if the caller is not the current scorer or the system.
*/
void disableScoring();/**
* Register a cache to receive scoring updates.
*
* @param networkType the type of network this cache can handle. See {@link NetworkKey#type}
* @param scoreCache implementation of {@link INetworkScoreCache} to store the scores
* @param filterType the {@link CacheUpdateFilter} to apply
* @throws SecurityException if the caller is not the system
* @throws IllegalArgumentException if a score cache is already registed for this type
* @hide
*/
void registerNetworkScoreCache(int networkType, INetworkScoreCache scoreCache, int filterType);/**
* Unregister a cache to receive scoring updates.
*
* @param networkType the type of network this cache can handle. See {@link NetworkKey#type}.
* @param scoreCache implementation of {@link INetworkScoreCache} to store the scores.
* @throws SecurityException if the caller is not the system.
* @hide
*/
void unregisterNetworkScoreCache(int networkType, INetworkScoreCache scoreCache);/**
* Request scoring for networks.
*
* Implementations should delegate to the registered network recommendation provider or
* fulfill the request locally if possible.
*
* @param networks an array of {@link NetworkKey}s to score
* @return true if the request was delegated or fulfilled locally, false otherwise
* @throws SecurityException if the caller is not the system
* @hide
*/
boolean requestScores(in NetworkKey[] networks);/**
* Determine whether the application with the given UID is the enabled scorer.
*
* @param callingUid the UID to check
* @return true if the provided UID is the active scorer, false otherwise.
* @hide
*/
boolean isCallerActiveScorer(int callingUid);/**
* Obtain the package name of the current active network scorer.
*
* @return the full package name of the current active scorer, or null if there is no active
* scorer.
*/
String getActiveScorerPackage();/**
* Returns metadata about the active scorer or <code>null</code> if there is no active scorer.
*/
NetworkScorerAppData getActiveScorer();/**
* Returns the list of available scorer apps. The list will be empty if there are
* no valid scorers.
*/
List<NetworkScorerAppData> getAllValidScorers();
}
7. NetworkStatsService 的定义
文件在 frameworks/base/core/java/android/net/INetworkStatsService.aidl
interface INetworkStatsService {
/** Start a statistics query session. */
@UnsupportedAppUsage
INetworkStatsSession openSession();/** Start a statistics query session. If calling package is profile or device owner then it is
* granted automatic access if apiLevel is NetworkStatsManager.API_LEVEL_DPC_ALLOWED. If
* apiLevel is at least NetworkStatsManager.API_LEVEL_REQUIRES_PACKAGE_USAGE_STATS then
* PACKAGE_USAGE_STATS permission is always checked. If PACKAGE_USAGE_STATS is not granted
* READ_NETWORK_USAGE_STATS is checked for.
*/
@UnsupportedAppUsage
INetworkStatsSession openSessionForUsageStats(int flags, String callingPackage);/** Return data layer snapshot of UID network usage. */
@UnsupportedAppUsage
NetworkStats getDataLayerSnapshotForUid(int uid);/** Get a detailed snapshot of stats since boot for all UIDs.
*
* <p>Results will not always be limited to stats on requiredIfaces when specified: stats for
* interfaces stacked on the specified interfaces, or for interfaces on which the specified
* interfaces are stacked on, will also be included.
* @param requiredIfaces Interface names to get data for, or {@link NetworkStats#INTERFACES_ALL}.
*/
NetworkStats getDetailedUidStats(in String[] requiredIfaces);/** Return set of any ifaces associated with mobile networks since boot. */
@UnsupportedAppUsage
String[] getMobileIfaces();/** Increment data layer count of operations performed for UID and tag. */
void incrementOperationCount(int uid, int tag, int operationCount);/** Force update of ifaces. */
void forceUpdateIfaces(
in Network[] defaultNetworks,
in NetworkState[] networkStates,
in String activeIface,
in VpnInfo[] vpnInfos);
/** Force update of statistics. */
@UnsupportedAppUsage
void forceUpdate();/** Registers a callback on data usage. */
DataUsageRequest registerUsageCallback(String callingPackage,
in DataUsageRequest request, in Messenger messenger, in IBinder binder);/** Unregisters a callback on data usage. */
void unregisterUsageRequest(in DataUsageRequest request);/** Get the uid stats information since boot */
long getUidStats(int uid, int type);/** Get the iface stats information since boot */
long getIfaceStats(String iface, int type);/** Get the total network stats information since boot */
long getTotalStats(int type);/** Registers a network stats provider */
INetworkStatsProviderCallback registerNetworkStatsProvider(String tag,
in INetworkStatsProvider provider);
}
Android 网络服务类提供的服务接口相关推荐
- DCMTK:基本工作清单管理服务类提供程序基于一组文件作为数据源
DCMTK:基本工作清单管理服务类提供程序基于一组文件作为数据源 基本工作清单管理服务类提供程序基于一组文件作为数据源 基本工作清单管理服务类提供程序基于一组文件作为数据源 #include &quo ...
- DCMTK:表示基于文件系统的基本工作列表管理服务类提供程序的控制台引擎的类
DCMTK:表示基于文件系统的基本工作列表管理服务类提供程序的控制台引擎的类 表示基于文件系统的基本工作列表管理服务类提供程序的控制台引擎的类 表示基于文件系统的基本工作列表管理服务类提供程序的控制台 ...
- Android网络编程http派/申请服务
最近的研究Android网络编程知识,这里有一些想法,今晚学习.与您分享. 在实际的应用程序的开发非常需要时间appserver请求数据,那么app怎样发送请求呢?以下的代码就是当中的一种情况.使用H ...
- Android网络功能开发(5)——Socket编程接口
Socket是编写用TCP/IP协议进行通信的程序的API接口,TCP/IP协议是互联网上使用的通信协议,不局限于HTTP的一问一答方式,可以随发随收. JavaSE平台提供了Socket编程接口,A ...
- 魔坊APP项目-15-邀请好友(业务逻辑流程图、服务端提供邀请好友的二维码生成接口、客户端通过第三方识别微信二维码,服务端提供接口允许访问、App配置私有协议,允许第三方应用通过私有协议,唤醒APP)
邀请好友 1.业务逻辑流程图 客户端提供点击"邀请好友"以后的页面frame,html/invite.html,代码: <!DOCTYPE html> <html ...
- 计算机网络提供服务靠,计算机网络体系结构及协议之通信子网的操作方式和网络层提供的服务...
3.4.1通信子网的操作方式和网络层提供的服务 端点之间的通信是依靠通信子网中的节点间的通信来实现的,在OSI模型中,网络层是网络节点中的最高层,所以网络层将体现通信子网向端系统所提供的网络服务.在分 ...
- 个人小程序支持哪些小程序服务类目
大家都知道微信小程序从注册主体上分为个人小程序和企业小程序,其中,个人小程序因为注册后无法认证被平台在很多方面限制了权限,使得个人小程序和企业小程序的区别很大,其中之一就是在小程序服务类目上的范围不一 ...
- Spring容器装饰者模式应用之实现业务类与服务类自由组合的解决方式
在不论什么一个项目中都不可或缺的存在两种bean,一种是实现系统核心功能的bean,我们称之为业务类,第二种是与系统核心业务无关但同一时候又提供十分重要服务bean,我们称之为服务类.业务类的bean ...
- 大数据平台技术可以提供哪些服务
随着大数据.互联网和物联网的深度渗入,智慧城市已经成为城市现代化发展的首要任务和目标,即将大数据等数字技术融入城市生活和管理的各个方面,使城市的各项数据均能得到整合利用.那么大数据平台技术能够提供哪些 ...
- Nmap扫描教程之DNS服务类
Nmap扫描教程之DNS服务类 Nmap DNS服务类 DNS(Domain Name System,域名系统)的作用就是将主机名解析为对应IP地址的过程.通常主机域名的一般结构为:主机名.三级域名. ...
最新文章
- js 正则之检测素数
- springboot心跳检测_springboot websocket 实时刷新 添加心跳机制(亲测可用版)
- 文件上传api——MultipartFile
- 关于dlg和pro的问题
- 基于Consul的分布式信号量实现
- python idle 中文_Python IDLE 中文乱码问题
- plupload怎么设置属性_店铺收银系统怎么用?好收银系统能提升店铺效率
- php去掉数字前的符号,php导出excel如何处理使得表格数字值前面的0不被去掉
- 关于File.separator 文件路径:window与linux下路径问题(“No such file or diretory ”异常解决方案)...
- pix2pix损失函数理解(精)
- gitlab根据hook钩子自动化部署
- 怎样用python自动生成python代码_(Python)自动生成代码(方法一)
- Android使用ListView时item失效解决方案
- linux 安装与启动nginx
- 计算机二级office树的知识,计算机二级office选择题白话串讲--二叉树,是什么树?(1)...
- 零信任在智慧城市典型场景中的融合应用
- Error response from daemon: conflict: unable to delete 31f279e888c0 (must be forced) - image is bein
- redis+Python实现小型动态IP池的搭建,仅需90行代码
- 解决pip3 install waring ‘The script xxx is installed in ‘/home/xxx/bin‘ which is not on PATH‘
- termux安装linux 并开机自动运行命令,自动进入系统
热门文章
- Android性能优化方法(五)
- c# wince 小技巧
- 关于修改域用户密码的WebPart的问题的问题.
- 开发者需要了解的nodejs中require的机制
- shell手册--笨鸟杰作
- 动态修改ViewPagerIndicator CustomTabPageIndicator Tab标签文字颜色
- JavaScript中的ActiveXObject对象
- 我的WCF之旅(5):面向服务架构(SOA)和面向对象编程(OOP)的结合——如何实现Service Contract的重载(Overloading)...
- 重写对象的equals和hashCode方法
- Spring注解——同一接口有多个实现类,如何注入