Consistent "low storage" behavior.

Fix several bugs related to storage accounting.  Since getDataBytes()
already includes cached data, we need to subtract it to avoid blaming
apps for it.

We also need to blame app code on someone, so we blame it on the
current user.  StorageStatsManager was fixed awhile back to only
return the app code size on the requested storage volume, so we can
remove the system app checks.

Subtract "appBytes" from external storage accounting, since it's
already been blamed elsewhere against specific apps.

Pass along storage results from all users on the device, and subtract
them all when estimating size of "system" data.  To avoid embarrassing
estimation bugs, make sure that "system" data is at least 1GB.

Bug: 38008706
Test: cts-tradefed run commandAndExit cts-dev -m CtsJobSchedulerTestCases -t android.jobscheduler.cts.StorageConstraintTest
Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.StorageHostTest
Change-Id: Ide1e6d0690e5ad4e751c87891f63ba1036434619
10 files changed