diff --git a/res/values/colors.xml b/res/values/colors.xml
index 6879f9d7869..631fb194a7e 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -22,8 +22,8 @@
#333333
#77831A
#476093
- #793A7F
- #8E562A
+ #793A7F
+ #8E562A
#7C3030
#ff9a9a9a
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 80f3d571fcb..bb9360d67c4 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -313,8 +313,8 @@
Clear
Proxy port
-
- 8080
+
+ 8080
Bypass proxy for
@@ -1100,8 +1100,8 @@
Link speed
IP address
-
- 192.168.1.128
+
+ 192.168.1.128
EAP method
@@ -1181,20 +1181,20 @@
Please type a network prefix length between 0 and 32.
DNS 1
-
- 8.8.8.8
+
+ 8.8.8.8
DNS 2
-
- 4.4.4.4
+
+ 4.4.4.4
Gateway
-
- 192.168.1.1
+
+ 192.168.1.1
Network prefix length
-
- 24
+
+ 24
@@ -1591,7 +1591,7 @@
Media
- Downloads
+ Downloads
Pictures, Videos
@@ -1618,10 +1618,10 @@
Mount SD card
-
- Mount the USB storage
-
- Mount the SD card
+
+
+
+
Erase USB storage
@@ -1630,9 +1630,7 @@
Erases all data on the internal USB storage, such as music and photos
Erases all data on the SD card, such as music and photos
-
- Unavailable
-
+
\u0020(Read-only)
Unmount USB storage
diff --git a/res/xml/device_info_memory.xml b/res/xml/device_info_memory.xml
index aa36698840f..e905f39effe 100644
--- a/res/xml/device_info_memory.xml
+++ b/res/xml/device_info_memory.xml
@@ -17,54 +17,6 @@
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/com/android/settings/deviceinfo/Constants.java b/src/com/android/settings/deviceinfo/Constants.java
deleted file mode 100644
index 9f494797d31..00000000000
--- a/src/com/android/settings/deviceinfo/Constants.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.settings.deviceinfo;
-
-import android.os.Environment;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Some of the constants used in this package
- */
-class Constants {
- static final int MEDIA_INDEX = 0;
- static final int DOWNLOADS_INDEX = 1;
- static final int PIC_VIDEO_INDEX = 2;
- static final int MUSIC_INDEX = 3;
- static final int MEDIA_APPS_DATA_INDEX = 4;
- static final int MEDIA_MISC_INDEX = 5;
- static final int NUM_MEDIA_DIRS_TRACKED = MEDIA_MISC_INDEX + 1;
-
- static class MediaDirectory {
- final String[] mDirPaths;
- final String mKey;
- final String mPreferenceName;
- MediaDirectory(String pref, String debugInfo, String... paths) {
- mDirPaths = paths;
- mKey = debugInfo;
- mPreferenceName = pref;
- }
- }
- static final ArrayList mMediaDirs = new ArrayList();
- static final List ExclusionTargetsForMiscFiles = new ArrayList();
- static {
- mMediaDirs.add(MEDIA_INDEX,
- new MediaDirectory(null,
- "/sdcard",
- Environment.getExternalStorageDirectory().getAbsolutePath()));
- mMediaDirs.add(DOWNLOADS_INDEX,
- new MediaDirectory("memory_internal_downloads",
- "/sdcard/download",
- Environment.getExternalStoragePublicDirectory(
- Environment.DIRECTORY_DOWNLOADS).getAbsolutePath()));
- mMediaDirs.add(PIC_VIDEO_INDEX,
- new MediaDirectory("memory_internal_dcim",
- "/sdcard/pic_video",
- Environment.getExternalStoragePublicDirectory(
- Environment.DIRECTORY_DCIM).getAbsolutePath(),
- Environment.getExternalStoragePublicDirectory(
- Environment.DIRECTORY_MOVIES).getAbsolutePath(),
- Environment.getExternalStoragePublicDirectory(
- Environment.DIRECTORY_PICTURES).getAbsolutePath()));
- mMediaDirs.add(MUSIC_INDEX,
- new MediaDirectory("memory_internal_music",
- "/sdcard/audio",
- Environment.getExternalStoragePublicDirectory(
- Environment.DIRECTORY_MUSIC).getAbsolutePath(),
- Environment.getExternalStoragePublicDirectory(
- Environment.DIRECTORY_ALARMS).getAbsolutePath(),
- Environment.getExternalStoragePublicDirectory(
- Environment.DIRECTORY_NOTIFICATIONS).getAbsolutePath(),
- Environment.getExternalStoragePublicDirectory(
- Environment.DIRECTORY_RINGTONES).getAbsolutePath(),
- Environment.getExternalStoragePublicDirectory(
- Environment.DIRECTORY_PODCASTS).getAbsolutePath()));
- mMediaDirs.add(MEDIA_APPS_DATA_INDEX,
- new MediaDirectory(null,
- "/sdcard/Android",
- Environment.getExternalStorageAndroidDataDir().getAbsolutePath()));
- mMediaDirs.add(MEDIA_MISC_INDEX,
- new MediaDirectory("memory_internal_media_misc",
- "misc on /sdcard",
- "not relevant"));
- // prepare a lit of strings representing dirpaths that should be skipped while looking
- // for 'other' files
- for (int j = 0; j < Constants.NUM_MEDIA_DIRS_TRACKED - 1; j++) {
- String[] dirs = Constants.mMediaDirs.get(j).mDirPaths;
- int len = dirs.length;
- if (len > 0) {
- for (int k = 0; k < len; k++) {
- ExclusionTargetsForMiscFiles.add(dirs[k]);
- }
- }
- // also add /sdcard/Android
- ExclusionTargetsForMiscFiles.add(
- Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android");
- }
- }
-}
diff --git a/src/com/android/settings/deviceinfo/Memory.java b/src/com/android/settings/deviceinfo/Memory.java
index 1e10c58ac4d..955e57802b2 100644
--- a/src/com/android/settings/deviceinfo/Memory.java
+++ b/src/com/android/settings/deviceinfo/Memory.java
@@ -16,140 +16,52 @@
package com.android.settings.deviceinfo;
-import com.android.settings.R;
-import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.deviceinfo.MemoryMeasurement.MeasurementReceiver;
-
-import android.app.ActivityManager;
import android.app.AlertDialog;
import android.app.Dialog;
-import android.app.DownloadManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
+import android.content.DialogInterface.OnCancelListener;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.DialogInterface.OnCancelListener;
-import android.content.pm.ApplicationInfo;
import android.content.res.Resources;
-import android.graphics.drawable.ShapeDrawable;
-import android.graphics.drawable.shapes.RectShape;
import android.os.Bundle;
import android.os.Environment;
-import android.os.Handler;
import android.os.IBinder;
-import android.os.Message;
+import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.storage.IMountService;
import android.os.storage.StorageEventListener;
import android.os.storage.StorageManager;
+import android.os.storage.StorageVolume;
import android.preference.Preference;
-import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
-import android.text.format.Formatter;
import android.util.Log;
import android.widget.Toast;
-import java.util.List;
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
-public class Memory extends SettingsPreferenceFragment implements OnCancelListener,
- MeasurementReceiver {
+public class Memory extends SettingsPreferenceFragment implements OnCancelListener {
private static final String TAG = "MemorySettings";
- private static final String MEMORY_SD_SIZE = "memory_sd_size";
-
- private static final String MEMORY_SD_AVAIL = "memory_sd_avail";
-
- private static final String MEMORY_SD_MOUNT_TOGGLE = "memory_sd_mount_toggle";
-
- private static final String MEMORY_SD_FORMAT = "memory_sd_format";
-
- private static final String MEMORY_SD_GROUP = "memory_sd";
-
- private static final String MEMORY_INTERNAL_SIZE = "memory_internal_size";
-
- private static final String MEMORY_INTERNAL_AVAIL = "memory_internal_avail";
-
- private static final String MEMORY_INTERNAL_APPS = "memory_internal_apps";
-
- private static final String MEMORY_INTERNAL_CHART = "memory_internal_chart";
-
private static final int DLG_CONFIRM_UNMOUNT = 1;
private static final int DLG_ERROR_UNMOUNT = 2;
- private Resources mRes;
+ private Resources mResources;
- // External storage preferences
- private Preference mSdSize;
- private Preference mSdAvail;
- private Preference mSdMountToggle;
- private Preference mSdFormat;
- private PreferenceGroup mSdMountPreferenceGroup;
-
- // Internal storage preferences
- private Preference mInternalSize;
- private Preference mInternalAvail;
- private Preference mInternalAppsUsage;
- private final Preference[] mMediaPreferences = new Preference[Constants.NUM_MEDIA_DIRS_TRACKED];
- private UsageBarPreference mInternalUsageChart;
-
- // Internal storage chart colors
- private int mInternalAppsColor;
- private int mInternalAvailColor;
- private int mInternalUsedColor;
-
- boolean mSdMountToggleAdded = true;
+ // The mountToggle Preference that has been clicked.
+ // The click event will be discarded if this value is not null. Reset to null after (un)mount.
+ private Preference mClickedMountToggle;
+ private String mClickedMountPoint;
// Access using getMountService()
private IMountService mMountService = null;
private StorageManager mStorageManager = null;
- // Updates the memory usage bar graph.
- private static final int MSG_UI_UPDATE_INTERNAL_APPROXIMATE = 1;
-
- // Updates the memory usage bar graph.
- private static final int MSG_UI_UPDATE_INTERNAL_EXACT = 2;
-
- // Updates the memory usage stats for external.
- private static final int MSG_UI_UPDATE_EXTERNAL_APPROXIMATE = 3;
-
- private Handler mUpdateHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case MSG_UI_UPDATE_INTERNAL_APPROXIMATE: {
- Bundle bundle = msg.getData();
- final long totalSize = bundle.getLong(MemoryMeasurement.TOTAL_SIZE);
- final long availSize = bundle.getLong(MemoryMeasurement.AVAIL_SIZE);
- updateUiApproximate(totalSize, availSize);
- break;
- }
- case MSG_UI_UPDATE_INTERNAL_EXACT: {
- Bundle bundle = msg.getData();
- final long totalSize = bundle.getLong(MemoryMeasurement.TOTAL_SIZE);
- final long availSize = bundle.getLong(MemoryMeasurement.AVAIL_SIZE);
- final long appsUsed = bundle.getLong(MemoryMeasurement.APPS_USED);
- final long[] mediaSizes = new long[Constants.NUM_MEDIA_DIRS_TRACKED];
- for (int i = 0; i < Constants.NUM_MEDIA_DIRS_TRACKED; i++) {
- mediaSizes[i] = bundle.getLong(Constants.mMediaDirs.get(i).mKey);
- }
- updateUiExact(totalSize, availSize, appsUsed, mediaSizes);
- break;
- }
- case MSG_UI_UPDATE_EXTERNAL_APPROXIMATE: {
- Bundle bundle = msg.getData();
- final long totalSize = bundle.getLong(MemoryMeasurement.TOTAL_SIZE);
- final long availSize = bundle.getLong(MemoryMeasurement.AVAIL_SIZE);
- updateExternalStorage(totalSize, availSize);
- break;
- }
- }
- }
- };
-
- private MemoryMeasurement mMeasurement;
+ private StorageVolumePreferenceCategory[] mStorageVolumePreferenceCategories;
@Override
public void onCreate(Bundle icicle) {
@@ -162,84 +74,39 @@ public class Memory extends SettingsPreferenceFragment implements OnCancelListen
addPreferencesFromResource(R.xml.device_info_memory);
- mRes = getResources();
- mSdSize = findPreference(MEMORY_SD_SIZE);
- mSdAvail = findPreference(MEMORY_SD_AVAIL);
- mSdMountToggle = findPreference(MEMORY_SD_MOUNT_TOGGLE);
- mSdFormat = findPreference(MEMORY_SD_FORMAT);
- mSdMountPreferenceGroup = (PreferenceGroup)findPreference(MEMORY_SD_GROUP);
+ mResources = getResources();
- if (Environment.isExternalStorageEmulated()) {
- getPreferenceScreen().removePreference(mSdMountPreferenceGroup);
- }
-
- mInternalSize = findPreference(MEMORY_INTERNAL_SIZE);
- mInternalAppsColor = mRes.getColor(R.color.memory_apps_usage);
- mInternalUsedColor = android.graphics.Color.GRAY;
- mInternalAvailColor = mRes.getColor(R.color.memory_avail);
- final int buttonWidth = (int) mRes.getDimension(R.dimen.device_memory_usage_button_width);
- final int buttonHeight = (int) mRes.getDimension(R.dimen.device_memory_usage_button_height);
-
- // total available space
- mInternalAvail = findPreference(MEMORY_INTERNAL_AVAIL);
- mInternalAvail.setIcon(createRectShape(buttonHeight, buttonWidth, mInternalAvailColor));
-
- // used by apps
- mInternalAppsUsage = findPreference(MEMORY_INTERNAL_APPS);
- mInternalAppsUsage.setIcon(createRectShape(buttonHeight, buttonWidth, mInternalAppsColor));
-
- // space used by individual major directories on /sdcard
- for (int i = 0; i < Constants.NUM_MEDIA_DIRS_TRACKED; i++) {
- // nothing to be displayed for certain entries in Constants.mMediaDirs
- if (Constants.mMediaDirs.get(i).mPreferenceName == null) {
- continue;
+ try {
+ IMountService mountService = IMountService.Stub.asInterface(ServiceManager
+ .getService("mount"));
+ Parcelable[] volumes = mountService.getVolumeList();
+ int length = volumes.length;
+ mStorageVolumePreferenceCategories = new StorageVolumePreferenceCategory[length];
+ for (int i = 0; i < length; i++) {
+ StorageVolume storageVolume = (StorageVolume) volumes[i];
+ StorageVolumePreferenceCategory storagePreferenceCategory =
+ new StorageVolumePreferenceCategory(getActivity(), mResources, storageVolume,
+ i == 0); // The first volume is the primary volume
+ mStorageVolumePreferenceCategories[i] = storagePreferenceCategory;
+ getPreferenceScreen().addPreference(storagePreferenceCategory);
+ storagePreferenceCategory.init();
}
- mMediaPreferences[i] = findPreference(Constants.mMediaDirs.get(i).mPreferenceName);
- int color = 0;
- switch (i) {
- case Constants.DOWNLOADS_INDEX:
- color = mRes.getColor(R.color.memory_downloads);
- break;
- case Constants.PIC_VIDEO_INDEX:
- color = mRes.getColor(R.color.memory_video);
- break;
- case Constants.MUSIC_INDEX:
- color = mRes.getColor(R.color.memory_audio);
- break;
- case Constants.MEDIA_MISC_INDEX:
- color = mRes.getColor(R.color.memory_misc);
- break;
- }
- mMediaPreferences[i].setIcon(createRectShape(buttonHeight, buttonWidth, color));
+ } catch (Exception e) {
+ Log.e(TAG, "couldn't talk to MountService", e);
}
- mInternalUsageChart = (UsageBarPreference) findPreference(MEMORY_INTERNAL_CHART);
-
- mMeasurement = MemoryMeasurement.getInstance(getActivity());
- mMeasurement.setReceiver(this);
- }
-
- private ShapeDrawable createRectShape(int height, int width, int color) {
- ShapeDrawable shape = new ShapeDrawable(new RectShape());
- shape.setIntrinsicHeight(height);
- shape.setIntrinsicWidth(width);
- shape.getPaint().setColor(color);
- return shape;
}
@Override
public void onResume() {
super.onResume();
- mMeasurement.setReceiver(this);
IntentFilter intentFilter = new IntentFilter(Intent.ACTION_MEDIA_SCANNER_STARTED);
intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
intentFilter.addDataScheme("file");
- getActivity().registerReceiver(mReceiver, intentFilter);
+ getActivity().registerReceiver(mMediaScannerReceiver, intentFilter);
- mMeasurement.invalidate();
- if (!Environment.isExternalStorageEmulated()) {
- mMeasurement.measureExternal();
+ for (int i = 0; i < mStorageVolumePreferenceCategories.length; i++) {
+ mStorageVolumePreferenceCategories[i].onResume();
}
- mMeasurement.measureInternal();
}
StorageEventListener mStorageListener = new StorageEventListener() {
@@ -248,8 +115,12 @@ public class Memory extends SettingsPreferenceFragment implements OnCancelListen
Log.i(TAG, "Received storage state changed notification that " +
path + " changed state from " + oldState +
" to " + newState);
- if (!Environment.isExternalStorageEmulated()) {
- mMeasurement.measureExternal();
+ for (int i = 0; i < mStorageVolumePreferenceCategories.length; i++) {
+ StorageVolumePreferenceCategory svpc = mStorageVolumePreferenceCategories[i];
+ if (path.equals(svpc.getMountPoint())) {
+ svpc.onStorageStateChanged();
+ break;
+ }
}
}
};
@@ -257,8 +128,10 @@ public class Memory extends SettingsPreferenceFragment implements OnCancelListen
@Override
public void onPause() {
super.onPause();
- getActivity().unregisterReceiver(mReceiver);
- mMeasurement.cleanUp();
+ getActivity().unregisterReceiver(mMediaScannerReceiver);
+ for (int i = 0; i < mStorageVolumePreferenceCategories.length; i++) {
+ mStorageVolumePreferenceCategories[i].onPause();
+ }
}
@Override
@@ -283,60 +156,38 @@ public class Memory extends SettingsPreferenceFragment implements OnCancelListen
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
- if (preference == mSdMountToggle) {
- String status = Environment.getExternalStorageState();
- if (status.equals(Environment.MEDIA_MOUNTED)) {
- unmount();
- } else {
- mount();
+ for (int i = 0; i < mStorageVolumePreferenceCategories.length; i++) {
+ StorageVolumePreferenceCategory svpc = mStorageVolumePreferenceCategories[i];
+ Intent intent = svpc.intentForClick(preference);
+ if (intent != null) {
+ startActivity(intent);
+ return true;
}
- return true;
- } else if (preference == mSdFormat) {
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setClass(getActivity(), com.android.settings.MediaFormat.class);
- startActivity(intent);
- return true;
- } else if (preference == mInternalAppsUsage) {
- Intent intent = new Intent(Intent.ACTION_MANAGE_PACKAGE_STORAGE);
- intent.setClass(getActivity(),
- com.android.settings.Settings.ManageApplicationsActivity.class);
- startActivity(intent);
- return true;
- } else if (preference == mMediaPreferences[Constants.DOWNLOADS_INDEX]) {
- Intent intent = new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS)
- .putExtra(DownloadManager.INTENT_EXTRAS_SORT_BY_SIZE, true);
- startActivity(intent);
- return true;
- } else if (preference == mMediaPreferences[Constants.MUSIC_INDEX]) {
- Intent intent = new Intent("android.intent.action.GET_CONTENT");
- intent.setType("audio/mp3");
- startActivity(intent);
- return true;
- } else if (preference == mMediaPreferences[Constants.PIC_VIDEO_INDEX]) {
- Intent intent = new Intent("android.intent.action.GET_CONTENT");
- intent.setType("image/jpeg");
- startActivity(intent);
- return true;
- } else if (preference == mMediaPreferences[Constants.MEDIA_MISC_INDEX]) {
- Context context = getActivity().getApplicationContext();
- if (MemoryMeasurement.getInstance(context).isSizeOfMiscCategoryNonZero()) {
- startActivity(new Intent(context, MiscFilesHandler.class));
+
+ boolean mountToggleClicked = svpc.mountToggleClicked(preference);
+ if (mountToggleClicked && mClickedMountToggle == null) {
+ mClickedMountToggle = preference;
+ mClickedMountPoint = svpc.getMountPoint();
+ String state = svpc.getStorageVolumeState();
+ if (state.equals(Environment.MEDIA_MOUNTED) ||
+ state.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) {
+ unmount();
+ } else {
+ mount();
+ }
+ return true;
}
- return true;
}
return false;
}
- private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ private final BroadcastReceiver mMediaScannerReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- mMeasurement.invalidate();
-
- if (!Environment.isExternalStorageEmulated()) {
- mMeasurement.measureExternal();
+ for (int i = 0; i < mStorageVolumePreferenceCategories.length; i++) {
+ mStorageVolumePreferenceCategories[i].onMediaScannerFinished();
}
- mMeasurement.measureInternal();
}
};
@@ -348,7 +199,7 @@ public class Memory extends SettingsPreferenceFragment implements OnCancelListen
.setTitle(R.string.dlg_confirm_unmount_title)
.setPositiveButton(R.string.dlg_ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
- doUnmount(true);
+ doUnmount();
}})
.setNegativeButton(R.string.cancel, null)
.setMessage(R.string.dlg_confirm_unmount_text)
@@ -368,28 +219,27 @@ public class Memory extends SettingsPreferenceFragment implements OnCancelListen
super.showDialog(id);
switch (id) {
- case DLG_CONFIRM_UNMOUNT:
- case DLG_ERROR_UNMOUNT:
- setOnCancelListener(this);
- break;
+ case DLG_CONFIRM_UNMOUNT:
+ case DLG_ERROR_UNMOUNT:
+ setOnCancelListener(this);
+ break;
}
}
- private void doUnmount(boolean force) {
+ private void doUnmount() {
// Present a toast here
Toast.makeText(getActivity(), R.string.unmount_inform_text, Toast.LENGTH_SHORT).show();
IMountService mountService = getMountService();
- String extStoragePath = Environment.getExternalStorageDirectory().toString();
try {
- mSdMountToggle.setEnabled(false);
- mSdMountToggle.setTitle(mRes.getString(R.string.sd_ejecting_title));
- mSdMountToggle.setSummary(mRes.getString(R.string.sd_ejecting_summary));
- mountService.unmountVolume(extStoragePath, force);
+ mClickedMountToggle.setEnabled(false);
+ mClickedMountToggle.setTitle(mResources.getString(R.string.sd_ejecting_title));
+ mClickedMountToggle.setSummary(mResources.getString(R.string.sd_ejecting_summary));
+ mountService.unmountVolume(mClickedMountPoint, true);
} catch (RemoteException e) {
- // Informative dialog to user that
- // unmount failed.
+ // Informative dialog to user that unmount failed.
showDialogInner(DLG_ERROR_UNMOUNT);
}
+ mClickedMountToggle = null;
}
private void showDialogInner(int id) {
@@ -398,17 +248,21 @@ public class Memory extends SettingsPreferenceFragment implements OnCancelListen
}
private boolean hasAppsAccessingStorage() throws RemoteException {
- String extStoragePath = Environment.getExternalStorageDirectory().toString();
IMountService mountService = getMountService();
- int stUsers[] = mountService.getStorageUsers(extStoragePath);
+ int stUsers[] = mountService.getStorageUsers(mClickedMountPoint);
if (stUsers != null && stUsers.length > 0) {
return true;
}
+ // TODO FIXME Parameterize with mountPoint and uncomment.
+ // On HC-MR2, no apps can be installed on sd and the emulated internal storage is not
+ // removable: application cannot interfere with unmount
+ /*
ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
List list = am.getRunningExternalApplications();
if (list != null && list.size() > 0) {
return true;
}
+ */
return false;
}
@@ -419,12 +273,13 @@ public class Memory extends SettingsPreferenceFragment implements OnCancelListen
// Present dialog to user
showDialogInner(DLG_CONFIRM_UNMOUNT);
} else {
- doUnmount(true);
+ doUnmount();
}
} catch (RemoteException e) {
// Very unlikely. But present an error dialog anyway
Log.e(TAG, "Is MountService running?");
showDialogInner(DLG_ERROR_UNMOUNT);
+ mClickedMountToggle = null;
}
}
@@ -432,151 +287,17 @@ public class Memory extends SettingsPreferenceFragment implements OnCancelListen
IMountService mountService = getMountService();
try {
if (mountService != null) {
- mountService.mountVolume(Environment.getExternalStorageDirectory().toString());
+ mountService.mountVolume(mClickedMountPoint);
} else {
Log.e(TAG, "Mount service is null, can't mount");
}
} catch (RemoteException ex) {
+ // Not much can be done
}
- }
-
- private void updateUiExact(long totalSize, long availSize, long appsSize, long[] mediaSizes) {
- // There are other things that can take up storage, but we didn't measure it.
- // add that unaccounted-for-usage to Apps Usage
- long appsPlusRemaining = totalSize - availSize - mediaSizes[Constants.DOWNLOADS_INDEX] -
- mediaSizes[Constants.PIC_VIDEO_INDEX] - mediaSizes[Constants.MUSIC_INDEX] -
- mediaSizes[Constants.MEDIA_MISC_INDEX];
- mInternalSize.setSummary(formatSize(totalSize));
- mInternalAvail.setSummary(formatSize(availSize));
- mInternalAppsUsage.setSummary(formatSize(appsPlusRemaining));
-
- mInternalUsageChart.clear();
- mInternalUsageChart.addEntry(appsPlusRemaining / (float) totalSize, mInternalAppsColor);
-
- for (int i = 0; i < Constants.NUM_MEDIA_DIRS_TRACKED; i++) {
- if (Constants.mMediaDirs.get(i).mPreferenceName == null) {
- continue;
- }
- this.mMediaPreferences[i].setSummary(formatSize(mediaSizes[i]));
- // don't add entry to color chart for media usage and for zero-sized dirs
- if (i != Constants.MEDIA_INDEX && mediaSizes[i] > 0) {
- int color = 0;
- switch (i) {
- case Constants.DOWNLOADS_INDEX:
- color = mRes.getColor(R.color.memory_downloads);
- break;
- case Constants.PIC_VIDEO_INDEX:
- color = mRes.getColor(R.color.memory_video);
- break;
- case Constants.MUSIC_INDEX:
- color = mRes.getColor(R.color.memory_audio);
- break;
- case Constants.MEDIA_MISC_INDEX:
- color = mRes.getColor(R.color.memory_misc);
- break;
- }
- mInternalUsageChart.addEntry(mediaSizes[i] / (float) totalSize, color);
- }
- }
- mInternalUsageChart.addEntry(availSize / (float) totalSize, mInternalAvailColor);
- mInternalUsageChart.commit();
- }
-
- private void updateUiApproximate(long totalSize, long availSize) {
- mInternalSize.setSummary(formatSize(totalSize));
- mInternalAvail.setSummary(formatSize(availSize));
-
- final long usedSize = totalSize - availSize;
-
- mInternalUsageChart.clear();
- mInternalUsageChart.addEntry(usedSize / (float) totalSize, mInternalUsedColor);
- mInternalUsageChart.commit();
- }
-
- private void updateExternalStorage(long totalSize, long availSize) {
- String status = Environment.getExternalStorageState();
- String readOnly = "";
- if (status.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) {
- status = Environment.MEDIA_MOUNTED;
- readOnly = mRes.getString(R.string.read_only);
- }
-
- if (status.equals(Environment.MEDIA_MOUNTED)) {
- if (!Environment.isExternalStorageRemovable()) {
- // This device has built-in storage that is not removable.
- // There is no reason for the user to unmount it.
- if (mSdMountToggleAdded) {
- mSdMountPreferenceGroup.removePreference(mSdMountToggle);
- mSdMountToggleAdded = false;
- }
- }
- try {
- mSdSize.setSummary(formatSize(totalSize));
- mSdAvail.setSummary(formatSize(availSize) + readOnly);
-
- mSdMountToggle.setEnabled(true);
- mSdMountToggle.setTitle(mRes.getString(R.string.sd_eject));
- mSdMountToggle.setSummary(mRes.getString(R.string.sd_eject_summary));
-
- } catch (IllegalArgumentException e) {
- // this can occur if the SD card is removed, but we haven't
- // received the
- // ACTION_MEDIA_REMOVED Intent yet.
- status = Environment.MEDIA_REMOVED;
- }
- } else {
- mSdSize.setSummary(mRes.getString(R.string.sd_unavailable));
- mSdAvail.setSummary(mRes.getString(R.string.sd_unavailable));
-
- if (!Environment.isExternalStorageRemovable()) {
- if (status.equals(Environment.MEDIA_UNMOUNTED)) {
- if (!mSdMountToggleAdded) {
- mSdMountPreferenceGroup.addPreference(mSdMountToggle);
- mSdMountToggleAdded = true;
- }
- }
- }
-
- if (status.equals(Environment.MEDIA_UNMOUNTED) || status.equals(Environment.MEDIA_NOFS)
- || status.equals(Environment.MEDIA_UNMOUNTABLE)) {
- mSdMountToggle.setEnabled(true);
- mSdMountToggle.setTitle(mRes.getString(R.string.sd_mount));
- mSdMountToggle.setSummary(mRes.getString(R.string.sd_mount_summary));
- } else {
- mSdMountToggle.setEnabled(false);
- mSdMountToggle.setTitle(mRes.getString(R.string.sd_mount));
- mSdMountToggle.setSummary(mRes.getString(R.string.sd_insert_summary));
- }
- }
- }
-
- private String formatSize(long size) {
- return Formatter.formatFileSize(getActivity(), size);
+ mClickedMountToggle = null;
}
public void onCancel(DialogInterface dialog) {
- // TODO: Is this really required?
- // finish();
- }
-
- @Override
- public void updateApproximateExternal(Bundle bundle) {
- final Message message = mUpdateHandler.obtainMessage(MSG_UI_UPDATE_EXTERNAL_APPROXIMATE);
- message.setData(bundle);
- mUpdateHandler.sendMessage(message);
- }
-
- @Override
- public void updateApproximateInternal(Bundle bundle) {
- final Message message = mUpdateHandler.obtainMessage(MSG_UI_UPDATE_INTERNAL_APPROXIMATE);
- message.setData(bundle);
- mUpdateHandler.sendMessage(message);
- }
-
- @Override
- public void updateExactInternal(Bundle bundle) {
- final Message message = mUpdateHandler.obtainMessage(MSG_UI_UPDATE_INTERNAL_EXACT);
- message.setData(bundle);
- mUpdateHandler.sendMessage(message);
+ mClickedMountToggle = null;
}
}
diff --git a/src/com/android/settings/deviceinfo/MemoryMeasurement.java b/src/com/android/settings/deviceinfo/MemoryMeasurement.java
deleted file mode 100644
index 1b42bc10df2..00000000000
--- a/src/com/android/settings/deviceinfo/MemoryMeasurement.java
+++ /dev/null
@@ -1,505 +0,0 @@
-package com.android.settings.deviceinfo;
-
-import com.android.internal.app.IMediaContainerService;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.IPackageStatsObserver;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageStats;
-import android.os.Bundle;
-import android.os.Environment;
-import android.os.Handler;
-import android.os.HandlerThread;
-import android.os.IBinder;
-import android.os.Looper;
-import android.os.Message;
-import android.os.StatFs;
-import android.util.Log;
-
-import java.io.File;
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Measure the memory for various systems.
- *
- * TODO: This class should ideally have less knowledge about what the context
- * it's measuring is. In the future, reduce the amount of stuff it needs to
- * know about by just keeping an array of measurement types of the following
- * properties:
- *
- * Filesystem stats (using StatFs)
- * Directory measurements (using DefaultContainerService.measureDir)
- * Application measurements (using PackageManager)
- *
- * Then the calling application would just specify the type and an argument.
- * This class would keep track of it while the calling application would
- * decide on how to use it.
- */
-public class MemoryMeasurement {
- private static final String TAG = "MemorySettings";
- private static final boolean LOCAL_LOGV = true;
- static final boolean LOGV = LOCAL_LOGV && Log.isLoggable(TAG, Log.VERBOSE);
-
- public static final String TOTAL_SIZE = "total_size";
-
- public static final String AVAIL_SIZE = "avail_size";
-
- public static final String APPS_USED = "apps_used";
-
- private long[] mMediaSizes = new long[Constants.NUM_MEDIA_DIRS_TRACKED];
-
- private static final String DEFAULT_CONTAINER_PACKAGE = "com.android.defcontainer";
-
- private static final ComponentName DEFAULT_CONTAINER_COMPONENT = new ComponentName(
- DEFAULT_CONTAINER_PACKAGE, "com.android.defcontainer.DefaultContainerService");
-
- private final MeasurementHandler mHandler;
-
- private static volatile MemoryMeasurement sInstance;
-
- private volatile WeakReference mReceiver;
-
- // Internal memory fields
- private long mInternalTotalSize;
- private long mInternalAvailSize;
- private long mInternalAppsSize;
-
- // External memory fields
- private long mExternalTotalSize;
-
- private long mExternalAvailSize;
- List mFileInfoForMisc;
-
- private MemoryMeasurement(Context context) {
- // Start the thread that will measure the disk usage.
- final HandlerThread t = new HandlerThread("MemoryMeasurement");
- t.start();
- mHandler = new MeasurementHandler(context, t.getLooper());
- }
-
- /**
- * Get the singleton of the MemoryMeasurement class. The application
- * context is used to avoid leaking activities.
- */
- public static MemoryMeasurement getInstance(Context context) {
- if (sInstance == null) {
- synchronized (MemoryMeasurement.class) {
- if (sInstance == null) {
- sInstance = new MemoryMeasurement(context.getApplicationContext());
- }
- }
- }
-
- return sInstance;
- }
-
- public void setReceiver(MeasurementReceiver receiver) {
- if (mReceiver == null || mReceiver.get() == null) {
- mReceiver = new WeakReference(receiver);
- }
- }
-
- public void measureExternal() {
- if (!mHandler.hasMessages(MeasurementHandler.MSG_MEASURE_EXTERNAL)) {
- mHandler.sendEmptyMessage(MeasurementHandler.MSG_MEASURE_EXTERNAL);
- }
- }
-
- public void measureInternal() {
- if (!mHandler.hasMessages(MeasurementHandler.MSG_MEASURE_INTERNAL)) {
- mHandler.sendEmptyMessage(MeasurementHandler.MSG_MEASURE_INTERNAL);
- }
- }
-
- public void cleanUp() {
- mReceiver = null;
- mHandler.cleanUp();
- }
-
- private void sendInternalApproximateUpdate() {
- MeasurementReceiver receiver = (mReceiver != null) ? mReceiver.get() : null;
- if (receiver == null) {
- return;
- }
-
- Bundle bundle = new Bundle();
- bundle.putLong(TOTAL_SIZE, mInternalTotalSize);
- bundle.putLong(AVAIL_SIZE, mInternalAvailSize);
-
- receiver.updateApproximateInternal(bundle);
- }
-
- private void sendInternalExactUpdate() {
- MeasurementReceiver receiver = (mReceiver != null) ? mReceiver.get() : null;
- if (receiver == null) {
- if (LOGV) {
- Log.i(TAG, "measurements dropped because receiver is null! wasted effort");
- }
- return;
- }
-
- Bundle bundle = new Bundle();
- bundle.putLong(TOTAL_SIZE, mInternalTotalSize);
- bundle.putLong(AVAIL_SIZE, mInternalAvailSize);
- bundle.putLong(APPS_USED, mInternalAppsSize);
- for (int i = 0; i < Constants.NUM_MEDIA_DIRS_TRACKED; i++) {
- bundle.putLong(Constants.mMediaDirs.get(i).mKey, mMediaSizes[i]);
- }
-
- receiver.updateExactInternal(bundle);
- }
-
- private void sendExternalApproximateUpdate() {
- MeasurementReceiver receiver = (mReceiver != null) ? mReceiver.get() : null;
- if (receiver == null) {
- return;
- }
-
- Bundle bundle = new Bundle();
- bundle.putLong(TOTAL_SIZE, mExternalTotalSize);
- bundle.putLong(AVAIL_SIZE, mExternalAvailSize);
-
- receiver.updateApproximateExternal(bundle);
- }
-
- public interface MeasurementReceiver {
- public void updateApproximateInternal(Bundle bundle);
-
- public void updateExactInternal(Bundle bundle);
-
- public void updateApproximateExternal(Bundle bundle);
- }
-
- private class MeasurementHandler extends Handler {
- public static final int MSG_MEASURE_INTERNAL = 1;
-
- public static final int MSG_MEASURE_EXTERNAL = 2;
-
- public static final int MSG_CONNECTED = 3;
-
- public static final int MSG_DISCONNECT = 4;
-
- public static final int MSG_COMPLETED = 5;
-
- public static final int MSG_INVALIDATE = 6;
-
- private Object mLock = new Object();
-
- private IMediaContainerService mDefaultContainer;
-
- private volatile boolean mBound = false;
-
- private volatile boolean mMeasured = false;
-
- private StatsObserver mStatsObserver;
-
- private final WeakReference mContext;
-
- final private ServiceConnection mDefContainerConn = new ServiceConnection() {
- public void onServiceConnected(ComponentName name, IBinder service) {
- final IMediaContainerService imcs = IMediaContainerService.Stub
- .asInterface(service);
- mDefaultContainer = imcs;
- mBound = true;
- sendMessage(obtainMessage(MSG_CONNECTED, imcs));
- }
-
- public void onServiceDisconnected(ComponentName name) {
- mBound = false;
- removeMessages(MSG_CONNECTED);
- }
- };
-
- public MeasurementHandler(Context context, Looper looper) {
- super(looper);
- mContext = new WeakReference(context);
- }
-
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case MSG_MEASURE_EXTERNAL: {
- if (mMeasured) {
- sendExternalApproximateUpdate();
- break;
- }
-
- measureApproximateExternalStorage();
- break;
- }
- case MSG_MEASURE_INTERNAL: {
- if (mMeasured) {
- sendInternalExactUpdate();
- break;
- }
-
- final Context context = (mContext != null) ? mContext.get() : null;
- if (context == null) {
- return;
- }
-
- measureApproximateInternalStorage();
-
- synchronized (mLock) {
- if (mBound) {
- removeMessages(MSG_DISCONNECT);
- sendMessage(obtainMessage(MSG_CONNECTED, mDefaultContainer));
- } else {
- Intent service = new Intent().setComponent(DEFAULT_CONTAINER_COMPONENT);
- context.bindService(service, mDefContainerConn,
- Context.BIND_AUTO_CREATE);
- }
- }
- break;
- }
- case MSG_CONNECTED: {
- IMediaContainerService imcs = (IMediaContainerService) msg.obj;
- measureExactInternalStorage(imcs);
- break;
- }
- case MSG_DISCONNECT: {
- synchronized (mLock) {
- if (mBound) {
- final Context context = (mContext != null) ? mContext.get() : null;
- if (context == null) {
- return;
- }
-
- mBound = false;
- context.unbindService(mDefContainerConn);
- }
- }
- break;
- }
- case MSG_COMPLETED: {
- mMeasured = true;
- sendInternalExactUpdate();
- break;
- }
- case MSG_INVALIDATE: {
- mMeasured = false;
- break;
- }
- }
- }
-
- public void cleanUp() {
- removeMessages(MSG_MEASURE_INTERNAL);
- removeMessages(MSG_MEASURE_EXTERNAL);
-
- sendEmptyMessage(MSG_DISCONNECT);
- }
-
- /**
- * Request measurement of each package.
- *
- * @param pm PackageManager instance to query
- */
- public void requestQueuedMeasurementsLocked(PackageManager pm) {
- final List appsList = mStatsObserver.getAppsList();
- final int N = appsList.size();
- for (int i = 0; i < N; i++) {
- pm.getPackageSizeInfo(appsList.get(i), mStatsObserver);
- }
- }
-
- private class StatsObserver extends IPackageStatsObserver.Stub {
- private long mAppsSizeForThisStatsObserver = 0;
- private final List mAppsList = new ArrayList();
- public void onGetStatsCompleted(PackageStats stats, boolean succeeded) {
- if (!mStatsObserver.equals(this)) {
- // this callback's class object is no longer in use. ignore this callback.
- return;
- }
- if (succeeded) {
- mAppsSizeForThisStatsObserver += stats.codeSize + stats.dataSize +
- stats.externalCacheSize + stats.externalDataSize +
- stats.externalMediaSize + stats.externalObbSize;
- }
-
- synchronized (mAppsList) {
- mAppsList.remove(stats.packageName);
-
- if (mAppsList.size() == 0) {
- mInternalAppsSize = mAppsSizeForThisStatsObserver;
-
- onInternalMeasurementComplete();
- }
- }
- }
-
- public void queuePackageMeasurementLocked(String packageName) {
- mAppsList.add(packageName);
- }
- public List getAppsList() {
- return mAppsList;
- }
- }
-
- private void onInternalMeasurementComplete() {
- sendEmptyMessage(MSG_COMPLETED);
- }
-
- private void measureApproximateInternalStorage() {
- final File dataPath = Environment.getDataDirectory();
- final StatFs stat = new StatFs(dataPath.getPath());
- final long blockSize = stat.getBlockSize();
- final long totalBlocks = stat.getBlockCount();
- final long availableBlocks = stat.getAvailableBlocks();
-
- final long totalSize = totalBlocks * blockSize;
- final long availSize = availableBlocks * blockSize;
-
- mInternalTotalSize = totalSize;
- mInternalAvailSize = availSize;
-
- sendInternalApproximateUpdate();
- }
-
- private void measureExactInternalStorage(IMediaContainerService imcs) {
- Context context = mContext != null ? mContext.get() : null;
- if (context == null) {
- return;
- }
- // We have to get installd to measure the package sizes.
- PackageManager pm = context.getPackageManager();
- if (pm == null) {
- return;
- }
- // measure sizes for all except "media_misc" - which is computed
- for (int i = 0; i < Constants.NUM_MEDIA_DIRS_TRACKED - 1; i++) {
- mMediaSizes[i] = 0;
- String[] dirs = Constants.mMediaDirs.get(i).mDirPaths;
- int len = dirs.length;
- if (len > 0) {
- for (int k = 0; k < len; k++) {
- long dirSize = getSize(imcs, dirs[k]);
- mMediaSizes[i] += dirSize;
- if (LOGV) {
- Log.i(TAG, "size of " + dirs[k] + ": " + dirSize);
- }
- }
- }
- }
-
- // compute the size of "misc"
- mMediaSizes[Constants.MEDIA_MISC_INDEX] = mMediaSizes[Constants.MEDIA_INDEX];
- for (int i = 1; i < Constants.NUM_MEDIA_DIRS_TRACKED - 1; i++) {
- mMediaSizes[Constants.MEDIA_MISC_INDEX] -= mMediaSizes[i];
- }
- if (LOGV) {
- Log.i(TAG, "media_misc size: " + mMediaSizes[Constants.MEDIA_MISC_INDEX]);
- }
-
- // compute the sizes of each of the files/directories under 'misc' category
- measureSizesOfMisc(imcs);
-
- // compute apps sizes
- final List apps = pm
- .getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES
- | PackageManager.GET_DISABLED_COMPONENTS);
- if (apps != null) {
- // initiate measurement of all package sizes. need new StatsObserver object.
- mStatsObserver = new StatsObserver();
- synchronized (mStatsObserver.mAppsList) {
- for (int i = 0; i < apps.size(); i++) {
- final ApplicationInfo info = apps.get(i);
- mStatsObserver.queuePackageMeasurementLocked(info.packageName);
- }
-
- requestQueuedMeasurementsLocked(pm);
- }
- }
-
- // Sending of the message back to the MeasurementReceiver is
- // completed in the PackageObserver
- }
- private void measureSizesOfMisc(IMediaContainerService imcs) {
- File top = Environment.getExternalStorageDirectory();
- mFileInfoForMisc = new ArrayList();
- File[] files = top.listFiles();
- int len = files.length;
- if (len == 0) {
- return;
- }
- // get sizes of all top level nodes in /sdcard dir except the ones already computed...
- long counter = 0;
- for (int i = 0; i < len; i++) {
- String path = files[i].getAbsolutePath();
- if (Constants.ExclusionTargetsForMiscFiles.contains(path)) {
- continue;
- }
- if (files[i].isFile()) {
- mFileInfoForMisc.add(new FileInfo(path, files[i].length(), counter++));
- } else if (files[i].isDirectory()) {
- long dirSize = getSize(imcs, path);
- mFileInfoForMisc.add(new FileInfo(path, dirSize, counter++));
- } else {
- }
- }
- // sort the list of FileInfo objects collected above in descending order of their sizes
- Collections.sort(mFileInfoForMisc);
- }
-
- private long getSize(IMediaContainerService imcs, String dir) {
- try {
- long size = imcs.calculateDirectorySize(dir);
- return size;
- } catch (Exception e) {
- Log.w(TAG, "Could not read memory from default container service for " +
- dir, e);
- return -1;
- }
- }
-
- public void measureApproximateExternalStorage() {
- File path = Environment.getExternalStorageDirectory();
-
- StatFs stat = new StatFs(path.getPath());
- long blockSize = stat.getBlockSize();
- long totalBlocks = stat.getBlockCount();
- long availableBlocks = stat.getAvailableBlocks();
-
- mExternalTotalSize = totalBlocks * blockSize;
- mExternalAvailSize = availableBlocks * blockSize;
-
- sendExternalApproximateUpdate();
- }
- }
-
- public void invalidate() {
- mHandler.sendEmptyMessage(MeasurementHandler.MSG_INVALIDATE);
- }
-
- boolean isSizeOfMiscCategoryNonZero() {
- return mFileInfoForMisc != null && mFileInfoForMisc.size() > 0;
- }
-
- static class FileInfo implements Comparable {
- String mFileName;
- long mSize;
- long mId;
- FileInfo(String fileName, long size, long id) {
- mFileName = fileName;
- mSize = size;
- mId = id;
- }
- @Override
- public int compareTo(FileInfo that) {
- if (this == that || mSize == that.mSize) return 0;
- else if (mSize < that.mSize) return 1; // for descending sort
- else return -1;
- }
- @Override
- public String toString() {
- return mFileName + " : " + mSize + ", id:" + mId;
- }
- }
-}
diff --git a/src/com/android/settings/deviceinfo/MiscFilesHandler.java b/src/com/android/settings/deviceinfo/MiscFilesHandler.java
index 15951c959bc..eae68611a56 100644
--- a/src/com/android/settings/deviceinfo/MiscFilesHandler.java
+++ b/src/com/android/settings/deviceinfo/MiscFilesHandler.java
@@ -16,12 +16,11 @@
package com.android.settings.deviceinfo;
-import com.android.settings.R;
-import com.android.settings.deviceinfo.MemoryMeasurement.FileInfo;
-
+import android.app.Activity;
import android.app.ListActivity;
import android.content.Context;
import android.os.Bundle;
+import android.os.storage.StorageVolume;
import android.text.format.Formatter;
import android.util.Log;
import android.util.SparseBooleanArray;
@@ -39,6 +38,9 @@ import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ListView;
+import com.android.settings.R;
+import com.android.settings.deviceinfo.StorageMeasurement.FileInfo;
+
import java.io.File;
import java.util.ArrayList;
import java.util.List;
@@ -107,7 +109,7 @@ public class MiscFilesHandler extends ListActivity {
//item not selected
continue;
}
- if (MemoryMeasurement.LOGV) {
+ if (StorageMeasurement.LOGV) {
Log.i(TAG, "deleting: " + mAdapter.getItem(i));
}
// delete the file
@@ -156,6 +158,7 @@ public class MiscFilesHandler extends ListActivity {
}
public void onDestroyActionMode(ActionMode mode) {
+ // This block intentionally left blank
}
public void onItemCheckedStateChanged(ActionMode mode, int position, long id,
@@ -181,17 +184,21 @@ public class MiscFilesHandler extends ListActivity {
}
}
- public class MemoryMearurementAdapter extends BaseAdapter {
- private ArrayList mData = null;
+ class MemoryMearurementAdapter extends BaseAdapter {
+ private ArrayList mData = null;
private long mDataSize = 0;
private Context mContext;
- public MemoryMearurementAdapter(Context context) {
- mContext = context;
- MemoryMeasurement mMeasurement = MemoryMeasurement.getInstance(context);
- mData = (ArrayList)mMeasurement.mFileInfoForMisc;
+ public MemoryMearurementAdapter(Activity activity) {
+ mContext = activity;
+ final Bundle extras = activity.getIntent().getExtras();
+ final StorageVolume storageVolume = extras.getParcelable(
+ StorageVolumePreferenceCategory.STORAGE_VOLUME);
+ StorageMeasurement mMeasurement =
+ StorageMeasurement.getInstance(activity, storageVolume, false);
+ mData = (ArrayList) mMeasurement.mFileInfoForMisc;
if (mData != null) {
- for (MemoryMeasurement.FileInfo info : mData) {
+ for (StorageMeasurement.FileInfo info : mData) {
mDataSize += info.mSize;
}
}
@@ -203,7 +210,7 @@ public class MiscFilesHandler extends ListActivity {
}
@Override
- public MemoryMeasurement.FileInfo getItem(int position) {
+ public StorageMeasurement.FileInfo getItem(int position) {
if (mData == null || mData.size() <= position) {
return null;
}
@@ -217,13 +224,14 @@ public class MiscFilesHandler extends ListActivity {
}
return mData.get(position).mId;
}
+
public void removeAll(List