Merge changes from topic "ms07-movestats" am: 942c713c9d

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1895044

Change-Id: I85d704b09dac07e91b8400a2bbd15867e2b80d6d
This commit is contained in:
Treehugger Robot
2021-12-10 18:57:08 +00:00
committed by Automerger Merge Worker
30 changed files with 145 additions and 26 deletions

View File

@@ -19,11 +19,58 @@ package {
default_applicable_licenses: ["Android-Apache-2.0"], default_applicable_licenses: ["Android-Apache-2.0"],
} }
// NetworkStats related libraries.
filegroup {
name: "framework-connectivity-netstats-internal-sources",
srcs: [
"src/android/app/usage/*.java",
"src/android/net/DataUsage*.*",
"src/android/net/INetworkStats*.*",
"src/android/net/NetworkIdentity*.java",
"src/android/net/NetworkStateSnapshot.*",
"src/android/net/NetworkStats*.*",
"src/android/net/NetworkTemplate.*",
"src/android/net/TrafficStats.java",
"src/android/net/UnderlyingNetworkInfo.*",
"src/android/net/netstats/**/*.*",
],
path: "src",
visibility: [
"//visibility:private",
],
}
filegroup {
name: "framework-connectivity-netstats-aidl-export-sources",
srcs: [
"aidl-export/android/net/NetworkStats.aidl",
"aidl-export/android/net/NetworkTemplate.aidl",
],
path: "aidl-export",
visibility: [
"//visibility:private",
],
}
filegroup {
name: "framework-connectivity-netstats-sources",
srcs: [
":framework-connectivity-netstats-internal-sources",
":framework-connectivity-netstats-aidl-export-sources",
],
visibility: [
"//visibility:private",
],
}
// Nsd related libraries.
filegroup { filegroup {
name: "framework-connectivity-nsd-internal-sources", name: "framework-connectivity-nsd-internal-sources",
srcs: [ srcs: [
"src/**/*.java", "src/android/net/nsd/*.aidl",
"src/**/*.aidl", "src/android/net/nsd/*.java",
], ],
path: "src", path: "src",
visibility: [ visibility: [
@@ -34,7 +81,7 @@ filegroup {
filegroup { filegroup {
name: "framework-connectivity-nsd-aidl-export-sources", name: "framework-connectivity-nsd-aidl-export-sources",
srcs: [ srcs: [
"aidl-export/**/*.aidl", "aidl-export/android/net/nsd/*.aidl",
], ],
path: "aidl-export", path: "aidl-export",
visibility: [ visibility: [
@@ -49,6 +96,19 @@ filegroup {
":framework-connectivity-nsd-aidl-export-sources", ":framework-connectivity-nsd-aidl-export-sources",
], ],
visibility: [ visibility: [
"//frameworks/base", "//visibility:private",
], ],
} }
// Connectivity-T common libraries.
filegroup {
name: "framework-connectivity-tiramisu-sources",
srcs: [
":framework-connectivity-netstats-sources",
":framework-connectivity-nsd-sources",
],
visibility: [
"//frameworks/base",
],
}

View File

@@ -14,9 +14,10 @@
* limitations under the License. * 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.service.NetworkIdentitySetProto;
import android.util.proto.ProtoOutputStream; import android.util.proto.ProtoOutputStream;
@@ -25,8 +26,6 @@ import java.io.DataOutput;
import java.io.IOException; import java.io.IOException;
import java.util.HashSet; import java.util.HashSet;
import static android.net.ConnectivityManager.TYPE_MOBILE;
/** /**
* Identity of a {@code iface}, defined by the set of {@link NetworkIdentity} * Identity of a {@code iface}, defined by the set of {@link NetworkIdentity}
* active on that interface. * active on that interface.
@@ -97,6 +96,9 @@ public class NetworkIdentitySet extends HashSet<NetworkIdentity> implements
} }
} }
/**
* Method to serialize this object into a {@code DataOutput}.
*/
public void writeToStream(DataOutput out) throws IOException { public void writeToStream(DataOutput out) throws IOException {
out.writeInt(VERSION_ADD_OEM_MANAGED_NETWORK); out.writeInt(VERSION_ADD_OEM_MANAGED_NETWORK);
out.writeInt(size()); out.writeInt(size());
@@ -179,6 +181,9 @@ public class NetworkIdentitySet extends HashSet<NetworkIdentity> implements
return ident.compareTo(anotherIdent); return ident.compareTo(anotherIdent);
} }
/**
* Method to dump this object into proto debug file.
*/
public void dumpDebug(ProtoOutputStream proto, long tag) { public void dumpDebug(ProtoOutputStream proto, long tag) {
final long start = proto.start(tag); final long start = proto.start(tag);

View File

@@ -11,10 +11,10 @@
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * 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.Manifest.permission.READ_NETWORK_USAGE_HISTORY;
import static android.net.NetworkStats.UID_ALL; 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.Retention;
import java.lang.annotation.RetentionPolicy; 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 { public final class NetworkStatsAccess {
private NetworkStatsAccess() {} private NetworkStatsAccess() {}

View File

@@ -14,7 +14,7 @@
* limitations under the License. * 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_NO;
import static android.net.NetworkStats.DEFAULT_NETWORK_YES; 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 android.text.format.DateUtils.WEEK_IN_MILLIS;
import static com.android.internal.net.NetworkUtilsInternal.multiplySafeByRational; 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.os.Binder;
import android.service.NetworkStatsCollectionKeyProto; import android.service.NetworkStatsCollectionKeyProto;
import android.service.NetworkStatsCollectionProto; import android.service.NetworkStatsCollectionProto;
@@ -85,8 +79,11 @@ import java.util.Objects;
/** /**
* Collection of {@link NetworkStatsHistory}, stored based on combined key of * Collection of {@link NetworkStatsHistory}, stored based on combined key of
* {@link NetworkIdentitySet}, UID, set, and tag. Knows how to persist itself. * {@link NetworkIdentitySet}, UID, set, and tag. Knows how to persist itself.
*
* @hide
*/ */
public class NetworkStatsCollection implements FileRotator.Reader, FileRotator.Writer { public class NetworkStatsCollection implements FileRotator.Reader, FileRotator.Writer {
private static final String TAG = NetworkStatsCollection.class.getSimpleName();
/** File header magic number: "ANET" */ /** File header magic number: "ANET" */
private static final int FILE_MAGIC = 0x414E4554; private static final int FILE_MAGIC = 0x414E4554;
@@ -366,8 +363,8 @@ public class NetworkStatsCollection implements FileRotator.Reader, FileRotator.W
entry.uid = key.uid; entry.uid = key.uid;
entry.set = key.set; entry.set = key.set;
entry.tag = key.tag; entry.tag = key.tag;
entry.defaultNetwork = key.ident.areAllMembersOnDefaultNetwork() ? entry.defaultNetwork = key.ident.areAllMembersOnDefaultNetwork()
DEFAULT_NETWORK_YES : DEFAULT_NETWORK_NO; ? DEFAULT_NETWORK_YES : DEFAULT_NETWORK_NO;
entry.metered = key.ident.isAnyMemberMetered() ? METERED_YES : METERED_NO; entry.metered = key.ident.isAnyMemberMetered() ? METERED_YES : METERED_NO;
entry.roaming = key.ident.isAnyMemberRoaming() ? ROAMING_YES : ROAMING_NO; entry.roaming = key.ident.isAnyMemberRoaming() ? ROAMING_YES : ROAMING_NO;
entry.rxBytes = historyEntry.rxBytes; 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 @Deprecated
public void readLegacyNetwork(File file) throws IOException { public void readLegacyNetwork(File file) throws IOException {
final AtomicFile inputFile = new AtomicFile(file); 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 @Deprecated
public void readLegacyUid(File file, boolean onlyTags) throws IOException { public void readLegacyUid(File file, boolean onlyTags) throws IOException {
final AtomicFile inputFile = new AtomicFile(file); 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 set;
public final int tag; 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.ident = ident;
this.uid = uid; this.uid = uid;
this.set = set; this.set = set;
this.tag = tag; this.tag = tag;
hashCode = Objects.hash(ident, uid, set, tag); mHashCode = Objects.hash(ident, uid, set, tag);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return hashCode; return mHashCode;
} }
@Override @Override

View File

@@ -19,13 +19,45 @@ package {
default_applicable_licenses: ["Android-Apache-2.0"], default_applicable_licenses: ["Android-Apache-2.0"],
} }
// NetworkStats related libraries.
filegroup {
name: "services.connectivity-netstats-sources",
srcs: [
"src/com/android/server/net/NetworkIdentity*.java",
"src/com/android/server/net/NetworkStats*.java",
],
path: "src",
visibility: [
"//visibility:private",
],
}
// Nsd related libraries.
filegroup { filegroup {
name: "services.connectivity-nsd-sources", name: "services.connectivity-nsd-sources",
srcs: [ srcs: [
"src/**/*.java", "src/com/android/server/INativeDaemon*.java",
"src/com/android/server/NativeDaemon*.java",
"src/com/android/server/Nsd*.java",
],
path: "src",
visibility: [
"//visibility:private",
],
}
// Connectivity-T common libraries.
filegroup {
name: "services.connectivity-tiramisu-sources",
srcs: [
":services.connectivity-netstats-sources",
":services.connectivity-nsd-sources",
], ],
path: "src", path: "src",
visibility: [ visibility: [
"//frameworks/base/services/core", "//frameworks/base/services/core",
], ],
} }

View File

@@ -22,7 +22,10 @@ import static com.android.internal.util.Preconditions.checkArgument;
import android.app.usage.NetworkStatsManager; import android.app.usage.NetworkStatsManager;
import android.net.DataUsageRequest; import android.net.DataUsageRequest;
import android.net.NetworkIdentitySet;
import android.net.NetworkStats; import android.net.NetworkStats;
import android.net.NetworkStatsAccess;
import android.net.NetworkStatsCollection;
import android.net.NetworkStatsHistory; import android.net.NetworkStatsHistory;
import android.net.NetworkTemplate; import android.net.NetworkTemplate;
import android.os.Bundle; import android.os.Bundle;

View File

@@ -21,8 +21,11 @@ import static android.net.TrafficStats.KB_IN_BYTES;
import static android.net.TrafficStats.MB_IN_BYTES; import static android.net.TrafficStats.MB_IN_BYTES;
import static android.text.format.DateUtils.YEAR_IN_MILLIS; import static android.text.format.DateUtils.YEAR_IN_MILLIS;
import android.net.NetworkIdentitySet;
import android.net.NetworkStats; import android.net.NetworkStats;
import android.net.NetworkStats.NonMonotonicObserver; import android.net.NetworkStats.NonMonotonicObserver;
import android.net.NetworkStatsAccess;
import android.net.NetworkStatsCollection;
import android.net.NetworkStatsHistory; import android.net.NetworkStatsHistory;
import android.net.NetworkTemplate; import android.net.NetworkTemplate;
import android.net.TrafficStats; import android.net.TrafficStats;

View File

@@ -96,11 +96,14 @@ import android.net.INetworkStatsSession;
import android.net.Network; import android.net.Network;
import android.net.NetworkCapabilities; import android.net.NetworkCapabilities;
import android.net.NetworkIdentity; import android.net.NetworkIdentity;
import android.net.NetworkIdentitySet;
import android.net.NetworkSpecifier; import android.net.NetworkSpecifier;
import android.net.NetworkStack; import android.net.NetworkStack;
import android.net.NetworkStateSnapshot; import android.net.NetworkStateSnapshot;
import android.net.NetworkStats; import android.net.NetworkStats;
import android.net.NetworkStats.NonMonotonicObserver; import android.net.NetworkStats.NonMonotonicObserver;
import android.net.NetworkStatsAccess;
import android.net.NetworkStatsCollection;
import android.net.NetworkStatsHistory; import android.net.NetworkStatsHistory;
import android.net.NetworkTemplate; import android.net.NetworkTemplate;
import android.net.TelephonyNetworkSpecifier; import android.net.TelephonyNetworkSpecifier;