From eb6f4bef96409239af98a38c354c457604141602 Mon Sep 17 00:00:00 2001 From: Junyu Lai Date: Mon, 17 Jan 2022 11:52:57 +0000 Subject: [PATCH 1/8] [MS54.3] Move NetworkStats to updatable sources This CL builds NetworkStats related codes with the connectivity module instead of platform. Test: TH Bug: 197717846 Change-Id: I4eeb7ea9cfc3139991caf0fc22474e0052a0391c Merged-In: I4eeb7ea9cfc3139991caf0fc22474e0052a0391c --- Tethering/Android.bp | 1 + ...api-max-target-o-low-priority-tiramisu.txt | 176 ++++++++++++++++++ .../hiddenapi-unsupported-tiramisu.txt | 3 + Tethering/tests/unit/Android.bp | 2 + framework-t/Android.bp | 3 + framework-t/api/current.txt | 104 +++++++++++ framework-t/api/lint-baseline.txt | 150 +++++++++++++++ framework-t/api/module-lib-current.txt | 154 +++++++++++++++ framework-t/api/module-lib-lint-baseline.txt | 7 + framework-t/api/removed.txt | 8 + framework-t/api/system-current.txt | 83 +++++++++ framework/Android.bp | 22 +++ framework/proto/netstats.proto | 121 ++++++++++++ service-t/Android.bp | 2 - service/Android.bp | 1 + service/jarjar-rules.txt | 23 ++- 16 files changed, 848 insertions(+), 12 deletions(-) create mode 100644 Tethering/apex/hiddenapi/hiddenapi-unsupported-tiramisu.txt create mode 100644 framework-t/api/module-lib-lint-baseline.txt create mode 100644 framework/proto/netstats.proto diff --git a/Tethering/Android.bp b/Tethering/Android.bp index 46fd50fd4c..451abf780e 100644 --- a/Tethering/Android.bp +++ b/Tethering/Android.bp @@ -50,6 +50,7 @@ java_defaults { ], libs: [ "framework-connectivity", + "framework-connectivity-tiramisu.stubs.module_lib", "framework-statsd.stubs.module_lib", "framework-tethering.impl", "framework-wifi", diff --git a/Tethering/apex/hiddenapi/hiddenapi-max-target-o-low-priority-tiramisu.txt b/Tethering/apex/hiddenapi/hiddenapi-max-target-o-low-priority-tiramisu.txt index c1d87bb0a3..3a0268221d 100644 --- a/Tethering/apex/hiddenapi/hiddenapi-max-target-o-low-priority-tiramisu.txt +++ b/Tethering/apex/hiddenapi/hiddenapi-max-target-o-low-priority-tiramisu.txt @@ -1,3 +1,82 @@ +Landroid/app/usage/NetworkStats$Bucket;->convertDefaultNetworkStatus(I)I +Landroid/app/usage/NetworkStats$Bucket;->convertMetered(I)I +Landroid/app/usage/NetworkStats$Bucket;->convertRoaming(I)I +Landroid/app/usage/NetworkStats$Bucket;->convertSet(I)I +Landroid/app/usage/NetworkStats$Bucket;->convertState(I)I +Landroid/app/usage/NetworkStats$Bucket;->convertTag(I)I +Landroid/app/usage/NetworkStats$Bucket;->convertUid(I)I +Landroid/app/usage/NetworkStats$Bucket;->mBeginTimeStamp:J +Landroid/app/usage/NetworkStats$Bucket;->mDefaultNetworkStatus:I +Landroid/app/usage/NetworkStats$Bucket;->mEndTimeStamp:J +Landroid/app/usage/NetworkStats$Bucket;->mMetered:I +Landroid/app/usage/NetworkStats$Bucket;->mRoaming:I +Landroid/app/usage/NetworkStats$Bucket;->mRxBytes:J +Landroid/app/usage/NetworkStats$Bucket;->mRxPackets:J +Landroid/app/usage/NetworkStats$Bucket;->mState:I +Landroid/app/usage/NetworkStats$Bucket;->mTag:I +Landroid/app/usage/NetworkStats$Bucket;->mTxBytes:J +Landroid/app/usage/NetworkStats$Bucket;->mTxPackets:J +Landroid/app/usage/NetworkStats$Bucket;->mUid:I +Landroid/app/usage/NetworkStats;->(Landroid/content/Context;Landroid/net/NetworkTemplate;IJJLandroid/net/INetworkStatsService;)V +Landroid/app/usage/NetworkStats;->fillBucketFromSummaryEntry(Landroid/app/usage/NetworkStats$Bucket;)V +Landroid/app/usage/NetworkStats;->getDeviceSummaryForNetwork()Landroid/app/usage/NetworkStats$Bucket; +Landroid/app/usage/NetworkStats;->getNextHistoryBucket(Landroid/app/usage/NetworkStats$Bucket;)Z +Landroid/app/usage/NetworkStats;->getNextSummaryBucket(Landroid/app/usage/NetworkStats$Bucket;)Z +Landroid/app/usage/NetworkStats;->getSummaryAggregate()Landroid/app/usage/NetworkStats$Bucket; +Landroid/app/usage/NetworkStats;->getUid()I +Landroid/app/usage/NetworkStats;->hasNextUid()Z +Landroid/app/usage/NetworkStats;->isUidEnumeration()Z +Landroid/app/usage/NetworkStats;->mCloseGuard:Ldalvik/system/CloseGuard; +Landroid/app/usage/NetworkStats;->mEndTimeStamp:J +Landroid/app/usage/NetworkStats;->mEnumerationIndex:I +Landroid/app/usage/NetworkStats;->mHistory:Landroid/net/NetworkStatsHistory; +Landroid/app/usage/NetworkStats;->mRecycledHistoryEntry:Landroid/net/NetworkStatsHistory$Entry; +Landroid/app/usage/NetworkStats;->mRecycledSummaryEntry:Landroid/net/NetworkStats$Entry; +Landroid/app/usage/NetworkStats;->mSession:Landroid/net/INetworkStatsSession; +Landroid/app/usage/NetworkStats;->mStartTimeStamp:J +Landroid/app/usage/NetworkStats;->mState:I +Landroid/app/usage/NetworkStats;->mSummary:Landroid/net/NetworkStats; +Landroid/app/usage/NetworkStats;->mTag:I +Landroid/app/usage/NetworkStats;->mTemplate:Landroid/net/NetworkTemplate; +Landroid/app/usage/NetworkStats;->mUidOrUidIndex:I +Landroid/app/usage/NetworkStats;->mUids:[I +Landroid/app/usage/NetworkStats;->setSingleUidTagState(III)V +Landroid/app/usage/NetworkStats;->startHistoryEnumeration(III)V +Landroid/app/usage/NetworkStats;->startSummaryEnumeration()V +Landroid/app/usage/NetworkStats;->startUserUidEnumeration()V +Landroid/app/usage/NetworkStats;->stepHistory()V +Landroid/app/usage/NetworkStats;->stepUid()V +Landroid/app/usage/NetworkStats;->TAG:Ljava/lang/String; +Landroid/app/usage/NetworkStatsManager$CallbackHandler;->(Landroid/os/Looper;ILjava/lang/String;Landroid/app/usage/NetworkStatsManager$UsageCallback;)V +Landroid/app/usage/NetworkStatsManager$CallbackHandler;->getObject(Landroid/os/Message;Ljava/lang/String;)Ljava/lang/Object; +Landroid/app/usage/NetworkStatsManager$CallbackHandler;->mCallback:Landroid/app/usage/NetworkStatsManager$UsageCallback; +Landroid/app/usage/NetworkStatsManager$CallbackHandler;->mNetworkType:I +Landroid/app/usage/NetworkStatsManager$CallbackHandler;->mSubscriberId:Ljava/lang/String; +Landroid/app/usage/NetworkStatsManager$UsageCallback;->request:Landroid/net/DataUsageRequest; +Landroid/app/usage/NetworkStatsManager;->(Landroid/content/Context;Landroid/net/INetworkStatsService;)V +Landroid/app/usage/NetworkStatsManager;->CALLBACK_LIMIT_REACHED:I +Landroid/app/usage/NetworkStatsManager;->CALLBACK_RELEASED:I +Landroid/app/usage/NetworkStatsManager;->createTemplate(ILjava/lang/String;)Landroid/net/NetworkTemplate; +Landroid/app/usage/NetworkStatsManager;->DBG:Z +Landroid/app/usage/NetworkStatsManager;->FLAG_AUGMENT_WITH_SUBSCRIPTION_PLAN:I +Landroid/app/usage/NetworkStatsManager;->FLAG_POLL_FORCE:I +Landroid/app/usage/NetworkStatsManager;->FLAG_POLL_ON_OPEN:I +Landroid/app/usage/NetworkStatsManager;->mContext:Landroid/content/Context; +Landroid/app/usage/NetworkStatsManager;->mFlags:I +Landroid/app/usage/NetworkStatsManager;->MIN_THRESHOLD_BYTES:J +Landroid/app/usage/NetworkStatsManager;->mService:Landroid/net/INetworkStatsService; +Landroid/app/usage/NetworkStatsManager;->querySummaryForDevice(Landroid/net/NetworkTemplate;JJ)Landroid/app/usage/NetworkStats$Bucket; +Landroid/app/usage/NetworkStatsManager;->registerUsageCallback(Landroid/net/NetworkTemplate;IJLandroid/app/usage/NetworkStatsManager$UsageCallback;Landroid/os/Handler;)V +Landroid/app/usage/NetworkStatsManager;->setAugmentWithSubscriptionPlan(Z)V +Landroid/app/usage/NetworkStatsManager;->setPollOnOpen(Z)V +Landroid/app/usage/NetworkStatsManager;->TAG:Ljava/lang/String; +Landroid/net/DataUsageRequest;->(ILandroid/net/NetworkTemplate;J)V +Landroid/net/DataUsageRequest;->CREATOR:Landroid/os/Parcelable$Creator; +Landroid/net/DataUsageRequest;->PARCELABLE_KEY:Ljava/lang/String; +Landroid/net/DataUsageRequest;->requestId:I +Landroid/net/DataUsageRequest;->REQUEST_ID_UNSET:I +Landroid/net/DataUsageRequest;->template:Landroid/net/NetworkTemplate; +Landroid/net/DataUsageRequest;->thresholdInBytes:J Landroid/net/IIpSecService$Stub$Proxy;->(Landroid/os/IBinder;)V Landroid/net/IIpSecService$Stub$Proxy;->addAddressToTunnelInterface(ILandroid/net/LinkAddress;Ljava/lang/String;)V Landroid/net/IIpSecService$Stub$Proxy;->allocateSecurityParameterIndex(Ljava/lang/String;ILandroid/os/IBinder;)Landroid/net/IpSecSpiResponse; @@ -43,6 +122,68 @@ Landroid/net/IIpSecService;->openUdpEncapsulationSocket(ILandroid/os/IBinder;)La Landroid/net/IIpSecService;->releaseSecurityParameterIndex(I)V Landroid/net/IIpSecService;->removeAddressFromTunnelInterface(ILandroid/net/LinkAddress;Ljava/lang/String;)V Landroid/net/IIpSecService;->removeTransportModeTransforms(Landroid/os/ParcelFileDescriptor;)V +Landroid/net/INetworkStatsService$Stub$Proxy;->forceUpdate()V +Landroid/net/INetworkStatsService$Stub$Proxy;->forceUpdateIfaces([Landroid/net/Network;)V +Landroid/net/INetworkStatsService$Stub$Proxy;->getDataLayerSnapshotForUid(I)Landroid/net/NetworkStats; +Landroid/net/INetworkStatsService$Stub$Proxy;->getDetailedUidStats([Ljava/lang/String;)Landroid/net/NetworkStats; +Landroid/net/INetworkStatsService$Stub$Proxy;->getIfaceStats(Ljava/lang/String;I)J +Landroid/net/INetworkStatsService$Stub$Proxy;->getInterfaceDescriptor()Ljava/lang/String; +Landroid/net/INetworkStatsService$Stub$Proxy;->getTotalStats(I)J +Landroid/net/INetworkStatsService$Stub$Proxy;->getUidStats(II)J +Landroid/net/INetworkStatsService$Stub$Proxy;->incrementOperationCount(III)V +Landroid/net/INetworkStatsService$Stub$Proxy;->mRemote:Landroid/os/IBinder; +Landroid/net/INetworkStatsService$Stub$Proxy;->openSession()Landroid/net/INetworkStatsSession; +Landroid/net/INetworkStatsService$Stub$Proxy;->openSessionForUsageStats(ILjava/lang/String;)Landroid/net/INetworkStatsSession; +Landroid/net/INetworkStatsService$Stub$Proxy;->registerUsageCallback(Ljava/lang/String;Landroid/net/DataUsageRequest;Landroid/os/Messenger;Landroid/os/IBinder;)Landroid/net/DataUsageRequest; +Landroid/net/INetworkStatsService$Stub$Proxy;->unregisterUsageRequest(Landroid/net/DataUsageRequest;)V +Landroid/net/INetworkStatsService$Stub;->()V +Landroid/net/INetworkStatsService$Stub;->DESCRIPTOR:Ljava/lang/String; +Landroid/net/INetworkStatsService$Stub;->TRANSACTION_forceUpdate:I +Landroid/net/INetworkStatsService$Stub;->TRANSACTION_forceUpdateIfaces:I +Landroid/net/INetworkStatsService$Stub;->TRANSACTION_getDataLayerSnapshotForUid:I +Landroid/net/INetworkStatsService$Stub;->TRANSACTION_getDetailedUidStats:I +Landroid/net/INetworkStatsService$Stub;->TRANSACTION_getIfaceStats:I +Landroid/net/INetworkStatsService$Stub;->TRANSACTION_getMobileIfaces:I +Landroid/net/INetworkStatsService$Stub;->TRANSACTION_getTotalStats:I +Landroid/net/INetworkStatsService$Stub;->TRANSACTION_getUidStats:I +Landroid/net/INetworkStatsService$Stub;->TRANSACTION_incrementOperationCount:I +Landroid/net/INetworkStatsService$Stub;->TRANSACTION_openSession:I +Landroid/net/INetworkStatsService$Stub;->TRANSACTION_openSessionForUsageStats:I +Landroid/net/INetworkStatsService$Stub;->TRANSACTION_registerUsageCallback:I +Landroid/net/INetworkStatsService$Stub;->TRANSACTION_unregisterUsageRequest:I +Landroid/net/INetworkStatsService;->forceUpdateIfaces([Landroid/net/Network;)V +Landroid/net/INetworkStatsService;->getDetailedUidStats([Ljava/lang/String;)Landroid/net/NetworkStats; +Landroid/net/INetworkStatsService;->getIfaceStats(Ljava/lang/String;I)J +Landroid/net/INetworkStatsService;->getTotalStats(I)J +Landroid/net/INetworkStatsService;->getUidStats(II)J +Landroid/net/INetworkStatsService;->incrementOperationCount(III)V +Landroid/net/INetworkStatsService;->registerUsageCallback(Ljava/lang/String;Landroid/net/DataUsageRequest;Landroid/os/Messenger;Landroid/os/IBinder;)Landroid/net/DataUsageRequest; +Landroid/net/INetworkStatsService;->unregisterUsageRequest(Landroid/net/DataUsageRequest;)V +Landroid/net/INetworkStatsSession$Stub$Proxy;->(Landroid/os/IBinder;)V +Landroid/net/INetworkStatsSession$Stub$Proxy;->close()V +Landroid/net/INetworkStatsSession$Stub$Proxy;->getDeviceSummaryForNetwork(Landroid/net/NetworkTemplate;JJ)Landroid/net/NetworkStats; +Landroid/net/INetworkStatsSession$Stub$Proxy;->getHistoryForNetwork(Landroid/net/NetworkTemplate;I)Landroid/net/NetworkStatsHistory; +Landroid/net/INetworkStatsSession$Stub$Proxy;->getHistoryForUid(Landroid/net/NetworkTemplate;IIII)Landroid/net/NetworkStatsHistory; +Landroid/net/INetworkStatsSession$Stub$Proxy;->getHistoryIntervalForUid(Landroid/net/NetworkTemplate;IIIIJJ)Landroid/net/NetworkStatsHistory; +Landroid/net/INetworkStatsSession$Stub$Proxy;->getInterfaceDescriptor()Ljava/lang/String; +Landroid/net/INetworkStatsSession$Stub$Proxy;->getRelevantUids()[I +Landroid/net/INetworkStatsSession$Stub$Proxy;->getSummaryForAllUid(Landroid/net/NetworkTemplate;JJZ)Landroid/net/NetworkStats; +Landroid/net/INetworkStatsSession$Stub$Proxy;->getSummaryForNetwork(Landroid/net/NetworkTemplate;JJ)Landroid/net/NetworkStats; +Landroid/net/INetworkStatsSession$Stub$Proxy;->mRemote:Landroid/os/IBinder; +Landroid/net/INetworkStatsSession$Stub;->()V +Landroid/net/INetworkStatsSession$Stub;->asInterface(Landroid/os/IBinder;)Landroid/net/INetworkStatsSession; +Landroid/net/INetworkStatsSession$Stub;->DESCRIPTOR:Ljava/lang/String; +Landroid/net/INetworkStatsSession$Stub;->TRANSACTION_close:I +Landroid/net/INetworkStatsSession$Stub;->TRANSACTION_getDeviceSummaryForNetwork:I +Landroid/net/INetworkStatsSession$Stub;->TRANSACTION_getHistoryForNetwork:I +Landroid/net/INetworkStatsSession$Stub;->TRANSACTION_getHistoryForUid:I +Landroid/net/INetworkStatsSession$Stub;->TRANSACTION_getHistoryIntervalForUid:I +Landroid/net/INetworkStatsSession$Stub;->TRANSACTION_getRelevantUids:I +Landroid/net/INetworkStatsSession$Stub;->TRANSACTION_getSummaryForAllUid:I +Landroid/net/INetworkStatsSession$Stub;->TRANSACTION_getSummaryForNetwork:I +Landroid/net/INetworkStatsSession;->getDeviceSummaryForNetwork(Landroid/net/NetworkTemplate;JJ)Landroid/net/NetworkStats; +Landroid/net/INetworkStatsSession;->getHistoryIntervalForUid(Landroid/net/NetworkTemplate;IIIIJJ)Landroid/net/NetworkStatsHistory; +Landroid/net/INetworkStatsSession;->getRelevantUids()[I Landroid/net/IpSecAlgorithm;->checkValidOrThrow(Ljava/lang/String;II)V Landroid/net/IpSecAlgorithm;->CRYPT_NULL:Ljava/lang/String; Landroid/net/IpSecAlgorithm;->equals(Landroid/net/IpSecAlgorithm;Landroid/net/IpSecAlgorithm;)Z @@ -298,3 +439,38 @@ Landroid/net/nsd/NsdServiceInfo;->mServiceType:Ljava/lang/String; Landroid/net/nsd/NsdServiceInfo;->mTxtRecord:Landroid/util/ArrayMap; Landroid/net/nsd/NsdServiceInfo;->setTxtRecords(Ljava/lang/String;)V Landroid/net/nsd/NsdServiceInfo;->TAG:Ljava/lang/String; +Landroid/net/TrafficStats;->addIfSupported(J)J +Landroid/net/TrafficStats;->closeQuietly(Landroid/net/INetworkStatsSession;)V +Landroid/net/TrafficStats;->GB_IN_BYTES:J +Landroid/net/TrafficStats;->getDataLayerSnapshotForUid(Landroid/content/Context;)Landroid/net/NetworkStats; +Landroid/net/TrafficStats;->getRxPackets(Ljava/lang/String;)J +Landroid/net/TrafficStats;->getTxPackets(Ljava/lang/String;)J +Landroid/net/TrafficStats;->KB_IN_BYTES:J +Landroid/net/TrafficStats;->LOOPBACK_IFACE:Ljava/lang/String; +Landroid/net/TrafficStats;->MB_IN_BYTES:J +Landroid/net/TrafficStats;->PB_IN_BYTES:J +Landroid/net/TrafficStats;->sActiveProfilingStart:Landroid/net/NetworkStats; +Landroid/net/TrafficStats;->sProfilingLock:Ljava/lang/Object; +Landroid/net/TrafficStats;->sStatsService:Landroid/net/INetworkStatsService; +Landroid/net/TrafficStats;->startDataProfiling(Landroid/content/Context;)V +Landroid/net/TrafficStats;->stopDataProfiling(Landroid/content/Context;)Landroid/net/NetworkStats; +Landroid/net/TrafficStats;->TAG_SYSTEM_APP:I +Landroid/net/TrafficStats;->TAG_SYSTEM_BACKUP:I +Landroid/net/TrafficStats;->TAG_SYSTEM_DHCP:I +Landroid/net/TrafficStats;->TAG_SYSTEM_DOWNLOAD:I +Landroid/net/TrafficStats;->TAG_SYSTEM_GPS:I +Landroid/net/TrafficStats;->TAG_SYSTEM_MEDIA:I +Landroid/net/TrafficStats;->TAG_SYSTEM_NEIGHBOR:I +Landroid/net/TrafficStats;->TAG_SYSTEM_NTP:I +Landroid/net/TrafficStats;->TAG_SYSTEM_PAC:I +Landroid/net/TrafficStats;->TAG_SYSTEM_PROBE:I +Landroid/net/TrafficStats;->TAG_SYSTEM_RESTORE:I +Landroid/net/TrafficStats;->TB_IN_BYTES:J +Landroid/net/TrafficStats;->TYPE_RX_BYTES:I +Landroid/net/TrafficStats;->TYPE_RX_PACKETS:I +Landroid/net/TrafficStats;->TYPE_TCP_RX_PACKETS:I +Landroid/net/TrafficStats;->TYPE_TCP_TX_PACKETS:I +Landroid/net/TrafficStats;->TYPE_TX_BYTES:I +Landroid/net/TrafficStats;->TYPE_TX_PACKETS:I +Landroid/net/TrafficStats;->UID_REMOVED:I +Landroid/net/TrafficStats;->UID_TETHERING:I diff --git a/Tethering/apex/hiddenapi/hiddenapi-unsupported-tiramisu.txt b/Tethering/apex/hiddenapi/hiddenapi-unsupported-tiramisu.txt new file mode 100644 index 0000000000..a6257e3358 --- /dev/null +++ b/Tethering/apex/hiddenapi/hiddenapi-unsupported-tiramisu.txt @@ -0,0 +1,3 @@ +Landroid/net/INetworkStatsService$Stub$Proxy;->(Landroid/os/IBinder;)V +Landroid/net/INetworkStatsService$Stub$Proxy;->getMobileIfaces()[Ljava/lang/String; +Landroid/net/INetworkStatsService$Stub;->asInterface(Landroid/os/IBinder;)Landroid/net/INetworkStatsService; diff --git a/Tethering/tests/unit/Android.bp b/Tethering/tests/unit/Android.bp index ecd1a39bb3..224d87a4f4 100644 --- a/Tethering/tests/unit/Android.bp +++ b/Tethering/tests/unit/Android.bp @@ -34,6 +34,7 @@ java_library { libs: [ "framework-minus-apex", "framework-connectivity.impl", + "framework-connectivity-tiramisu.impl", "framework-tethering.impl", ], visibility: [ @@ -67,6 +68,7 @@ java_defaults { "framework-minus-apex", "framework-res", "framework-connectivity.impl", + "framework-connectivity-tiramisu.impl", "framework-tethering.impl", "framework-wifi.stubs.module_lib", ], diff --git a/framework-t/Android.bp b/framework-t/Android.bp index 50a3eb2183..6a911ababc 100644 --- a/framework-t/Android.bp +++ b/framework-t/Android.bp @@ -53,6 +53,7 @@ java_defaults { // The build system will use framework-bluetooth module_current stubs, because // of sdk_version: "module_current" above. "framework-bluetooth", + "framework-wifi", // Compile against the entire implementation of framework-connectivity, // including hidden methods. This is safe because if framework-connectivity-t is // on the bootclasspath (i.e., T), then framework-connectivity is also on the @@ -81,6 +82,7 @@ java_library { defaults: ["framework-connectivity-tiramisu-defaults"], libs: [ "framework-bluetooth", + "framework-wifi", "framework-connectivity-pre-jarjar", ], visibility: ["//packages/modules/Connectivity:__subpackages__"], @@ -100,6 +102,7 @@ java_sdk_library { // framework-connectivity-pre-jarjar match at runtime. jarjar_rules: ":connectivity-jarjar-rules", permitted_packages: [ + "android.app.usage", "android.net", "android.net.nsd", "android.nearby", diff --git a/framework-t/api/current.txt b/framework-t/api/current.txt index 1389ff2571..3d6fb3e552 100644 --- a/framework-t/api/current.txt +++ b/framework-t/api/current.txt @@ -1,4 +1,64 @@ // Signature format: 2.0 +package android.app.usage { + + public final class NetworkStats implements java.lang.AutoCloseable { + method public void close(); + method public boolean getNextBucket(android.app.usage.NetworkStats.Bucket); + method public boolean hasNextBucket(); + } + + public static class NetworkStats.Bucket { + ctor public NetworkStats.Bucket(); + method public int getDefaultNetworkStatus(); + method public long getEndTimeStamp(); + method public int getMetered(); + method public int getRoaming(); + method public long getRxBytes(); + method public long getRxPackets(); + method public long getStartTimeStamp(); + method public int getState(); + method public int getTag(); + method public long getTxBytes(); + method public long getTxPackets(); + method public int getUid(); + field public static final int DEFAULT_NETWORK_ALL = -1; // 0xffffffff + field public static final int DEFAULT_NETWORK_NO = 1; // 0x1 + field public static final int DEFAULT_NETWORK_YES = 2; // 0x2 + field public static final int METERED_ALL = -1; // 0xffffffff + field public static final int METERED_NO = 1; // 0x1 + field public static final int METERED_YES = 2; // 0x2 + field public static final int ROAMING_ALL = -1; // 0xffffffff + field public static final int ROAMING_NO = 1; // 0x1 + field public static final int ROAMING_YES = 2; // 0x2 + field public static final int STATE_ALL = -1; // 0xffffffff + field public static final int STATE_DEFAULT = 1; // 0x1 + field public static final int STATE_FOREGROUND = 2; // 0x2 + field public static final int TAG_NONE = 0; // 0x0 + field public static final int UID_ALL = -1; // 0xffffffff + field public static final int UID_REMOVED = -4; // 0xfffffffc + field public static final int UID_TETHERING = -5; // 0xfffffffb + } + + public class NetworkStatsManager { + method @WorkerThread public android.app.usage.NetworkStats queryDetails(int, String, long, long) throws android.os.RemoteException, java.lang.SecurityException; + method @WorkerThread public android.app.usage.NetworkStats queryDetailsForUid(int, String, long, long, int) throws java.lang.SecurityException; + method @WorkerThread public android.app.usage.NetworkStats queryDetailsForUidTag(int, String, long, long, int, int) throws java.lang.SecurityException; + method @WorkerThread public android.app.usage.NetworkStats queryDetailsForUidTagState(int, String, long, long, int, int, int) throws java.lang.SecurityException; + method @WorkerThread public android.app.usage.NetworkStats querySummary(int, String, long, long) throws android.os.RemoteException, java.lang.SecurityException; + method @WorkerThread public android.app.usage.NetworkStats.Bucket querySummaryForDevice(int, String, long, long) throws android.os.RemoteException, java.lang.SecurityException; + method @WorkerThread public android.app.usage.NetworkStats.Bucket querySummaryForUser(int, String, long, long) throws android.os.RemoteException, java.lang.SecurityException; + method public void registerUsageCallback(int, String, long, android.app.usage.NetworkStatsManager.UsageCallback); + method public void registerUsageCallback(int, String, long, android.app.usage.NetworkStatsManager.UsageCallback, @Nullable android.os.Handler); + method public void unregisterUsageCallback(android.app.usage.NetworkStatsManager.UsageCallback); + } + + public abstract static class NetworkStatsManager.UsageCallback { + ctor public NetworkStatsManager.UsageCallback(); + method public abstract void onThresholdReached(int, String); + } + +} + package android.net { public final class IpSecAlgorithm implements android.os.Parcelable { @@ -70,6 +130,50 @@ package android.net { method @NonNull public android.net.IpSecTransform.Builder setIpv4Encapsulation(@NonNull android.net.IpSecManager.UdpEncapsulationSocket, int); } + public class TrafficStats { + ctor public TrafficStats(); + method public static void clearThreadStatsTag(); + method public static void clearThreadStatsUid(); + method public static int getAndSetThreadStatsTag(int); + method public static long getMobileRxBytes(); + method public static long getMobileRxPackets(); + method public static long getMobileTxBytes(); + method public static long getMobileTxPackets(); + method public static long getRxBytes(@NonNull String); + method public static long getRxPackets(@NonNull String); + method public static int getThreadStatsTag(); + method public static int getThreadStatsUid(); + method public static long getTotalRxBytes(); + method public static long getTotalRxPackets(); + method public static long getTotalTxBytes(); + method public static long getTotalTxPackets(); + method public static long getTxBytes(@NonNull String); + method public static long getTxPackets(@NonNull String); + method public static long getUidRxBytes(int); + method public static long getUidRxPackets(int); + method @Deprecated public static long getUidTcpRxBytes(int); + method @Deprecated public static long getUidTcpRxSegments(int); + method @Deprecated public static long getUidTcpTxBytes(int); + method @Deprecated public static long getUidTcpTxSegments(int); + method public static long getUidTxBytes(int); + method public static long getUidTxPackets(int); + method @Deprecated public static long getUidUdpRxBytes(int); + method @Deprecated public static long getUidUdpRxPackets(int); + method @Deprecated public static long getUidUdpTxBytes(int); + method @Deprecated public static long getUidUdpTxPackets(int); + method public static void incrementOperationCount(int); + method public static void incrementOperationCount(int, int); + method public static void setThreadStatsTag(int); + method public static void setThreadStatsUid(int); + method public static void tagDatagramSocket(java.net.DatagramSocket) throws java.net.SocketException; + method public static void tagFileDescriptor(java.io.FileDescriptor) throws java.io.IOException; + method public static void tagSocket(java.net.Socket) throws java.net.SocketException; + method public static void untagDatagramSocket(java.net.DatagramSocket) throws java.net.SocketException; + method public static void untagFileDescriptor(java.io.FileDescriptor) throws java.io.IOException; + method public static void untagSocket(java.net.Socket) throws java.net.SocketException; + field public static final int UNSUPPORTED = -1; // 0xffffffff + } + } package android.net.nsd { diff --git a/framework-t/api/lint-baseline.txt b/framework-t/api/lint-baseline.txt index 1e3074758b..53e1beb653 100644 --- a/framework-t/api/lint-baseline.txt +++ b/framework-t/api/lint-baseline.txt @@ -1,7 +1,157 @@ // Baseline format: 1.0 +BannedThrow: android.app.usage.NetworkStatsManager#queryDetails(int, String, long, long): + Methods must not mention RuntimeException subclasses in throws clauses (was `java.lang.SecurityException`) +BannedThrow: android.app.usage.NetworkStatsManager#queryDetailsForUid(int, String, long, long, int): + Methods must not mention RuntimeException subclasses in throws clauses (was `java.lang.SecurityException`) +BannedThrow: android.app.usage.NetworkStatsManager#queryDetailsForUidTag(int, String, long, long, int, int): + Methods must not mention RuntimeException subclasses in throws clauses (was `java.lang.SecurityException`) +BannedThrow: android.app.usage.NetworkStatsManager#queryDetailsForUidTagState(int, String, long, long, int, int, int): + Methods must not mention RuntimeException subclasses in throws clauses (was `java.lang.SecurityException`) +BannedThrow: android.app.usage.NetworkStatsManager#querySummary(int, String, long, long): + Methods must not mention RuntimeException subclasses in throws clauses (was `java.lang.SecurityException`) +BannedThrow: android.app.usage.NetworkStatsManager#querySummaryForDevice(int, String, long, long): + Methods must not mention RuntimeException subclasses in throws clauses (was `java.lang.SecurityException`) +BannedThrow: android.app.usage.NetworkStatsManager#querySummaryForUser(int, String, long, long): + Methods must not mention RuntimeException subclasses in throws clauses (was `java.lang.SecurityException`) + + +BuilderSetStyle: android.net.IpSecTransform.Builder#buildTransportModeTransform(java.net.InetAddress, android.net.IpSecManager.SecurityParameterIndex): + Builder methods names should use setFoo() / addFoo() / clearFoo() style: method android.net.IpSecTransform.Builder.buildTransportModeTransform(java.net.InetAddress,android.net.IpSecManager.SecurityParameterIndex) + + +EqualsAndHashCode: android.net.IpSecTransform#equals(Object): + Must override both equals and hashCode; missing one in android.net.IpSecTransform + + +ExecutorRegistration: android.app.usage.NetworkStatsManager#registerUsageCallback(int, String, long, android.app.usage.NetworkStatsManager.UsageCallback, android.os.Handler): + Registration methods should have overload that accepts delivery Executor: `registerUsageCallback` + + +GenericException: android.app.usage.NetworkStats#finalize(): + Methods must not throw generic exceptions (`java.lang.Throwable`) GenericException: android.net.IpSecManager.SecurityParameterIndex#finalize(): Methods must not throw generic exceptions (`java.lang.Throwable`) GenericException: android.net.IpSecManager.UdpEncapsulationSocket#finalize(): Methods must not throw generic exceptions (`java.lang.Throwable`) GenericException: android.net.IpSecTransform#finalize(): Methods must not throw generic exceptions (`java.lang.Throwable`) + + +MissingBuildMethod: android.net.IpSecTransform.Builder: + android.net.IpSecTransform.Builder does not declare a `build()` method, but builder classes are expected to + + +MissingNullability: android.app.usage.NetworkStats#getNextBucket(android.app.usage.NetworkStats.Bucket) parameter #0: + Missing nullability on parameter `bucketOut` in method `getNextBucket` +MissingNullability: android.app.usage.NetworkStatsManager#queryDetails(int, String, long, long): + Missing nullability on method `queryDetails` return +MissingNullability: android.app.usage.NetworkStatsManager#queryDetails(int, String, long, long) parameter #1: + Missing nullability on parameter `subscriberId` in method `queryDetails` +MissingNullability: android.app.usage.NetworkStatsManager#queryDetailsForUid(int, String, long, long, int): + Missing nullability on method `queryDetailsForUid` return +MissingNullability: android.app.usage.NetworkStatsManager#queryDetailsForUid(int, String, long, long, int) parameter #1: + Missing nullability on parameter `subscriberId` in method `queryDetailsForUid` +MissingNullability: android.app.usage.NetworkStatsManager#queryDetailsForUidTag(int, String, long, long, int, int): + Missing nullability on method `queryDetailsForUidTag` return +MissingNullability: android.app.usage.NetworkStatsManager#queryDetailsForUidTag(int, String, long, long, int, int) parameter #1: + Missing nullability on parameter `subscriberId` in method `queryDetailsForUidTag` +MissingNullability: android.app.usage.NetworkStatsManager#queryDetailsForUidTagState(int, String, long, long, int, int, int): + Missing nullability on method `queryDetailsForUidTagState` return +MissingNullability: android.app.usage.NetworkStatsManager#queryDetailsForUidTagState(int, String, long, long, int, int, int) parameter #1: + Missing nullability on parameter `subscriberId` in method `queryDetailsForUidTagState` +MissingNullability: android.app.usage.NetworkStatsManager#querySummary(int, String, long, long): + Missing nullability on method `querySummary` return +MissingNullability: android.app.usage.NetworkStatsManager#querySummary(int, String, long, long) parameter #1: + Missing nullability on parameter `subscriberId` in method `querySummary` +MissingNullability: android.app.usage.NetworkStatsManager#querySummaryForDevice(int, String, long, long): + Missing nullability on method `querySummaryForDevice` return +MissingNullability: android.app.usage.NetworkStatsManager#querySummaryForDevice(int, String, long, long) parameter #1: + Missing nullability on parameter `subscriberId` in method `querySummaryForDevice` +MissingNullability: android.app.usage.NetworkStatsManager#querySummaryForUser(int, String, long, long): + Missing nullability on method `querySummaryForUser` return +MissingNullability: android.app.usage.NetworkStatsManager#querySummaryForUser(int, String, long, long) parameter #1: + Missing nullability on parameter `subscriberId` in method `querySummaryForUser` +MissingNullability: android.app.usage.NetworkStatsManager#registerUsageCallback(int, String, long, android.app.usage.NetworkStatsManager.UsageCallback) parameter #1: + Missing nullability on parameter `subscriberId` in method `registerUsageCallback` +MissingNullability: android.app.usage.NetworkStatsManager#registerUsageCallback(int, String, long, android.app.usage.NetworkStatsManager.UsageCallback) parameter #3: + Missing nullability on parameter `callback` in method `registerUsageCallback` +MissingNullability: android.app.usage.NetworkStatsManager#registerUsageCallback(int, String, long, android.app.usage.NetworkStatsManager.UsageCallback, android.os.Handler) parameter #1: + Missing nullability on parameter `subscriberId` in method `registerUsageCallback` +MissingNullability: android.app.usage.NetworkStatsManager#registerUsageCallback(int, String, long, android.app.usage.NetworkStatsManager.UsageCallback, android.os.Handler) parameter #3: + Missing nullability on parameter `callback` in method `registerUsageCallback` +MissingNullability: android.app.usage.NetworkStatsManager#unregisterUsageCallback(android.app.usage.NetworkStatsManager.UsageCallback) parameter #0: + Missing nullability on parameter `callback` in method `unregisterUsageCallback` +MissingNullability: android.app.usage.NetworkStatsManager.UsageCallback#onThresholdReached(int, String) parameter #1: + Missing nullability on parameter `subscriberId` in method `onThresholdReached` +MissingNullability: android.net.IpSecAlgorithm#writeToParcel(android.os.Parcel, int) parameter #0: + Missing nullability on parameter `out` in method `writeToParcel` +MissingNullability: android.net.IpSecManager.UdpEncapsulationSocket#getFileDescriptor(): + Missing nullability on method `getFileDescriptor` return +MissingNullability: android.net.TrafficStats#tagDatagramSocket(java.net.DatagramSocket) parameter #0: + Missing nullability on parameter `socket` in method `tagDatagramSocket` +MissingNullability: android.net.TrafficStats#tagFileDescriptor(java.io.FileDescriptor) parameter #0: + Missing nullability on parameter `fd` in method `tagFileDescriptor` +MissingNullability: android.net.TrafficStats#tagSocket(java.net.Socket) parameter #0: + Missing nullability on parameter `socket` in method `tagSocket` +MissingNullability: android.net.TrafficStats#untagDatagramSocket(java.net.DatagramSocket) parameter #0: + Missing nullability on parameter `socket` in method `untagDatagramSocket` +MissingNullability: android.net.TrafficStats#untagFileDescriptor(java.io.FileDescriptor) parameter #0: + Missing nullability on parameter `fd` in method `untagFileDescriptor` +MissingNullability: android.net.TrafficStats#untagSocket(java.net.Socket) parameter #0: + Missing nullability on parameter `socket` in method `untagSocket` +MissingNullability: com.android.internal.util.FileRotator#FileRotator(java.io.File, String, long, long) parameter #0: + Missing nullability on parameter `basePath` in method `FileRotator` +MissingNullability: com.android.internal.util.FileRotator#FileRotator(java.io.File, String, long, long) parameter #1: + Missing nullability on parameter `prefix` in method `FileRotator` +MissingNullability: com.android.internal.util.FileRotator#dumpAll(java.io.OutputStream) parameter #0: + Missing nullability on parameter `os` in method `dumpAll` +MissingNullability: com.android.internal.util.FileRotator#readMatching(com.android.internal.util.FileRotator.Reader, long, long) parameter #0: + Missing nullability on parameter `reader` in method `readMatching` +MissingNullability: com.android.internal.util.FileRotator#rewriteActive(com.android.internal.util.FileRotator.Rewriter, long) parameter #0: + Missing nullability on parameter `rewriter` in method `rewriteActive` +MissingNullability: com.android.internal.util.FileRotator#rewriteAll(com.android.internal.util.FileRotator.Rewriter) parameter #0: + Missing nullability on parameter `rewriter` in method `rewriteAll` +MissingNullability: com.android.internal.util.FileRotator.Reader#read(java.io.InputStream) parameter #0: + Missing nullability on parameter `in` in method `read` +MissingNullability: com.android.internal.util.FileRotator.Writer#write(java.io.OutputStream) parameter #0: + Missing nullability on parameter `out` in method `write` +MissingNullability: com.android.server.NetworkManagementSocketTagger#kernelToTag(String) parameter #0: + Missing nullability on parameter `string` in method `kernelToTag` +MissingNullability: com.android.server.NetworkManagementSocketTagger#tag(java.io.FileDescriptor) parameter #0: + Missing nullability on parameter `fd` in method `tag` +MissingNullability: com.android.server.NetworkManagementSocketTagger#untag(java.io.FileDescriptor) parameter #0: + Missing nullability on parameter `fd` in method `untag` + + +RethrowRemoteException: android.app.usage.NetworkStatsManager#queryDetails(int, String, long, long): + Methods calling system APIs should rethrow `RemoteException` as `RuntimeException` (but do not list it in the throws clause) +RethrowRemoteException: android.app.usage.NetworkStatsManager#querySummary(int, String, long, long): + Methods calling system APIs should rethrow `RemoteException` as `RuntimeException` (but do not list it in the throws clause) +RethrowRemoteException: android.app.usage.NetworkStatsManager#querySummaryForDevice(int, String, long, long): + Methods calling system APIs should rethrow `RemoteException` as `RuntimeException` (but do not list it in the throws clause) +RethrowRemoteException: android.app.usage.NetworkStatsManager#querySummaryForUser(int, String, long, long): + Methods calling system APIs should rethrow `RemoteException` as `RuntimeException` (but do not list it in the throws clause) + + +StaticFinalBuilder: android.net.IpSecTransform.Builder: + Builder must be final: android.net.IpSecTransform.Builder + + +StaticUtils: android.net.TrafficStats: + Fully-static utility classes must not have constructor + + +UseParcelFileDescriptor: android.net.IpSecManager#applyTransportModeTransform(java.io.FileDescriptor, int, android.net.IpSecTransform) parameter #0: + Must use ParcelFileDescriptor instead of FileDescriptor in parameter socket in android.net.IpSecManager.applyTransportModeTransform(java.io.FileDescriptor socket, int direction, android.net.IpSecTransform transform) +UseParcelFileDescriptor: android.net.IpSecManager#removeTransportModeTransforms(java.io.FileDescriptor) parameter #0: + Must use ParcelFileDescriptor instead of FileDescriptor in parameter socket in android.net.IpSecManager.removeTransportModeTransforms(java.io.FileDescriptor socket) +UseParcelFileDescriptor: android.net.IpSecManager.UdpEncapsulationSocket#getFileDescriptor(): + Must use ParcelFileDescriptor instead of FileDescriptor in method android.net.IpSecManager.UdpEncapsulationSocket.getFileDescriptor() +UseParcelFileDescriptor: android.net.TrafficStats#tagFileDescriptor(java.io.FileDescriptor) parameter #0: + Must use ParcelFileDescriptor instead of FileDescriptor in parameter fd in android.net.TrafficStats.tagFileDescriptor(java.io.FileDescriptor fd) +UseParcelFileDescriptor: android.net.TrafficStats#untagFileDescriptor(java.io.FileDescriptor) parameter #0: + Must use ParcelFileDescriptor instead of FileDescriptor in parameter fd in android.net.TrafficStats.untagFileDescriptor(java.io.FileDescriptor fd) +UseParcelFileDescriptor: com.android.server.NetworkManagementSocketTagger#tag(java.io.FileDescriptor) parameter #0: + Must use ParcelFileDescriptor instead of FileDescriptor in parameter fd in com.android.server.NetworkManagementSocketTagger.tag(java.io.FileDescriptor fd) +UseParcelFileDescriptor: com.android.server.NetworkManagementSocketTagger#untag(java.io.FileDescriptor) parameter #0: + Must use ParcelFileDescriptor instead of FileDescriptor in parameter fd in com.android.server.NetworkManagementSocketTagger.untag(java.io.FileDescriptor fd) diff --git a/framework-t/api/module-lib-current.txt b/framework-t/api/module-lib-current.txt index 2ff3451b15..4be9564569 100644 --- a/framework-t/api/module-lib-current.txt +++ b/framework-t/api/module-lib-current.txt @@ -1,4 +1,29 @@ // Signature format: 2.0 +package android.app.usage { + + public class NetworkStatsManager { + method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK}) public void forceUpdate(); + method public static int getCollapsedRatType(int); + method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK}) public void notifyNetworkStatus(@NonNull java.util.List, @NonNull java.util.List, @Nullable String, @NonNull java.util.List); + method @NonNull @WorkerThread public android.app.usage.NetworkStats queryDetailsForDevice(@NonNull android.net.NetworkTemplate, long, long); + method @NonNull @WorkerThread public android.app.usage.NetworkStats queryDetailsForUidTagState(@NonNull android.net.NetworkTemplate, long, long, int, int, int) throws java.lang.SecurityException; + method @NonNull @WorkerThread public android.app.usage.NetworkStats querySummary(@NonNull android.net.NetworkTemplate, long, long) throws java.lang.SecurityException; + method @NonNull @WorkerThread public android.app.usage.NetworkStats.Bucket querySummaryForDevice(@NonNull android.net.NetworkTemplate, long, long); + method @NonNull @WorkerThread public android.app.usage.NetworkStats queryTaggedSummary(@NonNull android.net.NetworkTemplate, long, long) throws java.lang.SecurityException; + method public void registerUsageCallback(@NonNull android.net.NetworkTemplate, long, @NonNull java.util.concurrent.Executor, @NonNull android.app.usage.NetworkStatsManager.UsageCallback); + method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK}) public void setDefaultGlobalAlert(long); + method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK}) public void setPollOnOpen(boolean); + method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK}) public void setStatsProviderWarningAndLimitAsync(@NonNull String, long, long); + method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK}) public void setUidForeground(int, boolean); + field public static final int NETWORK_TYPE_5G_NSA = -2; // 0xfffffffe + } + + public abstract static class NetworkStatsManager.UsageCallback { + method public void onThresholdReached(@NonNull android.net.NetworkTemplate); + } + +} + package android.net { public final class ConnectivityFrameworkInitializerTiramisu { @@ -13,5 +38,134 @@ package android.net { method public int getResourceId(); } + public class NetworkIdentity { + method public int getOemManaged(); + method public int getRatType(); + method @Nullable public String getSubscriberId(); + method public int getType(); + method @Nullable public String getWifiNetworkKey(); + method public boolean isDefaultNetwork(); + method public boolean isMetered(); + method public boolean isRoaming(); + } + + public static final class NetworkIdentity.Builder { + ctor public NetworkIdentity.Builder(); + method @NonNull public android.net.NetworkIdentity build(); + method @NonNull public android.net.NetworkIdentity.Builder clearRatType(); + method @NonNull public android.net.NetworkIdentity.Builder setDefaultNetwork(boolean); + method @NonNull public android.net.NetworkIdentity.Builder setMetered(boolean); + method @NonNull public android.net.NetworkIdentity.Builder setNetworkStateSnapshot(@NonNull android.net.NetworkStateSnapshot); + method @NonNull public android.net.NetworkIdentity.Builder setOemManaged(int); + method @NonNull public android.net.NetworkIdentity.Builder setRatType(int); + method @NonNull public android.net.NetworkIdentity.Builder setRoaming(boolean); + method @NonNull public android.net.NetworkIdentity.Builder setSubscriberId(@Nullable String); + method @NonNull public android.net.NetworkIdentity.Builder setType(int); + method @NonNull public android.net.NetworkIdentity.Builder setWifiNetworkKey(@Nullable String); + } + + public final class NetworkStateSnapshot implements android.os.Parcelable { + ctor public NetworkStateSnapshot(@NonNull android.net.Network, @NonNull android.net.NetworkCapabilities, @NonNull android.net.LinkProperties, @Nullable String, int); + method public int describeContents(); + method public int getLegacyType(); + method @NonNull public android.net.LinkProperties getLinkProperties(); + method @NonNull public android.net.Network getNetwork(); + method @NonNull public android.net.NetworkCapabilities getNetworkCapabilities(); + method @Nullable public String getSubscriberId(); + method public void writeToParcel(@NonNull android.os.Parcel, int); + field @NonNull public static final android.os.Parcelable.Creator CREATOR; + } + + public class NetworkStatsCollection { + method @NonNull public java.util.Map getEntries(); + } + + public static final class NetworkStatsCollection.Builder { + ctor public NetworkStatsCollection.Builder(long); + method @NonNull public android.net.NetworkStatsCollection.Builder addEntry(@NonNull android.net.NetworkStatsCollection.Key, @NonNull android.net.NetworkStatsHistory); + method @NonNull public android.net.NetworkStatsCollection build(); + } + + public static class NetworkStatsCollection.Key { + ctor public NetworkStatsCollection.Key(@NonNull java.util.Set, int, int, int); + } + + public final class NetworkStatsHistory implements android.os.Parcelable { + method public int describeContents(); + method @NonNull public java.util.List getEntries(); + method public void writeToParcel(@NonNull android.os.Parcel, int); + field @NonNull public static final android.os.Parcelable.Creator CREATOR; + } + + public static final class NetworkStatsHistory.Builder { + ctor public NetworkStatsHistory.Builder(long, int); + method @NonNull public android.net.NetworkStatsHistory.Builder addEntry(@NonNull android.net.NetworkStatsHistory.Entry); + method @NonNull public android.net.NetworkStatsHistory build(); + } + + public static final class NetworkStatsHistory.Entry { + ctor public NetworkStatsHistory.Entry(long, long, long, long, long, long, long); + method public long getActiveTime(); + method public long getBucketStart(); + method public long getOperations(); + method public long getRxBytes(); + method public long getRxPackets(); + method public long getTxBytes(); + method public long getTxPackets(); + } + + public final class NetworkTemplate implements android.os.Parcelable { + method public int describeContents(); + method public int getDefaultNetworkStatus(); + method public int getMatchRule(); + method public int getMeteredness(); + method public int getOemManaged(); + method public int getRatType(); + method public int getRoaming(); + method @NonNull public java.util.Set getSubscriberIds(); + method @NonNull public java.util.Set getWifiNetworkKeys(); + method public boolean matches(@NonNull android.net.NetworkIdentity); + method public void writeToParcel(@NonNull android.os.Parcel, int); + field @NonNull public static final android.os.Parcelable.Creator CREATOR; + field public static final int MATCH_BLUETOOTH = 8; // 0x8 + field public static final int MATCH_CARRIER = 10; // 0xa + field public static final int MATCH_ETHERNET = 5; // 0x5 + field public static final int MATCH_MOBILE = 1; // 0x1 + field public static final int MATCH_WIFI = 4; // 0x4 + field public static final int NETWORK_TYPE_ALL = -1; // 0xffffffff + field public static final int OEM_MANAGED_ALL = -1; // 0xffffffff + field public static final int OEM_MANAGED_NO = 0; // 0x0 + field public static final int OEM_MANAGED_PAID = 1; // 0x1 + field public static final int OEM_MANAGED_PRIVATE = 2; // 0x2 + field public static final int OEM_MANAGED_YES = -2; // 0xfffffffe + } + + public static final class NetworkTemplate.Builder { + ctor public NetworkTemplate.Builder(int); + method @NonNull public android.net.NetworkTemplate build(); + method @NonNull public android.net.NetworkTemplate.Builder setDefaultNetworkStatus(int); + method @NonNull public android.net.NetworkTemplate.Builder setMeteredness(int); + method @NonNull public android.net.NetworkTemplate.Builder setOemManaged(int); + method @NonNull public android.net.NetworkTemplate.Builder setRatType(int); + method @NonNull public android.net.NetworkTemplate.Builder setRoaming(int); + method @NonNull public android.net.NetworkTemplate.Builder setSubscriberIds(@NonNull java.util.Set); + method @NonNull public android.net.NetworkTemplate.Builder setWifiNetworkKeys(@NonNull java.util.Set); + } + + public class TrafficStats { + method public static void attachSocketTagger(); + method public static void init(@NonNull android.content.Context); + } + + public final class UnderlyingNetworkInfo implements android.os.Parcelable { + ctor public UnderlyingNetworkInfo(int, @NonNull String, @NonNull java.util.List); + method public int describeContents(); + method @NonNull public String getInterface(); + method public int getOwnerUid(); + method @NonNull public java.util.List getUnderlyingInterfaces(); + method public void writeToParcel(@NonNull android.os.Parcel, int); + field @NonNull public static final android.os.Parcelable.Creator CREATOR; + } + } diff --git a/framework-t/api/module-lib-lint-baseline.txt b/framework-t/api/module-lib-lint-baseline.txt new file mode 100644 index 0000000000..3158bd4596 --- /dev/null +++ b/framework-t/api/module-lib-lint-baseline.txt @@ -0,0 +1,7 @@ +// Baseline format: 1.0 +BannedThrow: android.app.usage.NetworkStatsManager#queryDetailsForUidTagState(android.net.NetworkTemplate, long, long, int, int, int): + Methods must not mention RuntimeException subclasses in throws clauses (was `java.lang.SecurityException`) +BannedThrow: android.app.usage.NetworkStatsManager#querySummary(android.net.NetworkTemplate, long, long): + Methods must not mention RuntimeException subclasses in throws clauses (was `java.lang.SecurityException`) +BannedThrow: android.app.usage.NetworkStatsManager#queryTaggedSummary(android.net.NetworkTemplate, long, long): + Methods must not mention RuntimeException subclasses in throws clauses (was `java.lang.SecurityException`) diff --git a/framework-t/api/removed.txt b/framework-t/api/removed.txt index d802177e24..1ba87d8a26 100644 --- a/framework-t/api/removed.txt +++ b/framework-t/api/removed.txt @@ -1 +1,9 @@ // Signature format: 2.0 +package android.net { + + public class TrafficStats { + method @Deprecated public static void setThreadStatsUidSelf(); + } + +} + diff --git a/framework-t/api/system-current.txt b/framework-t/api/system-current.txt index 041bcaf658..bc9c1b44b4 100644 --- a/framework-t/api/system-current.txt +++ b/framework-t/api/system-current.txt @@ -1,4 +1,15 @@ // Signature format: 2.0 +package android.app.usage { + + public class NetworkStatsManager { + method @NonNull @RequiresPermission(android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK) public android.net.NetworkStats getMobileUidStats(); + method @NonNull @RequiresPermission(android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK) public android.net.NetworkStats getWifiUidStats(); + method @NonNull @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 @NonNull @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.net { public class IpSecManager { @@ -18,5 +29,77 @@ package android.net { 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.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 int describeContents(); + method @NonNull public java.util.Iterator 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 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 setThreadStatsTagDownload(); + 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 + } + } diff --git a/framework/Android.bp b/framework/Android.bp index da16a8ddfe..481f3751ac 100644 --- a/framework/Android.bp +++ b/framework/Android.bp @@ -63,6 +63,7 @@ java_defaults { srcs: [ ":framework-connectivity-sources", ":net-utils-framework-common-srcs", + ":framework-connectivity-api-shared-srcs", ], aidl: { generate_get_transaction_name: true, @@ -84,6 +85,7 @@ java_defaults { "net-utils-device-common", ], static_libs: [ + "framework-connectivity-protos", "modules-utils-build", "modules-utils-preconditions", ], @@ -177,3 +179,23 @@ cc_library_shared { "com.android.tethering", ], } + +// TODO: reduce size of this library; consider using +// proto nano for example +java_library { + name: "framework-connectivity-protos", + sdk_version: "module_current", + min_sdk_version: "30", + proto: { + type: "lite", + }, + srcs: [ + "proto/**/*.*", + ], + static_libs: ["libprotobuf-java-lite"], + apex_available: [ + "com.android.tethering", + ], + lint: { strict_updatability_linting: true }, + visibility: ["//visibility:private"], +} diff --git a/framework/proto/netstats.proto b/framework/proto/netstats.proto new file mode 100644 index 0000000000..3c9f73cc57 --- /dev/null +++ b/framework/proto/netstats.proto @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +syntax = "proto2"; +package android.service; + +option java_multiple_files = true; +option java_outer_classname = "NetworkStatsServiceProto"; + +// Represents dumpsys from NetworkStatsService (netstats). +message NetworkStatsServiceDumpProto { + repeated NetworkInterfaceProto active_interfaces = 1; + + repeated NetworkInterfaceProto active_uid_interfaces = 2; + + // Device level network stats, which may include non-IP layer traffic. + optional NetworkStatsRecorderProto dev_stats = 3; + + // IP-layer traffic stats. + optional NetworkStatsRecorderProto xt_stats = 4; + + // Per-UID network stats. + optional NetworkStatsRecorderProto uid_stats = 5; + + // Per-UID, per-tag network stats, excluding the default tag (i.e. tag=0). + optional NetworkStatsRecorderProto uid_tag_stats = 6; +} + +// Corresponds to NetworkStatsService.mActiveIfaces/mActiveUidIfaces. +message NetworkInterfaceProto { + // Name of the network interface (eg: wlan). + optional string interface = 1; + + optional NetworkIdentitySetProto identities = 2; +} + +// Corresponds to NetworkIdentitySet. +message NetworkIdentitySetProto { + repeated NetworkIdentityProto identities = 1; +} + +// Corresponds to NetworkIdentity. +message NetworkIdentityProto { + // Constants from ConnectivityManager.TYPE_*. + optional int32 type = 1; + + optional bool roaming = 4; + + optional bool metered = 5; + + optional bool default_network = 6; + + optional int32 oem_managed_network = 7; +} + +// Corresponds to NetworkStatsRecorder. +message NetworkStatsRecorderProto { + optional int64 pending_total_bytes = 1; + + optional NetworkStatsCollectionProto complete_history = 2; +} + +// Corresponds to NetworkStatsCollection. +message NetworkStatsCollectionProto { + repeated NetworkStatsCollectionStatsProto stats = 1; +} + +// Corresponds to NetworkStatsCollection.mStats. +message NetworkStatsCollectionStatsProto { + optional NetworkStatsCollectionKeyProto key = 1; + + optional NetworkStatsHistoryProto history = 2; +} + +// Corresponds to NetworkStatsCollection.Key. +message NetworkStatsCollectionKeyProto { + optional NetworkIdentitySetProto identity = 1; + + optional int32 uid = 2; + + optional int32 set = 3; + + optional int32 tag = 4; +} + +// Corresponds to NetworkStatsHistory. +message NetworkStatsHistoryProto { + // Duration for this bucket in milliseconds. + optional int64 bucket_duration_ms = 1; + + repeated NetworkStatsHistoryBucketProto buckets = 2; +} + +// Corresponds to each bucket in NetworkStatsHistory. +message NetworkStatsHistoryBucketProto { + // Bucket start time in milliseconds since epoch. + optional int64 bucket_start_ms = 1; + + optional int64 rx_bytes = 2; + + optional int64 rx_packets = 3; + + optional int64 tx_bytes = 4; + + optional int64 tx_packets = 5; + + optional int64 operations = 6; +} \ No newline at end of file diff --git a/service-t/Android.bp b/service-t/Android.bp index 8ba07685a2..6612318f4d 100644 --- a/service-t/Android.bp +++ b/service-t/Android.bp @@ -30,8 +30,6 @@ java_library { min_sdk_version: "30", srcs: [ "src/**/*.java", - // TODO: This is necessary just for LocalLog, remove after removing NativeDaemonConnector. - ":framework-connectivity-shared-srcs", ":services.connectivity-tiramisu-updatable-sources", ], libs: [ diff --git a/service/Android.bp b/service/Android.bp index 33fe3eac1b..eed84fe066 100644 --- a/service/Android.bp +++ b/service/Android.bp @@ -95,6 +95,7 @@ java_library { libs: [ "framework-annotations-lib", "framework-connectivity-pre-jarjar", + "framework-connectivity-tiramisu.stubs.module_lib", "framework-tethering.stubs.module_lib", "framework-wifi.stubs.module_lib", "unsupportedappusage", diff --git a/service/jarjar-rules.txt b/service/jarjar-rules.txt index e3b26fd928..65ed8a3050 100644 --- a/service/jarjar-rules.txt +++ b/service/jarjar-rules.txt @@ -9,19 +9,22 @@ rule android.net.NetworkFactory* android.net.connectivity.@0 # From modules-utils-preconditions rule com.android.internal.util.Preconditions* android.net.connectivity.@0 +# From framework-connectivity-shared-srcs +rule android.util.LocalLog* android.net.connectivity.@0 +rule android.util.IndentingPrintWriter* android.net.connectivity.@0 +rule com.android.internal.util.IndentingPrintWriter* android.net.connectivity.@0 +rule com.android.internal.util.MessageUtils* android.net.connectivity.@0 +rule com.android.internal.util.WakeupMessage* android.net.connectivity.@0 +rule com.android.internal.util.FileRotator* android.net.connectivity.@0 +rule com.android.internal.util.ProcFileReader* android.net.connectivity.@0 + +# From framework-connectivity-protos +rule com.google.protobuf.** android.net.connectivity.@0 +rule android.service.** android.net.connectivity.@0 + rule android.sysprop.** com.android.connectivity.@0 -# internal util classes from framework-connectivity-shared-srcs -rule android.util.LocalLog* com.android.connectivity.@0 -# android.util.IndentingPrintWriter* should use a different package name from -# the one in com.android.internal.util -rule android.util.IndentingPrintWriter* com.android.connectivity.@0 -rule com.android.internal.util.IndentingPrintWriter* com.android.connectivity.@0 -rule com.android.internal.util.MessageUtils* com.android.connectivity.@0 -rule com.android.internal.util.WakeupMessage* com.android.connectivity.@0 - rule com.android.internal.messages.** com.android.connectivity.@0 -rule com.google.protobuf.** com.android.connectivity.@0 # From dnsresolver_aidl_interface (newer AIDLs should go to android.net.resolv.aidl) rule android.net.resolv.aidl.** com.android.connectivity.@0 From 4eccfdec896faac4003b75da26d3012fed8a1e77 Mon Sep 17 00:00:00 2001 From: junyulai Date: Fri, 25 Feb 2022 10:37:02 +0800 Subject: [PATCH 2/8] [MS54.8] Add hiddenapi-unsupported-t.txt to apex Android.bp This is separated from ag/16657723 to avoid merge conflict at downstream branches. For some downstream branches, the library does not exist and this part is commented out. Test: TH Bug: 197717846 Merged-In: I4eeb7ea9cfc3139991caf0fc22474e0052a0391c Merged-In: I33e0d699086c87ce8e940036c9a52908bbbcf6c5 Change-Id: I031e5687fa47594b50ca1b40570e01cdec356827 --- Tethering/apex/Android.bp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Tethering/apex/Android.bp b/Tethering/apex/Android.bp index 1a4ba9d1ec..fa486a3856 100644 --- a/Tethering/apex/Android.bp +++ b/Tethering/apex/Android.bp @@ -132,7 +132,10 @@ bootclasspath_fragment { "hiddenapi/hiddenapi-max-target-o-low-priority.txt", "hiddenapi/hiddenapi-max-target-o-low-priority-tiramisu.txt", ], - unsupported: ["hiddenapi/hiddenapi-unsupported.txt"], + unsupported: [ + "hiddenapi/hiddenapi-unsupported.txt", + "hiddenapi/hiddenapi-unsupported-tiramisu.txt", + ], }, } From e764686003911cf5c4d8e950746b33e9eaaa2542 Mon Sep 17 00:00:00 2001 From: Junyu Lai Date: Wed, 26 Jan 2022 18:46:46 +0000 Subject: [PATCH 3/8] [MS62.2] Add NetworkStatsService into service initializer NetworkStatsService is going to be moved into Connectivity mainlne module and it will be not visible to SystemServiceResistry after migration done. Thus, register service in NetworkStatsServiceInitialalizer and register manager in ConnectivityFrameworkInitializerTiramisu instead. Ignore-AOSP-First: Avoiding conflicts; cherry-pick will follow Test: FrameworksNetTests CtsNetTestCases Bug: 204830222 (cherry-picked from ag/16727131) Change-Id: I03d947cc54dd995f6b5b4544ee3bf03cf029d143 Merged-In: I03d947cc54dd995f6b5b4544ee3bf03cf029d143 --- .../NetworkStatsServiceInitializer.java | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 service-t/src/com/android/server/NetworkStatsServiceInitializer.java diff --git a/service-t/src/com/android/server/NetworkStatsServiceInitializer.java b/service-t/src/com/android/server/NetworkStatsServiceInitializer.java new file mode 100644 index 0000000000..0ea126a487 --- /dev/null +++ b/service-t/src/com/android/server/NetworkStatsServiceInitializer.java @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server; + +import android.content.Context; +import android.net.TrafficStats; +import android.util.Log; + +import com.android.modules.utils.build.SdkLevel; +import com.android.server.net.NetworkStatsService; + +/** + * NetworkStats service initializer for core networking. This is called by system server to create + * a new instance of NetworkStatsService. + */ +public final class NetworkStatsServiceInitializer extends SystemService { + private static final String TAG = NetworkStatsServiceInitializer.class.getSimpleName(); + private final NetworkStatsService mStatsService; + + public NetworkStatsServiceInitializer(Context context) { + super(context); + // Load JNI libraries used by NetworkStatsService and its dependencies + System.loadLibrary("service-connectivity"); + mStatsService = maybeCreateNetworkStatsService(context); + } + + @Override + public void onStart() { + if (mStatsService != null) { + Log.i(TAG, "Registering " + Context.NETWORK_STATS_SERVICE); + publishBinderService(Context.NETWORK_STATS_SERVICE, mStatsService, + /* allowIsolated= */ false); + TrafficStats.init(getContext()); + } + } + + @Override + public void onBootPhase(int phase) { + // This has to be run before StatsPullAtomService query usage at + // PHASE_THIRD_PARTY_APPS_CAN_START. + if (phase == SystemService.PHASE_ACTIVITY_MANAGER_READY && mStatsService != null) { + mStatsService.systemReady(); + } + } + + /** + * Return NetworkStatsService instance, or null if current SDK is lower than T. + */ + private NetworkStatsService maybeCreateNetworkStatsService(final Context context) { + if (!SdkLevel.isAtLeastT()) return null; + + return NetworkStatsService.create(context); + } +} From d95048929cc01cad6ca200d7ff318f6daf6eb425 Mon Sep 17 00:00:00 2001 From: Remi NGUYEN VAN Date: Wed, 2 Feb 2022 13:03:29 +0900 Subject: [PATCH 4/8] Add JNI stats libraries to connectivity Add new symbols to libservice-connectivity loaded on T only, and the framework libraries to apex and tests. Bug: 197717846 Test: atest FrameworksNetTests (cherry-picked and splitting apex Android.bp to aosp/1994130) Change-Id: Iae44344701a3267110e5cbf271120201134d59e5 Merged-In: Iae44344701a3267110e5cbf271120201134d59e5 --- service-t/native/libs/libnetworkstats/Android.bp | 1 - service/Android.bp | 5 +++++ service/jni/onload.cpp | 14 ++++++++++++++ tests/unit/Android.bp | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/service-t/native/libs/libnetworkstats/Android.bp b/service-t/native/libs/libnetworkstats/Android.bp index d24b14b51f..bf56fd5609 100644 --- a/service-t/native/libs/libnetworkstats/Android.bp +++ b/service-t/native/libs/libnetworkstats/Android.bp @@ -41,7 +41,6 @@ cc_library { cfi: true, }, apex_available: [ - "//apex_available:platform", "com.android.tethering", ], min_sdk_version: "30", diff --git a/service/Android.bp b/service/Android.bp index eed84fe066..2cfab1e5bb 100644 --- a/service/Android.bp +++ b/service/Android.bp @@ -55,6 +55,7 @@ cc_library_shared { "-Wthread-safety", ], srcs: [ + ":services.connectivity-netstats-jni-sources", "jni/com_android_server_BpfNetMaps.cpp", "jni/com_android_server_connectivity_ClatCoordinator.cpp", "jni/com_android_server_TestNetworkService.cpp", @@ -66,15 +67,19 @@ cc_library_shared { static_libs: [ "libclat", "libip_checksum", + "libmodules-utils-build", "libnetjniutils", + "libnet_utils_device_common_bpfjni", "libtraffic_controller", "netd_aidl_interface-lateststable-ndk", ], shared_libs: [ "libbase", + "libcutils", "libnetdutils", "liblog", "libnativehelper", + "libnetworkstats", ], apex_available: [ "com.android.tethering", diff --git a/service/jni/onload.cpp b/service/jni/onload.cpp index facdad7041..3d15d43db4 100644 --- a/service/jni/onload.cpp +++ b/service/jni/onload.cpp @@ -17,11 +17,15 @@ #include #include +#include + namespace android { int register_com_android_server_TestNetworkService(JNIEnv* env); int register_com_android_server_connectivity_ClatCoordinator(JNIEnv* env); int register_com_android_server_BpfNetMaps(JNIEnv* env); +int register_android_server_net_NetworkStatsFactory(JNIEnv* env); +int register_android_server_net_NetworkStatsService(JNIEnv* env); extern "C" jint JNI_OnLoad(JavaVM* vm, void*) { JNIEnv *env; @@ -42,6 +46,16 @@ extern "C" jint JNI_OnLoad(JavaVM* vm, void*) { return JNI_ERR; } + if (android::modules::sdklevel::IsAtLeastT()) { + if (register_android_server_net_NetworkStatsFactory(env) < 0) { + return JNI_ERR; + } + + if (register_android_server_net_NetworkStatsService(env) < 0) { + return JNI_ERR; + } + } + return JNI_VERSION_1_6; } diff --git a/tests/unit/Android.bp b/tests/unit/Android.bp index fde7bac4fd..eaceb9a171 100644 --- a/tests/unit/Android.bp +++ b/tests/unit/Android.bp @@ -167,6 +167,7 @@ android_test { "services.net", ], jni_libs: [ + "libandroid_net_connectivity_com_android_net_module_util_jni", "libservice-connectivity", "libandroid_net_connectivity_com_android_net_module_util_jni", ], From 6187e7c79a7a63b415e15a71216e9481ec4405b4 Mon Sep 17 00:00:00 2001 From: junyulai Date: Tue, 22 Feb 2022 16:37:25 +0800 Subject: [PATCH 5/8] Add JNI stats libraries to apex Android.bp This is separated from ag/16766427 to avoid merge conflict at downstream branches. For some downstream branches, the library does not exist and this part is commented out. Bug: 197717846 Test: atest FrameworksNetTests Merged-In: Idb6da7ce678fbb3f4839604726cbdbdf223144c1 Merged-In: Iae44344701a3267110e5cbf271120201134d59e5 Change-Id: I9d7f6cea1cdb3c8117e677d8c204e3985295ada0 --- Tethering/apex/Android.bp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Tethering/apex/Android.bp b/Tethering/apex/Android.bp index fa486a3856..85aec96bb3 100644 --- a/Tethering/apex/Android.bp +++ b/Tethering/apex/Android.bp @@ -57,7 +57,10 @@ apex { native_shared_libs: ["libnetd_updatable"], }, both: { - jni_libs: ["libframework-connectivity-jni"], + jni_libs: [ + "libframework-connectivity-jni", + "libframework-connectivity-tiramisu-jni" + ], }, }, binaries: [ From 73a61e7c28797273378df3b2293184bd607f928c Mon Sep 17 00:00:00 2001 From: Remi NGUYEN VAN Date: Thu, 3 Feb 2022 11:32:46 +0900 Subject: [PATCH 6/8] Add setPollForce to module API The API was test API in S, but this is not supported in module API surfaces. Make it module API instead. Ignore-AOSP-First: Avoiding merge conflicts. Cherry-pick will follow Bug: 197717846 Test: Tests already using this API (cherry-picked from ag/16780903) Change-Id: I53959f0ad4c7a41950e9349d539be82b9166b707 Merged-In: I53959f0ad4c7a41950e9349d539be82b9166b707 --- framework-t/api/module-lib-current.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/framework-t/api/module-lib-current.txt b/framework-t/api/module-lib-current.txt index 4be9564569..387a0c0496 100644 --- a/framework-t/api/module-lib-current.txt +++ b/framework-t/api/module-lib-current.txt @@ -12,6 +12,7 @@ package android.app.usage { method @NonNull @WorkerThread public android.app.usage.NetworkStats queryTaggedSummary(@NonNull android.net.NetworkTemplate, long, long) throws java.lang.SecurityException; method public void registerUsageCallback(@NonNull android.net.NetworkTemplate, long, @NonNull java.util.concurrent.Executor, @NonNull android.app.usage.NetworkStatsManager.UsageCallback); method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK}) public void setDefaultGlobalAlert(long); + method public void setPollForce(boolean); method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK}) public void setPollOnOpen(boolean); method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK}) public void setStatsProviderWarningAndLimitAsync(@NonNull String, long, long); method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK}) public void setUidForeground(int, boolean); From 3d52172838cca58593a7a8c6de53af4f543a010c Mon Sep 17 00:00:00 2001 From: Lorenzo Colitti Date: Fri, 4 Feb 2022 01:39:01 +0900 Subject: [PATCH 7/8] Update tests for NetworkStats code move. NetworkStatsFactory is moving from services.core to service-connectivity-tiramisu. Update FrameworksNetSmokeTests and FrameworksNetIntegrationTests to depend on the latter instead of the former. Test: atest FrameworksNetSmokeTests FrameworksNetIntegrationTests Ignore-AOSP-First: part of large internal topic to avoid merge conflicts (cherry-picked from ag/16786005) Change-Id: Ie48dac421decf83440b7c88adea18152e05f03bb Merged-In: Ie48dac421decf83440b7c88adea18152e05f03bb --- tests/integration/Android.bp | 2 +- tests/smoketest/Android.bp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/Android.bp b/tests/integration/Android.bp index 530fa913a8..97c1265f6e 100644 --- a/tests/integration/Android.bp +++ b/tests/integration/Android.bp @@ -40,7 +40,7 @@ android_test { "mockito-target-extended-minus-junit4", "net-tests-utils", "service-connectivity-pre-jarjar", - "services.core", + "service-connectivity-tiramisu-pre-jarjar", "services.net", "testables", ], diff --git a/tests/smoketest/Android.bp b/tests/smoketest/Android.bp index 8011540293..df8ab74be2 100644 --- a/tests/smoketest/Android.bp +++ b/tests/smoketest/Android.bp @@ -22,6 +22,6 @@ android_test { static_libs: [ "androidx.test.rules", "mockito-target-minus-junit4", - "services.core", + "service-connectivity", ], } From 9e066c9faf94c48e2fd8b2f613c7f4035bb3e4c5 Mon Sep 17 00:00:00 2001 From: Lorenzo Colitti Date: Fri, 4 Feb 2022 03:08:12 +0900 Subject: [PATCH 8/8] Update API files to unhide MATCH_PROXY. Bug: 204830222 Test: m Ignore-AOSP-First: part of topic with internal-only code (cherry-picked from ag/16786006) Change-Id: I9e11eea30ea9c988498e005c33f173ba2d0a32ec Merged-In: I9e11eea30ea9c988498e005c33f173ba2d0a32ec --- framework-t/api/module-lib-current.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/framework-t/api/module-lib-current.txt b/framework-t/api/module-lib-current.txt index 387a0c0496..4304f6ae86 100644 --- a/framework-t/api/module-lib-current.txt +++ b/framework-t/api/module-lib-current.txt @@ -132,6 +132,7 @@ package android.net { field public static final int MATCH_CARRIER = 10; // 0xa field public static final int MATCH_ETHERNET = 5; // 0x5 field public static final int MATCH_MOBILE = 1; // 0x1 + field public static final int MATCH_PROXY = 9; // 0x9 field public static final int MATCH_WIFI = 4; // 0x4 field public static final int NETWORK_TYPE_ALL = -1; // 0xffffffff field public static final int OEM_MANAGED_ALL = -1; // 0xffffffff