summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2011-11-08 15:43:12 -0800
committerJeff Sharkey <jsharkey@android.com>2011-11-08 17:41:26 -0800
commit7e25b0ea8891ffc0ac472d61f21610a9ac4e270a (patch)
treee004ec8419f400ff88a9b57c25bf6bc83e77ad3a /services
parent3f3115b27733a822104385284b1ec1f39d91f839 (diff)
downloadframeworks_base-7e25b0ea8891ffc0ac472d61f21610a9ac4e270a.zip
frameworks_base-7e25b0ea8891ffc0ac472d61f21610a9ac4e270a.tar.gz
frameworks_base-7e25b0ea8891ffc0ac472d61f21610a9ac4e270a.tar.bz2
Dispatch alerts through background thread.
Bug: 5557659 Change-Id: Icc3ad476a98ec3430b33f915723ffcc36ccbfae7
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/net/NetworkPolicyManagerService.java35
1 files changed, 22 insertions, 13 deletions
diff --git a/services/java/com/android/server/net/NetworkPolicyManagerService.java b/services/java/com/android/server/net/NetworkPolicyManagerService.java
index 676bbc8..2a1b1db 100644
--- a/services/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -190,6 +190,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
private static final int MSG_METERED_IFACES_CHANGED = 2;
private static final int MSG_FOREGROUND_ACTIVITIES_CHANGED = 3;
private static final int MSG_PROCESS_DIED = 4;
+ private static final int MSG_LIMIT_REACHED = 5;
private final Context mContext;
private final IActivityManager mActivityManager;
@@ -422,19 +423,8 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
// only someone like NMS should be calling us
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
- synchronized (mRulesLock) {
- if (mMeteredIfaces.contains(iface) && !LIMIT_GLOBAL_ALERT.equals(limitName)) {
- try {
- // force stats update to make sure we have numbers that
- // caused alert to trigger.
- mNetworkStats.forceUpdate();
- } catch (RemoteException e) {
- // ignored; service lives in system_server
- }
-
- updateNetworkEnabledLocked();
- updateNotificationsLocked();
- }
+ if (!LIMIT_GLOBAL_ALERT.equals(limitName)) {
+ mHandler.obtainMessage(MSG_LIMIT_REACHED, iface).sendToTarget();
}
}
};
@@ -1479,6 +1469,25 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
}
return true;
}
+ case MSG_LIMIT_REACHED: {
+ final String iface = (String) msg.obj;
+
+ synchronized (mRulesLock) {
+ if (mMeteredIfaces.contains(iface)) {
+ try {
+ // force stats update to make sure we have
+ // numbers that caused alert to trigger.
+ mNetworkStats.forceUpdate();
+ } catch (RemoteException e) {
+ // ignored; service lives in system_server
+ }
+
+ updateNetworkEnabledLocked();
+ updateNotificationsLocked();
+ }
+ }
+ return true;
+ }
default: {
return false;
}