OSDN Git Service

UsageStats creates too many daily/weekly/monthly/yearly files.
authorHui Yu <huiyu@google.com>
Tue, 29 Jan 2019 00:33:32 +0000 (16:33 -0800)
committerHui Yu <huiyu@google.com>
Wed, 20 Feb 2019 21:15:39 +0000 (21:15 +0000)
commitb21d59f283f72c8bf6bafdf3ac6cc1c2a1f17e5c
tree8f421c2e735abe16cb8b44515abdf255f2b71394
parentffd44b35193a52e4548b2914ff31aa8d9b2308c1
UsageStats creates too many daily/weekly/monthly/yearly files.

A wrong condition causes new sets of daily/weekly/monthly/yearly files
been created before it reaches the rollover time.

Currently database files are pruned by timestamp, it allows 3 years
yearly files, 6 months monthly files, 4 weeks weekly files, 10 days
daily files. Because the bug there could be unlimited number of files
are created as long as files' timestamp falls in these allowed time
spans.

Add a logic to prune files by number of files. Only allow up to 10 yearly
files, 12 monthly files, 50 weekly files, 100 daily files.

Change-Id: Iac42f70ae19edb48885a123dfd9988021de6c88d
Fix: b/122725555
Test: NA.
services/tests/servicestests/src/com/android/server/usage/UsageStatsDatabaseTest.java
services/usage/java/com/android/server/usage/UsageStatsDatabase.java
services/usage/java/com/android/server/usage/UserUsageStatsService.java