From 424acfb7ad469efb0a51c69fc8713cc96e2357b0 Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Sun, 16 Jan 2011 16:59:11 -0800 Subject: [PATCH] Measure external storage application usage Application data usage on the SD card (or USB storage) was not being reported by the Manage Applications screen. This is important for upcoming OBB space accounting. Bug: 3308791 Change-Id: Ibc9ad013cb2f6d0ee28caadca8899c1ff6e78f44 --- res/layout/installed_app_details.xml | 39 +++++++++++++++++++ res/values/strings.xml | 4 ++ .../applications/ApplicationsState.java | 19 +++++++-- .../applications/InstalledAppDetails.java | 7 ++++ 4 files changed, 65 insertions(+), 4 deletions(-) diff --git a/res/layout/installed_app_details.xml b/res/layout/installed_app_details.xml index fff197553de..0b68d47685f 100644 --- a/res/layout/installed_app_details.xml +++ b/res/layout/installed_app_details.xml @@ -132,6 +132,7 @@ android:maxLines="1" /> + + + + + + + + + Application Data + + USB storage + + SD card Uninstall diff --git a/src/com/android/settings/applications/ApplicationsState.java b/src/com/android/settings/applications/ApplicationsState.java index 6e9f2a2d296..6de8c7f1c48 100644 --- a/src/com/android/settings/applications/ApplicationsState.java +++ b/src/com/android/settings/applications/ApplicationsState.java @@ -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); diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java index de897eb49e8..06d97fc8713 100644 --- a/src/com/android/settings/applications/InstalledAppDetails.java +++ b/src/com/android/settings/applications/InstalledAppDetails.java @@ -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));