Add a lock to protect persistent stats snapshot

Since the network stats could be polled from multiple services at
runtime, it is not thread safe for networkStatsFactory to hold a
persistent stats snapshot without any protection. Use a internal lock to
prevent concurrent modification on mPersistentSnapshot to fix the
problem.

Bug: 124764595
Test: android.app.usage.cts.NetworkUsageStatsTest
      android.net.cts.TrafficStatsTest

Change-Id: I73851336452110afb74d6dd1ca5e50047d5b3d4a
Merged-In: I73851336452110afb74d6dd1ca5e50047d5b3d4a
Merged-In: I22afb46f17697e8b6359d4f593802e0f4b95db8b
(cherry picked from commit 25243b4eb93c234412a35f9e5d9f1649f8964f83)
1 file changed