diff options
author | John Hoford <hoford@google.com> | 2013-10-10 08:59:17 -0700 |
---|---|---|
committer | John Hoford <hoford@google.com> | 2013-10-10 09:00:43 -0700 |
commit | 96e6ddb24dd149aa991ef007a394ea9592066d14 (patch) | |
tree | fb1b83e7f651a6edaf0493fe1d57a6464a78e8ae /src/com/android/gallery3d/ingest | |
parent | fb1884f63beb3ab4c94b09aea91b5ad501bc6af6 (diff) | |
download | android_packages_apps_Gallery2-96e6ddb24dd149aa991ef007a394ea9592066d14.tar.gz android_packages_apps_Gallery2-96e6ddb24dd149aa991ef007a394ea9592066d14.tar.bz2 android_packages_apps_Gallery2-96e6ddb24dd149aa991ef007a394ea9592066d14.zip |
fix Gallery crashes with empty PTP device
bug:11152999
Change-Id: I70e4787dc46c0e948712ea4530b8110c36603dfa
Diffstat (limited to 'src/com/android/gallery3d/ingest')
-rw-r--r-- | src/com/android/gallery3d/ingest/MtpDeviceIndex.java | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/com/android/gallery3d/ingest/MtpDeviceIndex.java b/src/com/android/gallery3d/ingest/MtpDeviceIndex.java index d30f94a87..fed851e0e 100644 --- a/src/com/android/gallery3d/ingest/MtpDeviceIndex.java +++ b/src/com/android/gallery3d/ingest/MtpDeviceIndex.java @@ -267,6 +267,9 @@ public class MtpDeviceIndex { break; } } + if (mBuckets.length == 0 || mUnifiedLookupIndex.length == 0) { + return -1; + } int mappedPos = mBuckets[bucketNumber].unifiedStartIndex + position - mBuckets[bucketNumber].itemsStartIndex; if (order == SortOrder.Descending) { @@ -283,6 +286,9 @@ public class MtpDeviceIndex { return bucket.itemsStartIndex + position - 1 - bucket.unifiedStartIndex; } else { int zeroIndex = mUnifiedLookupIndex.length - 1 - position; + if (mBuckets.length == 0 || mUnifiedLookupIndex.length == 0) { + return -1; + } DateBucket bucket = mBuckets[mUnifiedLookupIndex[zeroIndex]]; if (bucket.unifiedEndIndex == zeroIndex) zeroIndex--; return mMtpObjects.length - 1 - bucket.itemsStartIndex |