Search in sources :

Example 1 with NetworkQuotaInfo

use of android.net.NetworkQuotaInfo in project platform_frameworks_base by android.

the class NetworkPolicyManagerService method getNetworkQuotaInfoUnchecked.

private NetworkQuotaInfo getNetworkQuotaInfoUnchecked(NetworkState state) {
    final NetworkIdentity ident = NetworkIdentity.buildNetworkIdentity(mContext, state);
    final NetworkPolicy policy;
    synchronized (mNetworkPoliciesSecondLock) {
        policy = findPolicyForNetworkNL(ident);
    }
    if (policy == null || !policy.hasCycle()) {
        // missing policy means we can't derive useful quota info
        return null;
    }
    final long currentTime = currentTimeMillis();
    // find total bytes used under policy
    final long start = computeLastCycleBoundary(currentTime, policy);
    final long end = currentTime;
    final long totalBytes = getTotalBytes(policy.template, start, end);
    // report soft and hard limits under policy
    final long softLimitBytes = policy.warningBytes != WARNING_DISABLED ? policy.warningBytes : NetworkQuotaInfo.NO_LIMIT;
    final long hardLimitBytes = policy.limitBytes != LIMIT_DISABLED ? policy.limitBytes : NetworkQuotaInfo.NO_LIMIT;
    return new NetworkQuotaInfo(totalBytes, softLimitBytes, hardLimitBytes);
}
Also used : NetworkQuotaInfo(android.net.NetworkQuotaInfo) NetworkIdentity(android.net.NetworkIdentity) NetworkPolicy(android.net.NetworkPolicy)

Example 2 with NetworkQuotaInfo

use of android.net.NetworkQuotaInfo in project android_frameworks_base by AOSPA.

the class NetworkPolicyManagerService method getNetworkQuotaInfoUnchecked.

private NetworkQuotaInfo getNetworkQuotaInfoUnchecked(NetworkState state) {
    final NetworkIdentity ident = NetworkIdentity.buildNetworkIdentity(mContext, state);
    final NetworkPolicy policy;
    synchronized (mNetworkPoliciesSecondLock) {
        policy = findPolicyForNetworkNL(ident);
    }
    if (policy == null || !policy.hasCycle()) {
        // missing policy means we can't derive useful quota info
        return null;
    }
    final long currentTime = currentTimeMillis();
    // find total bytes used under policy
    final long start = computeLastCycleBoundary(currentTime, policy);
    final long end = currentTime;
    final long totalBytes = getTotalBytes(policy.template, start, end);
    // report soft and hard limits under policy
    final long softLimitBytes = policy.warningBytes != WARNING_DISABLED ? policy.warningBytes : NetworkQuotaInfo.NO_LIMIT;
    final long hardLimitBytes = policy.limitBytes != LIMIT_DISABLED ? policy.limitBytes : NetworkQuotaInfo.NO_LIMIT;
    return new NetworkQuotaInfo(totalBytes, softLimitBytes, hardLimitBytes);
}
Also used : NetworkQuotaInfo(android.net.NetworkQuotaInfo) NetworkIdentity(android.net.NetworkIdentity) NetworkPolicy(android.net.NetworkPolicy)

Example 3 with NetworkQuotaInfo

use of android.net.NetworkQuotaInfo in project android_frameworks_base by ResurrectionRemix.

the class NetworkPolicyManagerService method getNetworkQuotaInfoUnchecked.

