|
118 | 118 | import android.text.format.Formatter; |
119 | 119 | import android.text.format.Time; |
120 | 120 | import android.util.Log; |
121 | | -import android.util.MathUtils; |
122 | 121 | import android.util.NtpTrustedTime; |
123 | 122 | import android.util.Slog; |
124 | 123 | import android.util.SparseArray; |
@@ -225,6 +224,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { |
225 | 224 | private static final int MSG_PROCESS_DIED = 4; |
226 | 225 | private static final int MSG_LIMIT_REACHED = 5; |
227 | 226 | private static final int MSG_RESTRICT_BACKGROUND_CHANGED = 6; |
| 227 | + private static final int MSG_ADVISE_PERSIST_THRESHOLD = 7; |
228 | 228 |
|
229 | 229 | private final Context mContext; |
230 | 230 | private final IActivityManager mActivityManager; |
@@ -1032,14 +1032,7 @@ private void updateNetworkRulesLocked() { |
1032 | 1032 | } |
1033 | 1033 | } |
1034 | 1034 |
|
1035 | | - try { |
1036 | | - // make sure stats are recorded frequently enough; we aim for 2MB |
1037 | | - // threshold for 2GB/month rules. |
1038 | | - final long persistThreshold = lowestRule / 1000; |
1039 | | - mNetworkStats.advisePersistThreshold(persistThreshold); |
1040 | | - } catch (RemoteException e) { |
1041 | | - // ignored; service lives in system_server |
1042 | | - } |
| 1035 | + mHandler.obtainMessage(MSG_ADVISE_PERSIST_THRESHOLD, lowestRule).sendToTarget(); |
1043 | 1036 |
|
1044 | 1037 | // remove quota on any trailing interfaces |
1045 | 1038 | for (String iface : mMeteredIfaces) { |
@@ -1861,6 +1854,19 @@ public boolean handleMessage(Message msg) { |
1861 | 1854 | } |
1862 | 1855 | } |
1863 | 1856 | mListeners.finishBroadcast(); |
| 1857 | + return true; |
| 1858 | + } |
| 1859 | + case MSG_ADVISE_PERSIST_THRESHOLD: { |
| 1860 | + final long lowestRule = (Long) msg.obj; |
| 1861 | + try { |
| 1862 | + // make sure stats are recorded frequently enough; we aim |
| 1863 | + // for 2MB threshold for 2GB/month rules. |
| 1864 | + final long persistThreshold = lowestRule / 1000; |
| 1865 | + mNetworkStats.advisePersistThreshold(persistThreshold); |
| 1866 | + } catch (RemoteException e) { |
| 1867 | + // ignored; service lives in system_server |
| 1868 | + } |
| 1869 | + return true; |
1864 | 1870 | } |
1865 | 1871 | default: { |
1866 | 1872 | return false; |
|
0 commit comments