Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)

Bug: 166295507
Merged-In: I3d92a6de21a938f6b352ec26dc23420c0fe02b27
Change-Id: Ifdb80563ef042738778ebb8a7581a97c4e3d96e2
This commit is contained in:
Xin Li
2020-08-31 21:21:38 -07:00
8 changed files with 83 additions and 69 deletions

View File

@@ -41,6 +41,7 @@ import android.os.Messenger;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ServiceManager.ServiceNotFoundException;
import android.telephony.TelephonyManager;
import android.util.DataUnit;
import android.util.Log;
@@ -198,6 +199,12 @@ public class NetworkStatsManager {
* {@link ConnectivityManager#TYPE_MOBILE}, {@link ConnectivityManager#TYPE_WIFI}
* etc.
* @param subscriberId If applicable, the subscriber id of the network interface.
* <p>Starting with API level 29, the {@code subscriberId} is guarded by
* additional restrictions. Calling apps that do not meet the new
* requirements to access the {@code subscriberId} can provide a {@code
* null} value when querying for the mobile network type to receive usage
* for all mobile networks. For additional details see {@link
* TelephonyManager#getSubscriberId()}.
* @param startTime Start of period. Defined in terms of "Unix time", see
* {@link java.lang.System#currentTimeMillis}.
* @param endTime End of period. Defined in terms of "Unix time", see
@@ -231,6 +238,12 @@ public class NetworkStatsManager {
* {@link ConnectivityManager#TYPE_MOBILE}, {@link ConnectivityManager#TYPE_WIFI}
* etc.
* @param subscriberId If applicable, the subscriber id of the network interface.
* <p>Starting with API level 29, the {@code subscriberId} is guarded by
* additional restrictions. Calling apps that do not meet the new
* requirements to access the {@code subscriberId} can provide a {@code
* null} value when querying for the mobile network type to receive usage
* for all mobile networks. For additional details see {@link
* TelephonyManager#getSubscriberId()}.
* @param startTime Start of period. Defined in terms of "Unix time", see
* {@link java.lang.System#currentTimeMillis}.
* @param endTime End of period. Defined in terms of "Unix time", see
@@ -268,6 +281,12 @@ public class NetworkStatsManager {
* {@link ConnectivityManager#TYPE_MOBILE}, {@link ConnectivityManager#TYPE_WIFI}
* etc.
* @param subscriberId If applicable, the subscriber id of the network interface.
* <p>Starting with API level 29, the {@code subscriberId} is guarded by
* additional restrictions. Calling apps that do not meet the new
* requirements to access the {@code subscriberId} can provide a {@code
* null} value when querying for the mobile network type to receive usage
* for all mobile networks. For additional details see {@link
* TelephonyManager#getSubscriberId()}.
* @param startTime Start of period. Defined in terms of "Unix time", see
* {@link java.lang.System#currentTimeMillis}.
* @param endTime End of period. Defined in terms of "Unix time", see
@@ -301,7 +320,7 @@ public class NetworkStatsManager {
/**
* Query network usage statistics details for a given uid.
*
* #see queryDetailsForUidTagState(int, String, long, long, int, int, int)
* @see #queryDetailsForUidTagState(int, String, long, long, int, int, int)
*/
public NetworkStats queryDetailsForUid(int networkType, String subscriberId,
long startTime, long endTime, int uid) throws SecurityException {
@@ -319,7 +338,7 @@ public class NetworkStatsManager {
/**
* Query network usage statistics details for a given uid and tag.
*
* #see queryDetailsForUidTagState(int, String, long, long, int, int, int)
* @see #queryDetailsForUidTagState(int, String, long, long, int, int, int)
*/
public NetworkStats queryDetailsForUidTag(int networkType, String subscriberId,
long startTime, long endTime, int uid, int tag) throws SecurityException {
@@ -344,6 +363,12 @@ public class NetworkStatsManager {
* {@link ConnectivityManager#TYPE_MOBILE}, {@link ConnectivityManager#TYPE_WIFI}
* etc.
* @param subscriberId If applicable, the subscriber id of the network interface.
* <p>Starting with API level 29, the {@code subscriberId} is guarded by
* additional restrictions. Calling apps that do not meet the new
* requirements to access the {@code subscriberId} can provide a {@code
* null} value when querying for the mobile network type to receive usage
* for all mobile networks. For additional details see {@link
* TelephonyManager#getSubscriberId()}.
* @param startTime Start of period. Defined in terms of "Unix time", see
* {@link java.lang.System#currentTimeMillis}.
* @param endTime End of period. Defined in terms of "Unix time", see
@@ -398,6 +423,12 @@ public class NetworkStatsManager {
* {@link ConnectivityManager#TYPE_MOBILE}, {@link ConnectivityManager#TYPE_WIFI}
* etc.
* @param subscriberId If applicable, the subscriber id of the network interface.
* <p>Starting with API level 29, the {@code subscriberId} is guarded by
* additional restrictions. Calling apps that do not meet the new
* requirements to access the {@code subscriberId} can provide a {@code
* null} value when querying for the mobile network type to receive usage
* for all mobile networks. For additional details see {@link
* TelephonyManager#getSubscriberId()}.
* @param startTime Start of period. Defined in terms of "Unix time", see
* {@link java.lang.System#currentTimeMillis}.
* @param endTime End of period. Defined in terms of "Unix time", see
@@ -455,7 +486,7 @@ public class NetworkStatsManager {
/**
* Registers to receive notifications about data usage on specified networks.
*
* #see registerUsageCallback(int, String[], long, UsageCallback, Handler)
* @see #registerUsageCallback(int, String, long, UsageCallback, Handler)
*/
public void registerUsageCallback(int networkType, String subscriberId, long thresholdBytes,
UsageCallback callback) {
@@ -472,6 +503,12 @@ public class NetworkStatsManager {
* @param networkType Type of network to monitor. Either
{@link ConnectivityManager#TYPE_MOBILE} or {@link ConnectivityManager#TYPE_WIFI}.
* @param subscriberId If applicable, the subscriber id of the network interface.
* <p>Starting with API level 29, the {@code subscriberId} is guarded by
* additional restrictions. Calling apps that do not meet the new
* requirements to access the {@code subscriberId} can provide a {@code
* null} value when registering for the mobile network type to receive
* notifications for all mobile networks. For additional details see {@link
* TelephonyManager#getSubscriberId()}.
* @param thresholdBytes Threshold in bytes to be notified on.
* @param callback The {@link UsageCallback} that the system will call when data usage
* has exceeded the specified threshold.

View File

@@ -105,7 +105,7 @@ public class NetworkIdentity implements Comparable<NetworkIdentity> {
return builder.append("}").toString();
}
public void writeToProto(ProtoOutputStream proto, long tag) {
public void dumpDebug(ProtoOutputStream proto, long tag) {
final long start = proto.start(tag);
proto.write(NetworkIdentityProto.TYPE, mType);

View File

@@ -698,7 +698,7 @@ public class NetworkStatsHistory implements Parcelable {
}
}
public void writeToProto(ProtoOutputStream proto, long tag) {
public void dumpDebug(ProtoOutputStream proto, long tag) {
final long start = proto.start(tag);
proto.write(NetworkStatsHistoryProto.BUCKET_DURATION_MS, bucketDuration);
@@ -707,11 +707,11 @@ public class NetworkStatsHistory implements Parcelable {
final long startBucket = proto.start(NetworkStatsHistoryProto.BUCKETS);
proto.write(NetworkStatsHistoryBucketProto.BUCKET_START_MS, bucketStart[i]);
writeToProto(proto, NetworkStatsHistoryBucketProto.RX_BYTES, rxBytes, i);
writeToProto(proto, NetworkStatsHistoryBucketProto.RX_PACKETS, rxPackets, i);
writeToProto(proto, NetworkStatsHistoryBucketProto.TX_BYTES, txBytes, i);
writeToProto(proto, NetworkStatsHistoryBucketProto.TX_PACKETS, txPackets, i);
writeToProto(proto, NetworkStatsHistoryBucketProto.OPERATIONS, operations, i);
dumpDebug(proto, NetworkStatsHistoryBucketProto.RX_BYTES, rxBytes, i);
dumpDebug(proto, NetworkStatsHistoryBucketProto.RX_PACKETS, rxPackets, i);
dumpDebug(proto, NetworkStatsHistoryBucketProto.TX_BYTES, txBytes, i);
dumpDebug(proto, NetworkStatsHistoryBucketProto.TX_PACKETS, txPackets, i);
dumpDebug(proto, NetworkStatsHistoryBucketProto.OPERATIONS, operations, i);
proto.end(startBucket);
}
@@ -719,7 +719,7 @@ public class NetworkStatsHistory implements Parcelable {
proto.end(start);
}
private static void writeToProto(ProtoOutputStream proto, long tag, long[] array, int index) {
private static void dumpDebug(ProtoOutputStream proto, long tag, long[] array, int index) {
if (array != null) {
proto.write(tag, array[index]);
}

View File

@@ -775,17 +775,10 @@ public class TrafficStats {
* @see android.content.pm.ApplicationInfo#uid
*/
public static long getUidTxBytes(int uid) {
// This isn't actually enforcing any security; it just returns the
// unsupported value. The real filtering is done at the kernel level.
final int callingUid = android.os.Process.myUid();
if (callingUid == android.os.Process.SYSTEM_UID || callingUid == uid) {
try {
return getStatsService().getUidStats(uid, TYPE_TX_BYTES);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
} else {
return UNSUPPORTED;
try {
return getStatsService().getUidStats(uid, TYPE_TX_BYTES);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
@@ -808,17 +801,10 @@ public class TrafficStats {
* @see android.content.pm.ApplicationInfo#uid
*/
public static long getUidRxBytes(int uid) {
// This isn't actually enforcing any security; it just returns the
// unsupported value. The real filtering is done at the kernel level.
final int callingUid = android.os.Process.myUid();
if (callingUid == android.os.Process.SYSTEM_UID || callingUid == uid) {
try {
return getStatsService().getUidStats(uid, TYPE_RX_BYTES);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
} else {
return UNSUPPORTED;
try {
return getStatsService().getUidStats(uid, TYPE_RX_BYTES);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
@@ -841,17 +827,10 @@ public class TrafficStats {
* @see android.content.pm.ApplicationInfo#uid
*/
public static long getUidTxPackets(int uid) {
// This isn't actually enforcing any security; it just returns the
// unsupported value. The real filtering is done at the kernel level.
final int callingUid = android.os.Process.myUid();
if (callingUid == android.os.Process.SYSTEM_UID || callingUid == uid) {
try {
return getStatsService().getUidStats(uid, TYPE_TX_PACKETS);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
} else {
return UNSUPPORTED;
try {
return getStatsService().getUidStats(uid, TYPE_TX_PACKETS);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
@@ -874,17 +853,10 @@ public class TrafficStats {
* @see android.content.pm.ApplicationInfo#uid
*/
public static long getUidRxPackets(int uid) {
// This isn't actually enforcing any security; it just returns the
// unsupported value. The real filtering is done at the kernel level.
final int callingUid = android.os.Process.myUid();
if (callingUid == android.os.Process.SYSTEM_UID || callingUid == uid) {
try {
return getStatsService().getUidStats(uid, TYPE_RX_PACKETS);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
} else {
return UNSUPPORTED;
try {
return getStatsService().getUidStats(uid, TYPE_RX_PACKETS);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}