private NetworkQuotaInfo getNetworkQuotaInfoUnchecked(NetworkState state) {
    final NetworkIdentity ident = NetworkIdentity.buildNetworkIdentity(mContext, state);
    final NetworkPolicy policy;
    synchronized (mNetworkPoliciesSecondLock) {
        policy = findPolicyForNetworkNL(ident);
    }
    if (policy == null || !policy.hasCycle()) {
        // missing policy means we can't derive useful quota info
        return null;
    }
    final long currentTime = currentTimeMillis();
    // find total bytes used under policy
    final long start = computeLastCycleBoundary(currentTime, policy);
    final long end = currentTime;
    final long totalBytes = getTotalBytes(policy.template, start, end);
    // report soft and hard limits under policy
    final long softLimitBytes = policy.warningBytes != WARNING_DISABLED ? policy.warningBytes : NetworkQuotaInfo.NO_LIMIT;
    final long hardLimitBytes = policy.limitBytes != LIMIT_DISABLED ? policy.limitBytes : NetworkQuotaInfo.NO_LIMIT;
    return new NetworkQuotaInfo(totalBytes, softLimitBytes, hardLimitBytes);
}
Also used : NetworkQuotaInfo(android.net.NetworkQuotaInfo) NetworkIdentity(android.net.NetworkIdentity) NetworkPolicy(android.net.NetworkPolicy)

Example 4 with NetworkQuotaInfo

use of android.net.NetworkQuotaInfo in project android_frameworks_base by crdroidandroid.

the class NetworkPolicyManagerService method getNetworkQuotaInfoUnchecked.

private NetworkQuotaInfo getNetworkQuotaInfoUnchecked(NetworkState state) {
    final NetworkIdentity ident = NetworkIdentity.buildNetworkIdentity(mContext, state);
    final NetworkPolicy policy;
    synchronized (mNetworkPoliciesSecondLock) {
        policy = findPolicyForNetworkNL(ident);
    }
    if (policy == null || !policy.hasCycle()) {
        // missing policy means we can't derive useful quota info
        return null;
    }
    final long currentTime = currentTimeMillis();
    // find total bytes used under policy
    final long start = computeLastCycleBoundary(currentTime, policy);
    final long end = currentTime;
    final long totalBytes = getTotalBytes(policy.template, start, end);
    // report soft and hard limits under policy
    final long softLimitBytes = policy.warningBytes != WARNING_DISABLED ? policy.warningBytes : NetworkQuotaInfo.NO_LIMIT;
    final long hardLimitBytes = policy.limitBytes != LIMIT_DISABLED ? policy.limitBytes : NetworkQuotaInfo.NO_LIMIT;
    return new NetworkQuotaInfo(totalBytes, softLimitBytes, hardLimitBytes);
}
Also used : NetworkQuotaInfo(android.net.NetworkQuotaInfo) NetworkIdentity(android.net.NetworkIdentity) NetworkPolicy(android.net.NetworkPolicy)

Example 5 with NetworkQuotaInfo

use of android.net.NetworkQuotaInfo in project android_frameworks_base by ParanoidAndroid.

the class NetworkPolicyManagerService method getNetworkQuotaInfoUnchecked.

private NetworkQuotaInfo getNetworkQuotaInfoUnchecked(NetworkState state) {
    final NetworkIdentity ident = NetworkIdentity.buildNetworkIdentity(mContext, state);
    final NetworkPolicy policy;
    synchronized (mRulesLock) {
        policy = findPolicyForNetworkLocked(ident);
    }
    if (policy == null || !policy.hasCycle()) {
        // missing policy means we can't derive useful quota info
        return null;
    }
    final long currentTime = currentTimeMillis();
    // find total bytes used under policy
    final long start = computeLastCycleBoundary(currentTime, policy);
    final long end = currentTime;
    final long totalBytes = getTotalBytes(policy.template, start, end);
    // report soft and hard limits under policy
    final long softLimitBytes = policy.warningBytes != WARNING_DISABLED ? policy.warningBytes : NetworkQuotaInfo.NO_LIMIT;
    final long hardLimitBytes = policy.limitBytes != LIMIT_DISABLED ? policy.limitBytes : NetworkQuotaInfo.NO_LIMIT;
    return new NetworkQuotaInfo(totalBytes, softLimitBytes, hardLimitBytes);
}
Also used : NetworkQuotaInfo(android.net.NetworkQuotaInfo) NetworkIdentity(android.net.NetworkIdentity) NetworkPolicy(android.net.NetworkPolicy)

Aggregations

NetworkIdentity (android.net.NetworkIdentity)6 NetworkPolicy (android.net.NetworkPolicy)6 NetworkQuotaInfo (android.net.NetworkQuotaInfo)6