Add log to debug loading time.
Change-Id: I53ddb3cdce7abe9de7c5bbd85c1adad474bdff2f
diff --git a/src/com/android/gallery3d/app/AlbumSetDataAdapter.java b/src/com/android/gallery3d/app/AlbumSetDataAdapter.java
index 262778a..1d642f9 100644
--- a/src/com/android/gallery3d/app/AlbumSetDataAdapter.java
+++ b/src/com/android/gallery3d/app/AlbumSetDataAdapter.java
@@ -18,6 +18,7 @@
import android.os.Handler;
import android.os.Message;
+import android.os.SystemClock;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.ContentListener;
@@ -327,7 +328,12 @@
long version;
synchronized (DataManager.LOCK) {
+ long start = SystemClock.uptimeMillis();
version = mSource.reload();
+ long duration = SystemClock.uptimeMillis() - start;
+ if (duration > 20) {
+ Log.v("DebugLoadingTime", "finish reload - " + duration);
+ }
}
UpdateInfo info = executeAndWait(new GetUpdateInfo(version));
updateComplete = info == null;
diff --git a/src/com/android/gallery3d/data/LocalAlbumSet.java b/src/com/android/gallery3d/data/LocalAlbumSet.java
index 35d87d7..24d6d32 100644
--- a/src/com/android/gallery3d/data/LocalAlbumSet.java
+++ b/src/com/android/gallery3d/data/LocalAlbumSet.java
@@ -24,6 +24,7 @@
import android.provider.MediaStore.Images;
import android.provider.MediaStore.Images.ImageColumns;
import android.provider.MediaStore.Video;
+import android.util.Log;
import com.android.gallery3d.R;
import com.android.gallery3d.app.GalleryApp;
@@ -130,7 +131,17 @@
return mName;
}
- private BucketEntry[] loadBucketEntries(Cursor cursor) {
+ private BucketEntry[] loadBucketEntries() {
+ Uri uri = mBaseUri;
+
+ Log.v("DebugLoadingTime", "start quering media provider");
+ Cursor cursor = mApplication.getContentResolver().query(
+ uri, PROJECTION_BUCKET, BUCKET_GROUP_BY, null, BUCKET_ORDER_BY);
+ if (cursor == null) {
+ Log.w(TAG, "cannot open local database: " + uri);
+ return new BucketEntry[0];
+ }
+
ArrayList<BucketEntry> buffer = new ArrayList<BucketEntry>();
int typeBits = 0;
if ((mType & MEDIA_TYPE_IMAGE) != 0) {
@@ -150,6 +161,7 @@
}
}
}
+ Log.v("DebugLoadingTime", "got " + buffer.size() + " buckets");
} finally {
cursor.close();
}
@@ -169,15 +181,8 @@
// Note: it will be faster if we only select media_type and bucket_id.
// need to test the performance if that is worth
- Uri uri = mBaseUri;
GalleryUtils.assertNotInRenderThread();
- Cursor cursor = mApplication.getContentResolver().query(
- uri, PROJECTION_BUCKET, BUCKET_GROUP_BY, null, BUCKET_ORDER_BY);
- if (cursor == null) {
- Log.w(TAG, "cannot open local database: " + uri);
- return new ArrayList<MediaSet>();
- }
- BucketEntry[] entries = loadBucketEntries(cursor);
+ BucketEntry[] entries = loadBucketEntries();
int offset = 0;
// Move camera and download bucket to the front, while keeping the