Close the load screen faster on pre-quota devices.
Pre-quota devices can take an absurd time to load. By loading the screen once the volume sizes load, we can just show "calculating..." for a really long time instead of a loading screen. Change-Id: Id8ab0609c2bc19531d530c6bdf6bff89c5bfac96 Fixes: 64150148 Test: Settings Robotest
This commit is contained in:
@@ -105,9 +105,7 @@ public class StorageDashboardFragment extends DashboardFragment
|
||||
public void onViewCreated(View v, Bundle savedInstanceState) {
|
||||
super.onViewCreated(v, savedInstanceState);
|
||||
initializeCacheProvider();
|
||||
if (mAppsResult == null || mStorageInfo == null) {
|
||||
setLoading(true, false);
|
||||
}
|
||||
maybeSetLoading(isQuotaSupported());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -125,21 +123,23 @@ public class StorageDashboardFragment extends DashboardFragment
|
||||
}
|
||||
|
||||
private void onReceivedSizes() {
|
||||
if (mStorageInfo == null || mAppsResult == null) {
|
||||
return;
|
||||
if (mStorageInfo != null) {
|
||||
long privateUsedBytes = mStorageInfo.totalBytes - mStorageInfo.freeBytes;
|
||||
mSummaryController.updateBytes(privateUsedBytes, mStorageInfo.totalBytes);
|
||||
mPreferenceController.setVolume(mVolume);
|
||||
mPreferenceController.setUsedSize(privateUsedBytes);
|
||||
mPreferenceController.setTotalSize(mStorageInfo.totalBytes);
|
||||
for (int i = 0, size = mSecondaryUsers.size(); i < size; i++) {
|
||||
AbstractPreferenceController controller = mSecondaryUsers.get(i);
|
||||
if (controller instanceof SecondaryUserController) {
|
||||
SecondaryUserController userController = (SecondaryUserController) controller;
|
||||
userController.setTotalSize(mStorageInfo.totalBytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
long privateUsedBytes = mStorageInfo.totalBytes - mStorageInfo.freeBytes;
|
||||
mSummaryController.updateBytes(privateUsedBytes, mStorageInfo.totalBytes);
|
||||
mPreferenceController.setVolume(mVolume);
|
||||
mPreferenceController.setUsedSize(privateUsedBytes);
|
||||
mPreferenceController.setTotalSize(mStorageInfo.totalBytes);
|
||||
for (int i = 0, size = mSecondaryUsers.size(); i < size; i++) {
|
||||
AbstractPreferenceController controller = mSecondaryUsers.get(i);
|
||||
if (controller instanceof SecondaryUserController) {
|
||||
SecondaryUserController userController = (SecondaryUserController) controller;
|
||||
userController.setTotalSize(mStorageInfo.totalBytes);
|
||||
}
|
||||
if (mAppsResult == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
mPreferenceController.onLoadFinished(mAppsResult, UserHandle.myUserId());
|
||||
@@ -272,11 +272,21 @@ public class StorageDashboardFragment extends DashboardFragment
|
||||
return mStorageInfo;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void setPrivateStorageInfo(PrivateStorageInfo info) {
|
||||
mStorageInfo = info;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public SparseArray<StorageAsyncLoader.AppsStorageResult> getAppsStorageResult() {
|
||||
return mAppsResult;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void setAppsStorageResult(SparseArray<StorageAsyncLoader.AppsStorageResult> info) {
|
||||
mAppsResult = info;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void initializeCachedValues() {
|
||||
PrivateStorageInfo info = mCachedStorageValuesHelper.getCachedPrivateStorageInfo();
|
||||
@@ -290,6 +300,16 @@ public class StorageDashboardFragment extends DashboardFragment
|
||||
mAppsResult = loaderResult;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void maybeSetLoading(boolean isQuotaSupported) {
|
||||
// If we have fast stats, we load until both have loaded.
|
||||
// If we have slow stats, we load when we get the total volume sizes.
|
||||
if ((isQuotaSupported && (mStorageInfo == null || mAppsResult == null)) ||
|
||||
(!isQuotaSupported && mStorageInfo == null)) {
|
||||
setLoading(true /* loading */, false /* animate */);
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeCacheProvider() {
|
||||
mCachedStorageValuesHelper =
|
||||
new CachedStorageValuesHelper(getContext(), UserHandle.myUserId());
|
||||
@@ -304,6 +324,11 @@ public class StorageDashboardFragment extends DashboardFragment
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isQuotaSupported() {
|
||||
final StorageStatsManager stats = getActivity().getSystemService(StorageStatsManager.class);
|
||||
return stats.isQuotaSupported(mVolume.fsUuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* IconLoaderCallbacks exists because StorageDashboardFragment already implements
|
||||
* LoaderCallbacks for a different type.
|
||||
|
Reference in New Issue
Block a user