Skip to content

Commit 2048789

Browse files
jsharkeyAndroid (Google) Code Review
authored andcommitted
Merge "Dispatch alerts through background thread." into ics-mr1
2 parents f388291 + 7e25b0e commit 2048789

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

services/java/com/android/server/net/NetworkPolicyManagerService.java

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
190190
private static final int MSG_METERED_IFACES_CHANGED = 2;
191191
private static final int MSG_FOREGROUND_ACTIVITIES_CHANGED = 3;
192192
private static final int MSG_PROCESS_DIED = 4;
193+
private static final int MSG_LIMIT_REACHED = 5;
193194

194195
private final Context mContext;
195196
private final IActivityManager mActivityManager;
@@ -422,19 +423,8 @@ public void limitReached(String limitName, String iface) {
422423
// only someone like NMS should be calling us
423424
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
424425

425-
synchronized (mRulesLock) {
426-
if (mMeteredIfaces.contains(iface) && !LIMIT_GLOBAL_ALERT.equals(limitName)) {
427-
try {
428-
// force stats update to make sure we have numbers that
429-
// caused alert to trigger.
430-
mNetworkStats.forceUpdate();
431-
} catch (RemoteException e) {
432-
// ignored; service lives in system_server
433-
}
434-
435-
updateNetworkEnabledLocked();
436-
updateNotificationsLocked();
437-
}
426+
if (!LIMIT_GLOBAL_ALERT.equals(limitName)) {
427+
mHandler.obtainMessage(MSG_LIMIT_REACHED, iface).sendToTarget();
438428
}
439429
}
440430
};
@@ -1479,6 +1469,25 @@ public boolean handleMessage(Message msg) {
14791469
}
14801470
return true;
14811471
}
1472+
case MSG_LIMIT_REACHED: {
1473+
final String iface = (String) msg.obj;
1474+
1475+
synchronized (mRulesLock) {
1476+
if (mMeteredIfaces.contains(iface)) {
1477+
try {
1478+
// force stats update to make sure we have
1479+
// numbers that caused alert to trigger.
1480+
mNetworkStats.forceUpdate();
1481+
} catch (RemoteException e) {
1482+
// ignored; service lives in system_server
1483+
}
1484+
1485+
updateNetworkEnabledLocked();
1486+
updateNotificationsLocked();
1487+
}
1488+
}
1489+
return true;
1490+
}
14821491
default: {
14831492
return false;
14841493
}

0 commit comments

Comments
 (0)