Improved storage accounting:
am: 7358b7802f
Change-Id: Ie5839177bf44a0269e04d17a2f33012e3029ab38
This commit is contained in:
@@ -2617,11 +2617,10 @@
|
|||||||
|
|
||||||
<!-- Body of dialog informing user about other files on a storage device [CHAR LIMIT=NONE]-->
|
<!-- Body of dialog informing user about other files on a storage device [CHAR LIMIT=NONE]-->
|
||||||
<string name="storage_detail_dialog_other">Other includes shared files saved by apps, files downloaded from the Internet or Bluetooth, Android files, and so on.
|
<string name="storage_detail_dialog_other">Other includes shared files saved by apps, files downloaded from the Internet or Bluetooth, Android files, and so on.
|
||||||
\n\nTo see the entire contents of this <xliff:g id="name" example="SD card">^1</xliff:g>, tap Explore.</string>
|
\n\nTo see the visible contents of this <xliff:g id="name" example="SD card">^1</xliff:g>, tap Explore.</string>
|
||||||
|
|
||||||
<!-- Body of dialog informing user about the storage used by the Android System [CHAR LIMIT=NONE]-->
|
<!-- Body of dialog informing user about the storage used by the Android System [CHAR LIMIT=NONE]-->
|
||||||
<string name="storage_detail_dialog_system">System includes files used internally by the Android operating system.
|
<string name="storage_detail_dialog_system">System includes files that Android can\u2019t display individually.</string>
|
||||||
\n\nThese files can\u2019t be viewed individually.</string>
|
|
||||||
|
|
||||||
<!-- Body of dialog informing user about other users on a storage device [CHAR LIMIT=NONE]-->
|
<!-- Body of dialog informing user about other users on a storage device [CHAR LIMIT=NONE]-->
|
||||||
<string name="storage_detail_dialog_user"><xliff:g id="user" example="Guest user">^1</xliff:g> may have saved photos, music, movies, apps, or other data that is taking up <xliff:g id="size" example="1.2 GB">^2</xliff:g> of storage.
|
<string name="storage_detail_dialog_user"><xliff:g id="user" example="Guest user">^1</xliff:g> may have saved photos, music, movies, apps, or other data that is taking up <xliff:g id="size" example="1.2 GB">^2</xliff:g> of storage.
|
||||||
|
@@ -72,8 +72,6 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import static com.android.settings.deviceinfo.StorageSettings.TAG;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Panel showing summary and actions for a {@link VolumeInfo#TYPE_PRIVATE}
|
* Panel showing summary and actions for a {@link VolumeInfo#TYPE_PRIVATE}
|
||||||
* storage volume.
|
* storage volume.
|
||||||
@@ -82,6 +80,9 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
// TODO: disable unmount when providing over MTP/PTP
|
// TODO: disable unmount when providing over MTP/PTP
|
||||||
// TODO: warn when mounted read-only
|
// TODO: warn when mounted read-only
|
||||||
|
|
||||||
|
private static final String TAG = "PrivateVolumeSettings";
|
||||||
|
private static final boolean LOGV = false;
|
||||||
|
|
||||||
private static final String TAG_RENAME = "rename";
|
private static final String TAG_RENAME = "rename";
|
||||||
private static final String TAG_OTHER_INFO = "otherInfo";
|
private static final String TAG_OTHER_INFO = "otherInfo";
|
||||||
private static final String TAG_SYSTEM_INFO = "systemInfo";
|
private static final String TAG_SYSTEM_INFO = "systemInfo";
|
||||||
@@ -164,6 +165,9 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
final long sharedDataSize = mVolume.getPath().getTotalSpace();
|
final long sharedDataSize = mVolume.getPath().getTotalSpace();
|
||||||
mTotalSize = getArguments().getLong(EXTRA_VOLUME_SIZE, 0);
|
mTotalSize = getArguments().getLong(EXTRA_VOLUME_SIZE, 0);
|
||||||
mSystemSize = mTotalSize - sharedDataSize;
|
mSystemSize = mTotalSize - sharedDataSize;
|
||||||
|
if (LOGV) Log.v(TAG,
|
||||||
|
"onCreate() mTotalSize: " + mTotalSize + " sharedDataSize: " + sharedDataSize);
|
||||||
|
|
||||||
if (mTotalSize <= 0) {
|
if (mTotalSize <= 0) {
|
||||||
mTotalSize = sharedDataSize;
|
mTotalSize = sharedDataSize;
|
||||||
mSystemSize = 0;
|
mSystemSize = 0;
|
||||||
@@ -260,6 +264,8 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
final long freeBytes = mVolume.getPath().getFreeSpace();
|
final long freeBytes = mVolume.getPath().getFreeSpace();
|
||||||
final long usedBytes = mTotalSize - freeBytes;
|
final long usedBytes = mTotalSize - freeBytes;
|
||||||
|
|
||||||
|
if (LOGV) Log.v(TAG, "update() freeBytes: " + freeBytes + " usedBytes: " + usedBytes);
|
||||||
|
|
||||||
final BytesResult result = Formatter.formatBytes(getResources(), usedBytes, 0);
|
final BytesResult result = Formatter.formatBytes(getResources(), usedBytes, 0);
|
||||||
mSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large),
|
mSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large),
|
||||||
result.value, result.units));
|
result.value, result.units));
|
||||||
@@ -554,6 +560,11 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private void updateDetails(MeasurementDetails details) {
|
private void updateDetails(MeasurementDetails details) {
|
||||||
|
StorageItemPreference otherItem = null;
|
||||||
|
long accountedSize = 0;
|
||||||
|
long totalMiscSize = 0;
|
||||||
|
long totalDownloadsSize = 0;
|
||||||
|
|
||||||
for (int i = 0; i < mItemPoolIndex; ++i) {
|
for (int i = 0; i < mItemPoolIndex; ++i) {
|
||||||
StorageItemPreference item = mItemPreferencePool.get(i);
|
StorageItemPreference item = mItemPreferencePool.get(i);
|
||||||
final int userId = item.userHandle;
|
final int userId = item.userHandle;
|
||||||
@@ -566,20 +577,31 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
switch (itemTitleId) {
|
switch (itemTitleId) {
|
||||||
case R.string.storage_detail_system: {
|
case R.string.storage_detail_system: {
|
||||||
updatePreference(item, mSystemSize);
|
updatePreference(item, mSystemSize);
|
||||||
|
accountedSize += mSystemSize;
|
||||||
|
if (LOGV) Log.v(TAG, "mSystemSize: " + mSystemSize
|
||||||
|
+ " accountedSize: " + accountedSize);
|
||||||
} break;
|
} break;
|
||||||
case R.string.storage_detail_apps: {
|
case R.string.storage_detail_apps: {
|
||||||
updatePreference(item, details.appsSize.get(userId));
|
updatePreference(item, details.appsSize.get(userId));
|
||||||
|
accountedSize += details.appsSize.get(userId);
|
||||||
|
if (LOGV) Log.v(TAG, "appsSize: " + details.appsSize.get(userId)
|
||||||
|
+ " accountedSize: " + accountedSize);
|
||||||
} break;
|
} break;
|
||||||
case R.string.storage_detail_images: {
|
case R.string.storage_detail_images: {
|
||||||
final long imagesSize = totalValues(details, userId,
|
final long imagesSize = totalValues(details, userId,
|
||||||
Environment.DIRECTORY_DCIM, Environment.DIRECTORY_MOVIES,
|
Environment.DIRECTORY_DCIM, Environment.DIRECTORY_PICTURES);
|
||||||
Environment.DIRECTORY_PICTURES);
|
|
||||||
updatePreference(item, imagesSize);
|
updatePreference(item, imagesSize);
|
||||||
|
accountedSize += imagesSize;
|
||||||
|
if (LOGV) Log.v(TAG, "imagesSize: " + imagesSize
|
||||||
|
+ " accountedSize: " + accountedSize);
|
||||||
} break;
|
} break;
|
||||||
case R.string.storage_detail_videos: {
|
case R.string.storage_detail_videos: {
|
||||||
final long videosSize = totalValues(details, userId,
|
final long videosSize = totalValues(details, userId,
|
||||||
Environment.DIRECTORY_MOVIES);
|
Environment.DIRECTORY_MOVIES);
|
||||||
updatePreference(item, videosSize);
|
updatePreference(item, videosSize);
|
||||||
|
accountedSize += videosSize;
|
||||||
|
if (LOGV) Log.v(TAG, "videosSize: " + videosSize
|
||||||
|
+ " accountedSize: " + accountedSize);
|
||||||
} break;
|
} break;
|
||||||
case R.string.storage_detail_audio: {
|
case R.string.storage_detail_audio: {
|
||||||
final long audioSize = totalValues(details, userId,
|
final long audioSize = totalValues(details, userId,
|
||||||
@@ -587,19 +609,54 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
Environment.DIRECTORY_ALARMS, Environment.DIRECTORY_NOTIFICATIONS,
|
Environment.DIRECTORY_ALARMS, Environment.DIRECTORY_NOTIFICATIONS,
|
||||||
Environment.DIRECTORY_RINGTONES, Environment.DIRECTORY_PODCASTS);
|
Environment.DIRECTORY_RINGTONES, Environment.DIRECTORY_PODCASTS);
|
||||||
updatePreference(item, audioSize);
|
updatePreference(item, audioSize);
|
||||||
|
accountedSize += audioSize;
|
||||||
|
if (LOGV) Log.v(TAG, "audioSize: " + audioSize
|
||||||
|
+ " accountedSize: " + accountedSize);
|
||||||
} break;
|
} break;
|
||||||
case R.string.storage_detail_other: {
|
case R.string.storage_detail_other: {
|
||||||
updatePreference(item, details.miscSize.get(userId));
|
final long downloadsSize = totalValues(details, userId,
|
||||||
|
Environment.DIRECTORY_DOWNLOADS);
|
||||||
|
final long miscSize = details.miscSize.get(userId);
|
||||||
|
totalDownloadsSize += downloadsSize;
|
||||||
|
totalMiscSize += miscSize;
|
||||||
|
accountedSize += miscSize + downloadsSize;
|
||||||
|
|
||||||
|
if (LOGV)
|
||||||
|
Log.v(TAG, "miscSize for " + userId + ": " + miscSize + "(total: "
|
||||||
|
+ totalMiscSize + ") \ndownloadsSize: " + downloadsSize + "(total: "
|
||||||
|
+ totalDownloadsSize + ") accountedSize: " + accountedSize);
|
||||||
|
|
||||||
|
// Cannot display 'Other' until all known items are accounted for.
|
||||||
|
otherItem = item;
|
||||||
} break;
|
} break;
|
||||||
case R.string.storage_detail_cached: {
|
case R.string.storage_detail_cached: {
|
||||||
updatePreference(item, details.cacheSize);
|
updatePreference(item, details.cacheSize);
|
||||||
|
accountedSize += details.cacheSize;
|
||||||
|
if (LOGV)
|
||||||
|
Log.v(TAG, "cacheSize: " + details.cacheSize + " accountedSize: "
|
||||||
|
+ accountedSize);
|
||||||
} break;
|
} break;
|
||||||
case 0: {
|
case 0: {
|
||||||
final long userSize = details.usersSize.get(userId);
|
final long userSize = details.usersSize.get(userId);
|
||||||
updatePreference(item, userSize);
|
updatePreference(item, userSize);
|
||||||
|
accountedSize += userSize;
|
||||||
|
if (LOGV) Log.v(TAG, "userSize: " + userSize
|
||||||
|
+ " accountedSize: " + accountedSize);
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (otherItem != null) {
|
||||||
|
final long usedSize = mTotalSize - details.availSize;
|
||||||
|
final long unaccountedSize = usedSize - accountedSize;
|
||||||
|
final long otherSize = totalMiscSize + totalDownloadsSize + unaccountedSize;
|
||||||
|
if (LOGV)
|
||||||
|
Log.v(TAG, "Other items: \n\tmTotalSize: " + mTotalSize + " availSize: "
|
||||||
|
+ details.availSize + " usedSize: " + usedSize + "\n\taccountedSize: "
|
||||||
|
+ accountedSize + " unaccountedSize size: " + unaccountedSize
|
||||||
|
+ "\n\ttotalMiscSize: " + totalMiscSize + " totalDownloadsSize: "
|
||||||
|
+ totalDownloadsSize + "\n\tdetails: " + details);
|
||||||
|
updatePreference(otherItem, otherSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePreference(StorageItemPreference pref, long size) {
|
private void updatePreference(StorageItemPreference pref, long size) {
|
||||||
|
Reference in New Issue
Block a user