@@ -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