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: zhuyunyi <zhuyunyi@xiaomi.com>
Change-Id: I58a54d17aad6ef5213e52658ee3387f3069339af
Loading
Please register or sign in to comment