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

@@ -132,6 +132,7 @@
android:maxLines="1" />
</LinearLayout>
<LinearLayout
android:id="@+id/info_size"
android:layout_width="match_parent"
@@ -169,6 +170,44 @@
android:maxLines="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:baselineAligned="true"
android:paddingTop="-1dip">
<TextView
android:id="@+id/external_size_prefix"
android:text="@string/external_size_label"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:maxLines="1"
android:paddingTop="6dip"
android:paddingLeft="6dip"/>
<ImageView
android:id="@+id/info_size_dots"
android:src="@drawable/dotted_line_480px"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="1px"
android:layout_gravity="bottom"
android:layout_marginLeft="1dip"
android:layout_marginRight="1dip"
android:layout_marginBottom="4dip"
android:scaleType="center" />
<TextView
android:id="@+id/external_size_text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:paddingTop="6dip"
android:paddingRight="6dip"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:maxLines="1" />
</LinearLayout>
<!-- Clear data and install location buttons -->
<include
layout="@layout/two_buttons_panel"

View File

@@ -1969,6 +1969,10 @@
<string name="application_size_label">Application</string>
<!-- Manage applications, individual application info screen, label under Storage heading. The amount of sapce taken up by the app's data (for example, downloaded emails or something like that) -->
<string name="data_size_label">Data</string>
<!-- Manage applications, individual application info screen, label under Storage heading. The amount of space taken up by the app's data on USB storage [CHARSIZE=40] -->
<string name="external_size_label" product="nosdcard">USB storage</string>
<!-- Manage applications, individual application info screen, label under Storage heading. The amount of space taken up by the app's data on the SD card [CHARSIZE=40] -->
<string name="external_size_label" product="default">SD card</string>
<!-- Manage applications, individual application info screen, button label under Storage heading. Button to remove the application from the system. -->
<string name="uninstall_text">Uninstall</string>
<!-- [CHAR LIMIT=25] Manage applications, individual application info screen, button label under Storage heading. Button to disable an existing application. -->

View File

@@ -71,6 +71,7 @@ public class ApplicationsState {
long cacheSize;
long codeSize;
long dataSize;
long externalSize;
}
public static class AppEntry extends SizeInfo {
@@ -626,13 +627,20 @@ public class ApplicationsState {
// --------------------------------------------------------------
private long getTotalSize(PackageStats ps) {
private long getTotalInternalSize(PackageStats ps) {
if (ps != null) {
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;
}
private String getSizeStr(long size) {
if (size >= 0) {
return Formatter.formatFileSize(mContext, size);
@@ -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));