Merge "Measure external storage application usage" into honeycomb

This commit is contained in:
Kenny Root
2011-01-17 10:13:58 -08:00
committed by Android (Google) Code Review
4 changed files with 65 additions and 4 deletions

View File

@@ -71,6 +71,7 @@ public class ApplicationsState {
long cacheSize;
long codeSize;
long dataSize;
long externalSize;
}
public static class AppEntry extends SizeInfo {
@@ -626,9 +627,16 @@ public class ApplicationsState {
// --------------------------------------------------------------
private long getTotalSize(PackageStats ps) {
private long getTotalInternalSize(PackageStats ps) {
if (ps != null) {
return ps.codeSize+ps.dataSize;
return ps.codeSize + ps.dataSize;
}
return SIZE_INVALID;
}
private long getTotalExternalSize(PackageStats ps) {
if (ps != null) {
return ps.externalDataSize + ps.externalMediaSize + ps.externalCacheSize;
}
return SIZE_INVALID;
}
@@ -660,15 +668,18 @@ public class ApplicationsState {
synchronized (entry) {
entry.sizeStale = false;
entry.sizeLoadStart = 0;
long newSize = getTotalSize(stats);
long externalSize = getTotalExternalSize(stats);
long newSize = externalSize + getTotalInternalSize(stats);
if (entry.size != newSize ||
entry.cacheSize != stats.cacheSize ||
entry.codeSize != stats.codeSize ||
entry.dataSize != stats.dataSize) {
entry.dataSize != stats.dataSize ||
entry.externalSize != externalSize) {
entry.size = newSize;
entry.cacheSize = stats.cacheSize;
entry.codeSize = stats.codeSize;
entry.dataSize = stats.dataSize;
entry.externalSize = externalSize;
entry.sizeStr = getSizeStr(entry.size);
if (DEBUG) Log.i(TAG, "Set size of " + entry.label + " " + entry
+ ": " + entry.sizeStr);

View File

@@ -93,6 +93,7 @@ public class InstalledAppDetails extends Fragment
private TextView mTotalSize;
private TextView mAppSize;
private TextView mDataSize;
private TextView mExternalSize;
private ClearUserDataObserver mClearDataObserver;
// Views related to cache info
private TextView mCacheSize;
@@ -107,6 +108,7 @@ public class InstalledAppDetails extends Fragment
private boolean mHaveSizes = false;
private long mLastCodeSize = -1;
private long mLastDataSize = -1;
private long mLastExternalSize = -1;
private long mLastCacheSize = -1;
private long mLastTotalSize = -1;
@@ -317,6 +319,7 @@ public class InstalledAppDetails extends Fragment
mTotalSize = (TextView)view.findViewById(R.id.total_size_text);
mAppSize = (TextView)view.findViewById(R.id.application_size_text);
mDataSize = (TextView)view.findViewById(R.id.data_size_text);
mExternalSize = (TextView)view.findViewById(R.id.external_size_text);
// Get Control button panel
View btnPanel = view.findViewById(R.id.control_buttons_panel);
@@ -504,6 +507,10 @@ public class InstalledAppDetails extends Fragment
mLastDataSize = mAppEntry.dataSize;
mDataSize.setText(getSizeStr(mAppEntry.dataSize));
}
if (mLastExternalSize != mAppEntry.externalSize) {
mLastExternalSize = mAppEntry.externalSize;
mExternalSize.setText(getSizeStr(mAppEntry.externalSize));
}
if (mLastCacheSize != mAppEntry.cacheSize) {
mLastCacheSize = mAppEntry.cacheSize;
mCacheSize.setText(getSizeStr(mAppEntry.cacheSize));