OSDN Git Service

Use MTP only if the MTP API is available.
authorChih-Chung Chang <chihchung@google.com>
Tue, 3 Jul 2012 11:33:46 +0000 (19:33 +0800)
committerChih-Chung Chang <chihchung@google.com>
Wed, 4 Jul 2012 04:53:14 +0000 (12:53 +0800)
Change-Id: I5c747d0da2905eb344c56dfab6333034dd5eecc3

gallerycommon/src/com/android/gallery3d/common/ApiHelper.java
src/com/android/gallery3d/data/DataManager.java

index a908e15..c1724a8 100644 (file)
@@ -54,6 +54,9 @@ public class ApiHelper {
             "android.graphics.SurfaceTexture", "setDefaultBufferSize",
             int.class, int.class);
 
+    public static final boolean HAS_MTP =
+            Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR1;
+
     private static boolean hasField(Class<?> klass, String fieldName) {
         try {
             klass.getDeclaredField(fieldName);
index 8551327..9ffdc0b 100644 (file)
@@ -23,6 +23,7 @@ import android.os.Handler;
 import android.support.v4.content.LocalBroadcastManager;
 
 import com.android.gallery3d.app.GalleryApp;
+import com.android.gallery3d.common.ApiHelper;
 import com.android.gallery3d.common.Utils;
 import com.android.gallery3d.data.MediaSet.ItemConsumer;
 import com.android.gallery3d.data.MediaSource.PathId;
@@ -115,7 +116,9 @@ public class DataManager {
         // the order matters, the UriSource must come last
         addSource(new LocalSource(mApplication));
         addSource(new PicasaSource(mApplication));
-        addSource(new MtpSource(mApplication));
+        if (ApiHelper.HAS_MTP) {
+            addSource(new MtpSource(mApplication));
+        }
         addSource(new ComboSource(mApplication));
         addSource(new ClusterSource(mApplication));
         addSource(new FilterSource(mApplication));