Skip to content
Commit afcd22ac authored by zhuyunyi's avatar zhuyunyi
Browse files

Change Shallow Copy to Deep Copy in UsageStats



There are three reference type members in UsageStats's constructor, when using "new UsageStats(stats)" to copy, it will be a Shallow Copy, which may cause concurrent modify problem.

For example, in UserUsageStatsService.java, the sUsageStatsCombiner is using "new UsageStats(stats.packageStats.valueAt(i)" to copy, and the value is passing to the computeCacheQuotaHints in
CacheQuotaStrategy.java. If we change the UsageStats.mForegroundServices at the same time, IndexOutOfBounds Exception will happen.

Therefore, it is necessary to modify the way of copying of the UsageStats.

Signed-off-by: default avatarzhuyunyi <zhuyunyi@xiaomi.com>
Change-Id: I58a54d17aad6ef5213e52658ee3387f3069339af
parent 6efa908b
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment