diff options
Diffstat (limited to 'src/com/android/settings/applications')
3 files changed, 79 insertions, 23 deletions
diff --git a/src/com/android/settings/applications/ApplicationsState.java b/src/com/android/settings/applications/ApplicationsState.java index 11e4aae..519c203 100644 --- a/src/com/android/settings/applications/ApplicationsState.java +++ b/src/com/android/settings/applications/ApplicationsState.java @@ -5,14 +5,11 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.IPackageStatsObserver; import android.content.pm.PackageManager; import android.content.pm.PackageStats; import android.content.pm.PackageManager.NameNotFoundException; -import android.content.res.Configuration; -import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Handler; @@ -74,7 +71,8 @@ public class ApplicationsState { long cacheSize; long codeSize; long dataSize; - long externalSize; + long externalCodeSize; + long externalDataSize; } public static class AppEntry extends SizeInfo { @@ -97,6 +95,8 @@ public class ApplicationsState { ApplicationInfo info; Drawable icon; String sizeStr; + String internalSizeStr; + String externalSizeStr; boolean sizeStale; long sizeLoadStart; @@ -392,6 +392,14 @@ public class ApplicationsState { for (int i=0; i<mApplications.size(); i++) { final ApplicationInfo info = mApplications.get(i); + // Need to trim out any applications that are disabled by + // something different than the user. + if (!info.enabled && info.enabledSetting + != PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER) { + mApplications.remove(i); + i--; + continue; + } final AppEntry entry = mEntriesMap.get(info.packageName); if (entry != null) { entry.info = info; @@ -652,8 +660,8 @@ public class ApplicationsState { private long getTotalExternalSize(PackageStats ps) { if (ps != null) { - return ps.externalDataSize + ps.externalMediaSize + ps.externalCacheSize - + ps.externalObbSize; + return ps.externalCodeSize + ps.externalDataSize + + ps.externalMediaSize + ps.externalObbSize; } return SIZE_INVALID; } @@ -685,19 +693,27 @@ public class ApplicationsState { synchronized (entry) { entry.sizeStale = false; entry.sizeLoadStart = 0; - long externalSize = getTotalExternalSize(stats); - long newSize = externalSize + getTotalInternalSize(stats); + long externalCodeSize = stats.externalCodeSize + + stats.externalObbSize; + long externalDataSize = stats.externalDataSize + + stats.externalMediaSize + stats.externalCacheSize; + long newSize = externalCodeSize + externalDataSize + + getTotalInternalSize(stats); if (entry.size != newSize || entry.cacheSize != stats.cacheSize || entry.codeSize != stats.codeSize || entry.dataSize != stats.dataSize || - entry.externalSize != externalSize) { + entry.externalCodeSize != externalCodeSize || + entry.externalDataSize != externalDataSize) { entry.size = newSize; entry.cacheSize = stats.cacheSize; entry.codeSize = stats.codeSize; entry.dataSize = stats.dataSize; - entry.externalSize = externalSize; + entry.externalCodeSize = externalCodeSize; + entry.externalDataSize = externalDataSize; entry.sizeStr = getSizeStr(entry.size); + entry.internalSizeStr = getSizeStr(getTotalInternalSize(stats)); + entry.externalSizeStr = getSizeStr(getTotalExternalSize(stats)); if (DEBUG) Log.i(TAG, "Set size of " + entry.label + " " + entry + ": " + entry.sizeStr); sizeChanged = true; diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java index 629bac5..ab46661 100644 --- a/src/com/android/settings/applications/InstalledAppDetails.java +++ b/src/com/android/settings/applications/InstalledAppDetails.java @@ -79,7 +79,7 @@ public class InstalledAppDetails extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener, ApplicationsState.Callbacks { private static final String TAG="InstalledAppDetails"; - static final boolean SUPPORT_DISABLE_APPS = false; + static final boolean SUPPORT_DISABLE_APPS = true; private static final boolean localLOGV = false; public static final String ARG_PACKAGE_NAME = "package"; @@ -103,7 +103,8 @@ public class InstalledAppDetails extends Fragment private TextView mTotalSize; private TextView mAppSize; private TextView mDataSize; - private TextView mExternalSize; + private TextView mExternalCodeSize; + private TextView mExternalDataSize; private ClearUserDataObserver mClearDataObserver; // Views related to cache info private TextView mCacheSize; @@ -118,7 +119,8 @@ public class InstalledAppDetails extends Fragment private boolean mHaveSizes = false; private long mLastCodeSize = -1; private long mLastDataSize = -1; - private long mLastExternalSize = -1; + private long mLastExternalCodeSize = -1; + private long mLastExternalDataSize = -1; private long mLastCacheSize = -1; private long mLastTotalSize = -1; @@ -282,7 +284,7 @@ public class InstalledAppDetails extends Fragment intent.setPackage(mAppEntry.info.packageName); List<ResolveInfo> homes = mPm.queryIntentActivities(intent, 0); if ((homes != null && homes.size() > 0) || - (mPackageInfo != null && + (mPackageInfo != null && mPackageInfo.signatures != null && sys.signatures[0].equals(mPackageInfo.signatures[0]))) { // Disable button for core system applications. mUninstallButton.setText(R.string.disable_text); @@ -331,7 +333,8 @@ 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); + mExternalCodeSize = (TextView)view.findViewById(R.id.external_code_size_text); + mExternalDataSize = (TextView)view.findViewById(R.id.external_data_size_text); // Get Control button panel View btnPanel = view.findViewById(R.id.control_buttons_panel); @@ -547,9 +550,13 @@ 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 (mLastExternalCodeSize != mAppEntry.externalCodeSize) { + mLastExternalCodeSize = mAppEntry.externalCodeSize; + mExternalCodeSize.setText(getSizeStr(mAppEntry.externalCodeSize)); + } + if (mLastExternalDataSize != mAppEntry.externalDataSize) { + mLastExternalDataSize = mAppEntry.externalDataSize; + mExternalDataSize.setText(getSizeStr(mAppEntry.externalDataSize)); } if (mLastCacheSize != mAppEntry.cacheSize) { mLastCacheSize = mAppEntry.cacheSize; @@ -831,7 +838,7 @@ public class InstalledAppDetails extends Fragment } else { if ((mAppEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { new DisableChanger(this, mAppEntry.info, mAppEntry.info.enabled ? - PackageManager.COMPONENT_ENABLED_STATE_DISABLED + PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER : PackageManager.COMPONENT_ENABLED_STATE_DEFAULT).execute((Object)null); } else { uninstallPkg(packageName); diff --git a/src/com/android/settings/applications/ManageApplications.java b/src/com/android/settings/applications/ManageApplications.java index 85db45e..554ece3 100644 --- a/src/com/android/settings/applications/ManageApplications.java +++ b/src/com/android/settings/applications/ManageApplications.java @@ -121,6 +121,10 @@ public class ManageApplications extends Fragment implements // constant value that can be used to check return code from sub activity. private static final int INSTALLED_APP_DETAILS = 1; + public static final int SIZE_TOTAL = 0; + public static final int SIZE_INTERNAL = 1; + public static final int SIZE_EXTERNAL = 2; + // sort order that can be changed through the menu can be sorted alphabetically // or size(descending) private static final int MENU_OPTIONS_BASE = 0; @@ -208,11 +212,21 @@ public class ManageApplications extends Fragment implements TextView disabled; CheckBox checkBox; - void updateSizeText(ManageApplications ma) { + void updateSizeText(ManageApplications ma, int whichSize) { if (DEBUG) Log.i(TAG, "updateSizeText of " + entry.label + " " + entry + ": " + entry.sizeStr); if (entry.sizeStr != null) { - appSize.setText(entry.sizeStr); + switch (whichSize) { + case SIZE_INTERNAL: + appSize.setText(entry.internalSizeStr); + break; + case SIZE_EXTERNAL: + appSize.setText(entry.externalSizeStr); + break; + default: + appSize.setText(entry.sizeStr); + break; + } } else if (entry.size == ApplicationsState.SIZE_INVALID) { appSize.setText(ma.mInvalidSizeStr); } @@ -237,6 +251,7 @@ public class ManageApplications extends Fragment implements private boolean mResumed; private int mLastFilterMode=-1, mLastSortMode=-1; private boolean mWaitingForData; + private int mWhichSize = SIZE_TOTAL; CharSequence mCurFilterPrefix; private Filter mFilter = new Filter() { @@ -296,12 +311,21 @@ public class ManageApplications extends Fragment implements if (DEBUG) Log.i(TAG, "Rebuilding app list..."); ApplicationsState.AppFilter filterObj; Comparator<AppEntry> comparatorObj; + boolean emulated = Environment.isExternalStorageEmulated(); + if (emulated) { + mWhichSize = SIZE_TOTAL; + } else { + mWhichSize = SIZE_INTERNAL; + } switch (mLastFilterMode) { case FILTER_APPS_THIRD_PARTY: filterObj = ApplicationsState.THIRD_PARTY_FILTER; break; case FILTER_APPS_SDCARD: filterObj = ApplicationsState.ON_SD_CARD_FILTER; + if (!emulated) { + mWhichSize = SIZE_EXTERNAL; + } break; default: filterObj = null; @@ -399,7 +423,7 @@ public class ManageApplications extends Fragment implements AppViewHolder holder = (AppViewHolder)mActive.get(i).getTag(); if (holder.entry.info.packageName.equals(packageName)) { synchronized (holder.entry) { - holder.updateSizeText(ManageApplications.this); + holder.updateSizeText(ManageApplications.this, mWhichSize); } if (holder.entry.info.packageName.equals(mCurrentPkgName) && mLastSortMode == SORT_ORDER_SIZE) { @@ -478,7 +502,7 @@ public class ManageApplications extends Fragment implements if (entry.icon != null) { holder.appIcon.setImageDrawable(entry.icon); } - holder.updateSizeText(ManageApplications.this); + holder.updateSizeText(ManageApplications.this, mWhichSize); if (InstalledAppDetails.SUPPORT_DISABLE_APPS) { holder.disabled.setVisibility(entry.info.enabled ? View.GONE : View.VISIBLE); } else { @@ -777,6 +801,11 @@ public class ManageApplications extends Fragment implements } catch (IllegalArgumentException e) { // use the old value of mFreeMem } + final int N = mApplicationsAdapter.getCount(); + for (int i=0; i<N; i++) { + ApplicationsState.AppEntry ae = mApplicationsAdapter.getAppEntry(i); + appStorage += ae.externalCodeSize + ae.externalDataSize; + } } else { if (!mLastShowedInternalStorage) { mLastShowedInternalStorage = true; @@ -790,10 +819,14 @@ public class ManageApplications extends Fragment implements mDataFileStats.getBlockSize(); } catch (IllegalArgumentException e) { } + final boolean emulatedStorage = Environment.isExternalStorageEmulated(); final int N = mApplicationsAdapter.getCount(); for (int i=0; i<N; i++) { ApplicationsState.AppEntry ae = mApplicationsAdapter.getAppEntry(i); appStorage += ae.codeSize + ae.dataSize; + if (emulatedStorage) { + appStorage += ae.externalCodeSize + ae.externalDataSize; + } } freeStorage += mApplicationsState.sumCacheSizes(); } |