Fix "division by zero" crash after USB mass storage disconnects
File.java will return the total size in bytes of the partition
containing the path, and if the path does not exist,
it will return 0.
Change-Id: I134d4ec787b475e38bb37b4386bafcc419971c1e
diff --git a/src/com/android/settings/deviceinfo/StorageVolumePreference.java b/src/com/android/settings/deviceinfo/StorageVolumePreference.java
index 3511b91..04e0ffc 100644
--- a/src/com/android/settings/deviceinfo/StorageVolumePreference.java
+++ b/src/com/android/settings/deviceinfo/StorageVolumePreference.java
@@ -74,7 +74,9 @@
final String used = Formatter.formatFileSize(context, usedBytes);
final String total = Formatter.formatFileSize(context, totalBytes);
setSummary(context.getString(R.string.storage_volume_summary, used, total));
- mUsedPercent = (int) ((usedBytes * 100) / totalBytes);
+ if (totalBytes > 0) {
+ mUsedPercent = (int) ((usedBytes * 100) / totalBytes);
+ }
if (freeBytes < mStorageManager.getStorageLowBytes(path)) {
mColor = StorageSettings.COLOR_WARNING;