Snap for 6206568 from 4e21e319cdf514b6c5a4f5a02eadd5ccd9445772 to rvc-release
Change-Id: Ic8d59142f4f9ee94cc49efc47c304087715dbc9a
This commit is contained in:
@@ -51,7 +51,7 @@ import java.net.Socket;
|
|||||||
*
|
*
|
||||||
* <p>Note that not all aspects of IPsec are permitted by this API. Applications may create
|
* <p>Note that not all aspects of IPsec are permitted by this API. Applications may create
|
||||||
* transport mode security associations and apply them to individual sockets. Applications looking
|
* transport mode security associations and apply them to individual sockets. Applications looking
|
||||||
* to create a VPN should use {@link VpnService}.
|
* to create an IPsec VPN should use {@link VpnManager} and {@link Ikev2VpnProfile}.
|
||||||
*
|
*
|
||||||
* @see <a href="https://tools.ietf.org/html/rfc4301">RFC 4301, Security Architecture for the
|
* @see <a href="https://tools.ietf.org/html/rfc4301">RFC 4301, Security Architecture for the
|
||||||
* Internet Protocol</a>
|
* Internet Protocol</a>
|
||||||
|
|||||||
@@ -548,32 +548,32 @@ public class NetworkStatsHistory implements Parcelable {
|
|||||||
final int startIndex = getIndexAfter(end);
|
final int startIndex = getIndexAfter(end);
|
||||||
for (int i = startIndex; i >= 0; i--) {
|
for (int i = startIndex; i >= 0; i--) {
|
||||||
final long curStart = bucketStart[i];
|
final long curStart = bucketStart[i];
|
||||||
final long curEnd = curStart + bucketDuration;
|
long curEnd = curStart + bucketDuration;
|
||||||
|
|
||||||
// bucket is older than request; we're finished
|
// bucket is older than request; we're finished
|
||||||
if (curEnd <= start) break;
|
if (curEnd <= start) break;
|
||||||
// bucket is newer than request; keep looking
|
// bucket is newer than request; keep looking
|
||||||
if (curStart >= end) continue;
|
if (curStart >= end) continue;
|
||||||
|
|
||||||
// include full value for active buckets, otherwise only fractional
|
// the active bucket is shorter then a normal completed bucket
|
||||||
final boolean activeBucket = curStart < now && curEnd > now;
|
if (curEnd > now) curEnd = now;
|
||||||
final long overlap;
|
// usually this is simply bucketDuration
|
||||||
if (activeBucket) {
|
final long bucketSpan = curEnd - curStart;
|
||||||
overlap = bucketDuration;
|
// prevent division by zero
|
||||||
} else {
|
if (bucketSpan <= 0) continue;
|
||||||
final long overlapEnd = curEnd < end ? curEnd : end;
|
|
||||||
final long overlapStart = curStart > start ? curStart : start;
|
final long overlapEnd = curEnd < end ? curEnd : end;
|
||||||
overlap = overlapEnd - overlapStart;
|
final long overlapStart = curStart > start ? curStart : start;
|
||||||
}
|
final long overlap = overlapEnd - overlapStart;
|
||||||
if (overlap <= 0) continue;
|
if (overlap <= 0) continue;
|
||||||
|
|
||||||
// integer math each time is faster than floating point
|
// integer math each time is faster than floating point
|
||||||
if (activeTime != null) entry.activeTime += activeTime[i] * overlap / bucketDuration;
|
if (activeTime != null) entry.activeTime += activeTime[i] * overlap / bucketSpan;
|
||||||
if (rxBytes != null) entry.rxBytes += rxBytes[i] * overlap / bucketDuration;
|
if (rxBytes != null) entry.rxBytes += rxBytes[i] * overlap / bucketSpan;
|
||||||
if (rxPackets != null) entry.rxPackets += rxPackets[i] * overlap / bucketDuration;
|
if (rxPackets != null) entry.rxPackets += rxPackets[i] * overlap / bucketSpan;
|
||||||
if (txBytes != null) entry.txBytes += txBytes[i] * overlap / bucketDuration;
|
if (txBytes != null) entry.txBytes += txBytes[i] * overlap / bucketSpan;
|
||||||
if (txPackets != null) entry.txPackets += txPackets[i] * overlap / bucketDuration;
|
if (txPackets != null) entry.txPackets += txPackets[i] * overlap / bucketSpan;
|
||||||
if (operations != null) entry.operations += operations[i] * overlap / bucketDuration;
|
if (operations != null) entry.operations += operations[i] * overlap / bucketSpan;
|
||||||
}
|
}
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1556,16 +1556,16 @@ public class IpSecService extends IIpSecService.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Objects.requireNonNull(callingPackage, "Null calling package cannot create IpSec tunnels");
|
Objects.requireNonNull(callingPackage, "Null calling package cannot create IpSec tunnels");
|
||||||
switch (getAppOpsManager().noteOp(TUNNEL_OP, Binder.getCallingUid(), callingPackage)) {
|
|
||||||
case AppOpsManager.MODE_DEFAULT:
|
// OP_MANAGE_IPSEC_TUNNELS will return MODE_ERRORED by default, including for the system
|
||||||
mContext.enforceCallingOrSelfPermission(
|
// server. If the appop is not granted, require that the caller has the MANAGE_IPSEC_TUNNELS
|
||||||
android.Manifest.permission.MANAGE_IPSEC_TUNNELS, "IpSecService");
|
// permission or is the System Server.
|
||||||
break;
|
if (AppOpsManager.MODE_ALLOWED == getAppOpsManager().noteOpNoThrow(
|
||||||
case AppOpsManager.MODE_ALLOWED:
|
TUNNEL_OP, Binder.getCallingUid(), callingPackage)) {
|
||||||
return;
|
return;
|
||||||
default:
|
|
||||||
throw new SecurityException("Request to ignore AppOps for non-legacy API");
|
|
||||||
}
|
}
|
||||||
|
mContext.enforceCallingOrSelfPermission(
|
||||||
|
android.Manifest.permission.MANAGE_IPSEC_TUNNELS, "IpSecService");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createOrUpdateTransform(
|
private void createOrUpdateTransform(
|
||||||
|
|||||||
Reference in New Issue
Block a user