Merge "Broadcast ACTION_NETWORK_STATS_UPDATED in NetworkStatsHandler" am: 61fbce1bde
Change-Id: I8996b46bbd71ddc27ef313e3d9d329faf56ac580
This commit is contained in:
@@ -178,6 +178,9 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||||||
// Perform polling, persist network, and register the global alert again.
|
// Perform polling, persist network, and register the global alert again.
|
||||||
private static final int MSG_PERFORM_POLL_REGISTER_ALERT = 2;
|
private static final int MSG_PERFORM_POLL_REGISTER_ALERT = 2;
|
||||||
private static final int MSG_UPDATE_IFACES = 3;
|
private static final int MSG_UPDATE_IFACES = 3;
|
||||||
|
// A message for broadcasting ACTION_NETWORK_STATS_UPDATED in handler thread to prevent
|
||||||
|
// deadlock.
|
||||||
|
private static final int MSG_BROADCAST_NETWORK_STATS_UPDATED = 4;
|
||||||
|
|
||||||
/** Flags to control detail level of poll event. */
|
/** Flags to control detail level of poll event. */
|
||||||
private static final int FLAG_PERSIST_NETWORK = 0x1;
|
private static final int FLAG_PERSIST_NETWORK = 0x1;
|
||||||
@@ -386,6 +389,13 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||||||
registerGlobalAlert();
|
registerGlobalAlert();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case MSG_BROADCAST_NETWORK_STATS_UPDATED: {
|
||||||
|
final Intent updatedIntent = new Intent(ACTION_NETWORK_STATS_UPDATED);
|
||||||
|
updatedIntent.setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
|
||||||
|
mContext.sendBroadcastAsUser(updatedIntent, UserHandle.ALL,
|
||||||
|
READ_NETWORK_USAGE_HISTORY);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1508,10 +1518,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// finally, dispatch updated event to any listeners
|
// finally, dispatch updated event to any listeners
|
||||||
final Intent updatedIntent = new Intent(ACTION_NETWORK_STATS_UPDATED);
|
mHandler.sendMessage(mHandler.obtainMessage(MSG_BROADCAST_NETWORK_STATS_UPDATED));
|
||||||
updatedIntent.setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
|
|
||||||
mContext.sendBroadcastAsUser(updatedIntent, UserHandle.ALL,
|
|
||||||
READ_NETWORK_USAGE_HISTORY);
|
|
||||||
|
|
||||||
Trace.traceEnd(TRACE_TAG_NETWORK);
|
Trace.traceEnd(TRACE_TAG_NETWORK);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user