Add cache mechanism for secondary users in Storage

To prevent from the flicker happening, the size info for secondary users
will be cached.

Bug: 220259287
Test: manual test
1) Create secondary user
2) Finish setup flow
3) Install any types of apps and try to change the storage size
4) Navigate to Settings > Storage
5) Observe the storage size and progress bar, they should have animation
   when storage size info updated.

Change-Id: Iff706b20446603f08334a0b782dd505ca78bdab2
This commit is contained in:
Mill Chen
2022-03-14 19:30:03 +08:00
parent bb44ceb407
commit ee41ad89a9
7 changed files with 60 additions and 30 deletions

View File

@@ -246,7 +246,7 @@ public class StorageDashboardFragment extends DashboardFragment
if (mStorageCacheHelper.hasCachedSizeInfo() && mSelectedStorageEntry.isPrivate()) {
StorageCacheHelper.StorageCache cachedData = mStorageCacheHelper.retrieveCachedSize();
mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo());
mPreferenceController.setUsedSize(cachedData.usedSize);
mPreferenceController.setUsedSize(cachedData.totalUsedSize);
mPreferenceController.setTotalSize(cachedData.totalSize);
}
@@ -396,7 +396,8 @@ public class StorageDashboardFragment extends DashboardFragment
mPreferenceController.setUsedSize(privateUsedBytes);
mPreferenceController.setTotalSize(mStorageInfo.totalBytes);
// Cache total size and used size
mStorageCacheHelper.cacheTotalSizeAndUsedSize(mStorageInfo.totalBytes, privateUsedBytes);
mStorageCacheHelper
.cacheTotalSizeAndTotalUsedSize(mStorageInfo.totalBytes, privateUsedBytes);
for (int i = 0, size = mSecondaryUsers.size(); i < size; i++) {
final AbstractPreferenceController controller = mSecondaryUsers.get(i);
if (controller instanceof SecondaryUserController) {