diff options
| author | Jeff Sharkey <jsharkey@android.com> | 2012-05-02 18:11:52 -0700 |
|---|---|---|
| committer | Jeff Sharkey <jsharkey@android.com> | 2012-05-03 12:12:10 -0700 |
| commit | ac3fcb1590e1da21324c13ce237ec48f2bf488bf (patch) | |
| tree | 696d28037cf8b7f078287a256f0eed8323923a10 /services/java/com/android/server/net/NetworkPolicyManagerService.java | |
| parent | e8914c36276710de50b347c1e6aecfa45d6a56cd (diff) | |
| download | frameworks_base-ac3fcb1590e1da21324c13ce237ec48f2bf488bf.zip frameworks_base-ac3fcb1590e1da21324c13ce237ec48f2bf488bf.tar.gz frameworks_base-ac3fcb1590e1da21324c13ce237ec48f2bf488bf.tar.bz2 | |
Reduce persist threshold for lower warning/limit.
Default is 2MB persist threshold, but even that can be substantial
for devices on 100MB/month plans. This change gradually reduces the
persist threshold up to 8x lower (256kb outstanding) based on lowest
active policy.
Bug: 5382676
Change-Id: Ief4e8cdb169bfb151a3d1b45722a8eaa01926508
Diffstat (limited to 'services/java/com/android/server/net/NetworkPolicyManagerService.java')
| -rw-r--r-- | services/java/com/android/server/net/NetworkPolicyManagerService.java | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/services/java/com/android/server/net/NetworkPolicyManagerService.java b/services/java/com/android/server/net/NetworkPolicyManagerService.java index 8ebe224..961d042 100644 --- a/services/java/com/android/server/net/NetworkPolicyManagerService.java +++ b/services/java/com/android/server/net/NetworkPolicyManagerService.java @@ -118,6 +118,7 @@ import android.telephony.TelephonyManager; import android.text.format.Formatter; import android.text.format.Time; import android.util.Log; +import android.util.MathUtils; import android.util.NtpTrustedTime; import android.util.Slog; import android.util.SparseArray; @@ -166,7 +167,7 @@ import libcore.io.IoUtils; */ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { private static final String TAG = "NetworkPolicy"; - private static final boolean LOGD = true; + private static final boolean LOGD = false; private static final boolean LOGV = false; private static final int VERSION_INIT = 1; @@ -962,6 +963,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { } } + long lowestRule = Long.MAX_VALUE; final HashSet<String> newMeteredIfaces = Sets.newHashSet(); // apply each policy that we found ifaces for; compute remaining data @@ -985,6 +987,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { + Arrays.toString(ifaces)); } + final boolean hasWarning = policy.warningBytes != LIMIT_DISABLED; final boolean hasLimit = policy.limitBytes != LIMIT_DISABLED; if (hasLimit || policy.metered) { final long quotaBytes; @@ -1014,6 +1017,23 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { newMeteredIfaces.add(iface); } } + + // keep track of lowest warning or limit of active policies + if (hasWarning && policy.warningBytes < lowestRule) { + lowestRule = policy.warningBytes; + } + if (hasLimit && policy.limitBytes < lowestRule) { + lowestRule = policy.limitBytes; + } + } + + try { + // make sure stats are recorded frequently enough; we aim for 2MB + // threshold for 2GB/month rules. + final long persistThreshold = lowestRule / 1000; + mNetworkStats.advisePersistThreshold(persistThreshold); + } catch (RemoteException e) { + // ignored; service lives in system_server } // remove quota on any trailing interfaces |
