Fix incorrect storage size in Storage Settings

From Android S, Storage Settings queries file sizes
from MediaProvider, it's not necessary to count size
data from getExternalStorageStats when calculating
size data.

Bug: 185542752
Test: make RunSettingsRoboTests ROBOTEST_FILTER=testMeasurementCompletedUpdatesPreferences
      manual
      1. Connect device to PC via USB File transfer.
      2. Copy large files from PC to device.
      3. Observe size information in Storage Settings.
Change-Id: I43cbec764e97f5003a4ec981717c9f213a21b614
This commit is contained in:
Arc Wang
2021-07-02 10:39:25 +08:00
parent 1060b2f926
commit 25880d0d0e
2 changed files with 0 additions and 9 deletions

View File

@@ -386,8 +386,6 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
+ otherData.documentsAndOtherSize + otherData.documentsAndOtherSize
+ otherData.trashSize + otherData.trashSize
+ otherData.allAppsExceptGamesSize; + otherData.allAppsExceptGamesSize;
attributedSize += otherData.externalStats.totalBytes
- otherData.externalStats.appBytes;
attributedSize -= otherData.duplicateCodeSize; attributedSize -= otherData.duplicateCodeSize;
} }

View File

@@ -54,7 +54,6 @@ import com.android.settings.applications.manageapplications.ManageApplications;
import com.android.settings.dashboard.profileselector.ProfileSelectFragment; import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
import com.android.settings.deviceinfo.StorageItemPreference; import com.android.settings.deviceinfo.StorageItemPreference;
import com.android.settings.testutils.shadow.ShadowUserManager; import com.android.settings.testutils.shadow.ShadowUserManager;
import com.android.settingslib.applications.StorageStatsSource;
import com.android.settingslib.deviceinfo.StorageVolumeProvider; import com.android.settingslib.deviceinfo.StorageVolumeProvider;
import org.junit.Before; import org.junit.Before;
@@ -340,12 +339,6 @@ public class StorageItemPreferenceControllerTest {
result.documentsAndOtherSize = MEGABYTE_IN_BYTES * 50; result.documentsAndOtherSize = MEGABYTE_IN_BYTES * 50;
result.trashSize = KILOBYTE_IN_BYTES * 100; result.trashSize = KILOBYTE_IN_BYTES * 100;
result.allAppsExceptGamesSize = MEGABYTE_IN_BYTES * 90; result.allAppsExceptGamesSize = MEGABYTE_IN_BYTES * 90;
result.externalStats =
new StorageStatsSource.ExternalStorageStats(
MEGABYTE_IN_BYTES * 500, // total
MEGABYTE_IN_BYTES * 100, // audio
MEGABYTE_IN_BYTES * 150, // video
MEGABYTE_IN_BYTES * 200, 0); // image
final SparseArray<StorageAsyncLoader.StorageResult> results = new SparseArray<>(); final SparseArray<StorageAsyncLoader.StorageResult> results = new SparseArray<>();
results.put(0, result); results.put(0, result);