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:
@@ -19,11 +19,58 @@ package {
|
||||
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 {
|
||||
name: "framework-connectivity-nsd-internal-sources",
|
||||
srcs: [
|
||||
"src/**/*.java",
|
||||
"src/**/*.aidl",
|
||||
"src/android/net/nsd/*.aidl",
|
||||
"src/android/net/nsd/*.java",
|
||||
],
|
||||
path: "src",
|
||||
visibility: [
|
||||
@@ -34,7 +81,7 @@ filegroup {
|
||||
filegroup {
|
||||
name: "framework-connectivity-nsd-aidl-export-sources",
|
||||
srcs: [
|
||||
"aidl-export/**/*.aidl",
|
||||
"aidl-export/android/net/nsd/*.aidl",
|
||||
],
|
||||
path: "aidl-export",
|
||||
visibility: [
|
||||
@@ -48,6 +95,19 @@ filegroup {
|
||||
":framework-connectivity-nsd-internal-sources",
|
||||
":framework-connectivity-nsd-aidl-export-sources",
|
||||
],
|
||||
visibility: [
|
||||
"//visibility:private",
|
||||
],
|
||||
}
|
||||
|
||||
// Connectivity-T common libraries.
|
||||
|
||||
filegroup {
|
||||
name: "framework-connectivity-tiramisu-sources",
|
||||
srcs: [
|
||||
":framework-connectivity-netstats-sources",
|
||||
":framework-connectivity-nsd-sources",
|
||||
],
|
||||
visibility: [
|
||||
"//frameworks/base",
|
||||
],
|
||||
|
||||
@@ -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<NetworkIdentity> 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<NetworkIdentity> 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);
|
||||
|
||||
@@ -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() {}
|
||||
|
||||
@@ -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
|
||||
@@ -19,10 +19,42 @@ package {
|
||||
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 {
|
||||
name: "services.connectivity-nsd-sources",
|
||||
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",
|
||||
visibility: [
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
Reference in New Issue
Block a user