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
To build the tests you can use the following command at the root of your android source tree $ make SettingsUnitTests The test apk then needs to be installed onto your test device via for example $ adb install -r out/target/product/shamu/data/app/SettingsUnitTests/SettingsUnitTests.apk To run all tests: $ adb shell am instrument -w com.android.settings.tests.unit/android.support.test.runner.AndroidJUnitRunner To run all tests in a specific class: $ adb shell am instrument -w -e class com.android.settings.<class> com.android.settings.tests.unit/android.support.test.runner.AndroidJUnitRunner To run a specific test: $ adb shell am instrument -w -e class com.android.settings.<class>#<test> com.android.settings.tests.unit/android.support.test.runner.AndroidJUnitRunner More general information can be found at http://developer.android.com/reference/android/support/test/runner/AndroidJUnitRunner.html