Merge "Change how we calculate system size." into oc-dev
am: 0b75d39312
Change-Id: Icaf7f87f280cd60ed37e02608821ab07815abbad
diff --git a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
index f7bb95d..2a5ac17 100644
--- a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
+++ b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
@@ -19,7 +19,6 @@
import android.app.Activity;
import android.app.LoaderManager;
import android.content.Context;
-import android.content.Intent;
import android.content.Loader;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
@@ -29,16 +28,11 @@
import android.os.storage.VolumeInfo;
import android.provider.SearchIndexableResource;
import android.support.annotation.VisibleForTesting;
-import android.util.Log;
import android.util.SparseArray;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.Utils;
-import com.android.settings.applications.PackageManagerWrapper;
import com.android.settings.applications.PackageManagerWrapperImpl;
import com.android.settings.applications.UserManagerWrapper;
import com.android.settings.applications.UserManagerWrapperImpl;
@@ -58,7 +52,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.Objects;
public class StorageDashboardFragment extends DashboardFragment
implements LoaderManager.LoaderCallbacks<SparseArray<StorageAsyncLoader.AppsStorageResult>> {
@@ -101,8 +94,7 @@
final long usedBytes = totalSize - mVolume.getPath().getFreeSpace();
mSummaryController.updateBytes(usedBytes, totalSize);
mPreferenceController.setVolume(mVolume);
- mPreferenceController.setSystemSize(systemSize);
-
+ mPreferenceController.setUsedSize(usedBytes);
mPreferenceController.setTotalSize(totalSize);
for (int i = 0, size = mSecondaryUsers.size(); i < size; i++) {
PreferenceController controller = mSecondaryUsers.get(i);
diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
index 36694f0..5c4e354 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
@@ -78,7 +78,7 @@
private final StorageVolumeProvider mSvp;
private VolumeInfo mVolume;
private int mUserId;
- private long mSystemSize;
+ private long mUsedBytes;
private long mTotalSize;
private StorageItemPreference mPhotoPreference;
@@ -226,17 +226,29 @@
mGamePreference.setStorageSize(data.gamesSize, mTotalSize);
mMoviesPreference.setStorageSize(data.videoAppsSize, mTotalSize);
mAppPreference.setStorageSize(data.otherAppsSize, mTotalSize);
- if (mSystemPreference != null) {
- mSystemPreference.setStorageSize(mSystemSize + data.systemSize, mTotalSize);
- }
- long unattributedBytes = data.externalStats.totalBytes - data.externalStats.audioBytes
- - data.externalStats.videoBytes - data.externalStats.imageBytes;
- mFilePreference.setStorageSize(unattributedBytes, mTotalSize);
+ long unattributedExternalBytes =
+ data.externalStats.totalBytes
+ - data.externalStats.audioBytes
+ - data.externalStats.videoBytes
+ - data.externalStats.imageBytes;
+ mFilePreference.setStorageSize(unattributedExternalBytes, mTotalSize);
+
+ // We define the system size as everything we can't classify.
+ if (mSystemPreference != null) {
+ mSystemPreference.setStorageSize(
+ mUsedBytes
+ - data.externalStats.totalBytes
+ - data.musicAppsSize
+ - data.gamesSize
+ - data.videoAppsSize
+ - data.otherAppsSize,
+ mTotalSize);
+ }
}
- public void setSystemSize(long systemSizeBytes) {
- mSystemSize = systemSizeBytes;
+ public void setUsedSize(long usedSizeBytes) {
+ mUsedBytes = usedSizeBytes;
}
public void setTotalSize(long totalSizeBytes) {
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
index 47faf92..2231c22 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
@@ -242,21 +242,19 @@
eq(StorageItemPreferenceController.FILES_KEY))).thenReturn(files);
mController.displayPreference(screen);
- mController.setSystemSize(KILOBYTE * 6);
+ mController.setUsedSize(KILOBYTE * 200); // There should 87kB attributed.
StorageAsyncLoader.AppsStorageResult result = new StorageAsyncLoader.AppsStorageResult();
result.gamesSize = KILOBYTE * 8;
result.videoAppsSize = KILOBYTE * 16;
result.musicAppsSize = KILOBYTE * 4;
result.otherAppsSize = KILOBYTE * 9;
- result.systemSize = KILOBYTE * 10;
+ result.systemSize = KILOBYTE * 10; // This value is ignored and overriden now.
result.externalStats = new StorageStatsSource.ExternalStorageStats(
KILOBYTE * 50, // total
KILOBYTE * 10, // audio
KILOBYTE * 15, // video
KILOBYTE * 20); // image
- result.gamesSize = KILOBYTE * 8;
- result.otherAppsSize = KILOBYTE * 9;
mController.onLoadFinished(result);
assertThat(audio.getSummary().toString()).isEqualTo("14.00KB"); // 4KB apps + 10KB files
@@ -264,7 +262,7 @@
assertThat(games.getSummary().toString()).isEqualTo("8.00KB");
assertThat(movies.getSummary().toString()).isEqualTo("16.00KB");
assertThat(apps.getSummary().toString()).isEqualTo("9.00KB");
- assertThat(system.getSummary().toString()).isEqualTo("16.00KB");
+ assertThat(system.getSummary().toString()).isEqualTo("113KB");
assertThat(files.getSummary().toString()).isEqualTo("5.00KB");
}