diff --git a/service-t/src/com/android/server/net/NetworkIdentitySet.java b/framework-t/src/android/net/NetworkIdentitySet.java similarity index 97% rename from service-t/src/com/android/server/net/NetworkIdentitySet.java rename to framework-t/src/android/net/NetworkIdentitySet.java index 22ed781da9..abbebef85c 100644 --- a/service-t/src/com/android/server/net/NetworkIdentitySet.java +++ b/framework-t/src/android/net/NetworkIdentitySet.java @@ -14,9 +14,10 @@ * limitations under the License. */ -package com.android.server.net; +package android.net; + +import static android.net.ConnectivityManager.TYPE_MOBILE; -import android.net.NetworkIdentity; import android.service.NetworkIdentitySetProto; import android.util.proto.ProtoOutputStream; @@ -25,8 +26,6 @@ import java.io.DataOutput; import java.io.IOException; import java.util.HashSet; -import static android.net.ConnectivityManager.TYPE_MOBILE; - /** * Identity of a {@code iface}, defined by the set of {@link NetworkIdentity} * active on that interface. @@ -97,6 +96,9 @@ public class NetworkIdentitySet extends HashSet implements } } + /** + * Method to serialize this object into a {@code DataOutput}. + */ public void writeToStream(DataOutput out) throws IOException { out.writeInt(VERSION_ADD_OEM_MANAGED_NETWORK); out.writeInt(size()); @@ -179,6 +181,9 @@ public class NetworkIdentitySet extends HashSet implements return ident.compareTo(anotherIdent); } + /** + * Method to dump this object into proto debug file. + */ public void dumpDebug(ProtoOutputStream proto, long tag) { final long start = proto.start(tag); diff --git a/service-t/src/com/android/server/net/NetworkStatsAccess.java b/framework-t/src/android/net/NetworkStatsAccess.java similarity index 98% rename from service-t/src/com/android/server/net/NetworkStatsAccess.java rename to framework-t/src/android/net/NetworkStatsAccess.java index d25eae409d..3885a9e6d5 100644 --- a/service-t/src/com/android/server/net/NetworkStatsAccess.java +++ b/framework-t/src/android/net/NetworkStatsAccess.java @@ -11,10 +11,10 @@ * 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 + * limitations under the License. */ -package com.android.server.net; +package android.net; import static android.Manifest.permission.READ_NETWORK_USAGE_HISTORY; import static android.net.NetworkStats.UID_ALL; @@ -37,7 +37,11 @@ import com.android.server.LocalServices; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -/** Utility methods for controlling access to network stats APIs. */ +/** + * Utility methods for controlling access to network stats APIs. + * + * @hide + */ public final class NetworkStatsAccess { private NetworkStatsAccess() {} diff --git a/service-t/src/com/android/server/net/NetworkStatsCollection.java b/framework-t/src/android/net/NetworkStatsCollection.java similarity index 97% rename from service-t/src/com/android/server/net/NetworkStatsCollection.java rename to framework-t/src/android/net/NetworkStatsCollection.java index 213ea402f5..0d3b9ed4e3 100644 --- a/service-t/src/com/android/server/net/NetworkStatsCollection.java +++ b/framework-t/src/android/net/NetworkStatsCollection.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server.net; +package android.net; import static android.net.NetworkStats.DEFAULT_NETWORK_NO; import static android.net.NetworkStats.DEFAULT_NETWORK_YES; @@ -31,13 +31,7 @@ import static android.net.TrafficStats.UID_REMOVED; import static android.text.format.DateUtils.WEEK_IN_MILLIS; import static com.android.internal.net.NetworkUtilsInternal.multiplySafeByRational; -import static com.android.server.net.NetworkStatsService.TAG; -import android.net.NetworkIdentity; -import android.net.NetworkStats; -import android.net.NetworkStatsHistory; -import android.net.NetworkTemplate; -import android.net.TrafficStats; import android.os.Binder; import android.service.NetworkStatsCollectionKeyProto; import android.service.NetworkStatsCollectionProto; @@ -85,8 +79,11 @@ import java.util.Objects; /** * Collection of {@link NetworkStatsHistory}, stored based on combined key of * {@link NetworkIdentitySet}, UID, set, and tag. Knows how to persist itself. + * + * @hide */ public class NetworkStatsCollection implements FileRotator.Reader, FileRotator.Writer { + private static final String TAG = NetworkStatsCollection.class.getSimpleName(); /** File header magic number: "ANET" */ private static final int FILE_MAGIC = 0x414E4554; @@ -366,8 +363,8 @@ public class NetworkStatsCollection implements FileRotator.Reader, FileRotator.W entry.uid = key.uid; entry.set = key.set; entry.tag = key.tag; - entry.defaultNetwork = key.ident.areAllMembersOnDefaultNetwork() ? - DEFAULT_NETWORK_YES : DEFAULT_NETWORK_NO; + entry.defaultNetwork = key.ident.areAllMembersOnDefaultNetwork() + ? DEFAULT_NETWORK_YES : DEFAULT_NETWORK_NO; entry.metered = key.ident.isAnyMemberMetered() ? METERED_YES : METERED_NO; entry.roaming = key.ident.isAnyMemberRoaming() ? ROAMING_YES : ROAMING_NO; entry.rxBytes = historyEntry.rxBytes; @@ -521,6 +518,12 @@ public class NetworkStatsCollection implements FileRotator.Reader, FileRotator.W } } + /** + * Read legacy network summary statistics file format into the collection, + * See {@code NetworkStatsService#maybeUpgradeLegacyStatsLocked}. + * + * @deprecated + */ @Deprecated public void readLegacyNetwork(File file) throws IOException { final AtomicFile inputFile = new AtomicFile(file); @@ -560,6 +563,12 @@ public class NetworkStatsCollection implements FileRotator.Reader, FileRotator.W } } + /** + * Read legacy Uid statistics file format into the collection, + * See {@code NetworkStatsService#maybeUpgradeLegacyStatsLocked}. + * + * @deprecated + */ @Deprecated public void readLegacyUid(File file, boolean onlyTags) throws IOException { final AtomicFile inputFile = new AtomicFile(file); @@ -774,19 +783,19 @@ public class NetworkStatsCollection implements FileRotator.Reader, FileRotator.W public final int set; public final int tag; - private final int hashCode; + private final int mHashCode; - public Key(NetworkIdentitySet ident, int uid, int set, int tag) { + Key(NetworkIdentitySet ident, int uid, int set, int tag) { this.ident = ident; this.uid = uid; this.set = set; this.tag = tag; - hashCode = Objects.hash(ident, uid, set, tag); + mHashCode = Objects.hash(ident, uid, set, tag); } @Override public int hashCode() { - return hashCode; + return mHashCode; } @Override diff --git a/service-t/src/com/android/server/net/NetworkStatsObservers.java b/service-t/src/com/android/server/net/NetworkStatsObservers.java index 2564daeaa1..1a0866d2f9 100644 --- a/service-t/src/com/android/server/net/NetworkStatsObservers.java +++ b/service-t/src/com/android/server/net/NetworkStatsObservers.java @@ -22,7 +22,10 @@ import static com.android.internal.util.Preconditions.checkArgument; import android.app.usage.NetworkStatsManager; import android.net.DataUsageRequest; +import android.net.NetworkIdentitySet; import android.net.NetworkStats; +import android.net.NetworkStatsAccess; +import android.net.NetworkStatsCollection; import android.net.NetworkStatsHistory; import android.net.NetworkTemplate; import android.os.Bundle; diff --git a/service-t/src/com/android/server/net/NetworkStatsRecorder.java b/service-t/src/com/android/server/net/NetworkStatsRecorder.java index 978ae87d39..5e27c776cc 100644 --- a/service-t/src/com/android/server/net/NetworkStatsRecorder.java +++ b/service-t/src/com/android/server/net/NetworkStatsRecorder.java @@ -21,8 +21,11 @@ import static android.net.TrafficStats.KB_IN_BYTES; import static android.net.TrafficStats.MB_IN_BYTES; import static android.text.format.DateUtils.YEAR_IN_MILLIS; +import android.net.NetworkIdentitySet; import android.net.NetworkStats; import android.net.NetworkStats.NonMonotonicObserver; +import android.net.NetworkStatsAccess; +import android.net.NetworkStatsCollection; import android.net.NetworkStatsHistory; import android.net.NetworkTemplate; import android.net.TrafficStats; diff --git a/service-t/src/com/android/server/net/NetworkStatsService.java b/service-t/src/com/android/server/net/NetworkStatsService.java index c876d411fa..2beca73ecd 100644 --- a/service-t/src/com/android/server/net/NetworkStatsService.java +++ b/service-t/src/com/android/server/net/NetworkStatsService.java @@ -96,11 +96,14 @@ import android.net.INetworkStatsSession; import android.net.Network; import android.net.NetworkCapabilities; import android.net.NetworkIdentity; +import android.net.NetworkIdentitySet; import android.net.NetworkSpecifier; import android.net.NetworkStack; import android.net.NetworkStateSnapshot; import android.net.NetworkStats; import android.net.NetworkStats.NonMonotonicObserver; +import android.net.NetworkStatsAccess; +import android.net.NetworkStatsCollection; import android.net.NetworkStatsHistory; import android.net.NetworkTemplate; import android.net.TelephonyNetworkSpecifier;