summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOwen Lin <owenlin@google.com>2012-03-13 14:17:01 +0800
committerOwen Lin <owenlin@google.com>2012-03-20 19:19:26 +0800
commite80b47691bfc340f76464b97bac5ad6fe9f561de (patch)
treedfe65a5e8465df8fa45b98c29ea7021e47b14be1
parentd8d04a85419c75b91348d3baeba416a14c5132f7 (diff)
downloadandroid_packages_apps_Snap-e80b47691bfc340f76464b97bac5ad6fe9f561de.tar.gz
android_packages_apps_Snap-e80b47691bfc340f76464b97bac5ad6fe9f561de.tar.bz2
android_packages_apps_Snap-e80b47691bfc340f76464b97bac5ad6fe9f561de.zip
Add log to debug loading time.
Change-Id: I53ddb3cdce7abe9de7c5bbd85c1adad474bdff2f
-rw-r--r--src/com/android/gallery3d/app/AlbumSetDataAdapter.java6
-rw-r--r--src/com/android/gallery3d/data/LocalAlbumSet.java23
2 files changed, 20 insertions, 9 deletions
diff --git a/src/com/android/gallery3d/app/AlbumSetDataAdapter.java b/src/com/android/gallery3d/app/AlbumSetDataAdapter.java
index 262778aa8..1d642f931 100644
--- a/src/com/android/gallery3d/app/AlbumSetDataAdapter.java
+++ b/src/com/android/gallery3d/app/AlbumSetDataAdapter.java
@@ -18,6 +18,7 @@ package com.android.gallery3d.app;
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 @@ public class AlbumSetDataAdapter implements AlbumSetView.Model {
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 35d87d765..24d6d32a5 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.Files.FileColumns;
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 @@ public class LocalAlbumSet extends MediaSet {
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 @@ public class LocalAlbumSet extends MediaSet {
}
}
}
+ Log.v("DebugLoadingTime", "got " + buffer.size() + " buckets");
} finally {
cursor.close();
}
@@ -169,15 +181,8 @@ public class LocalAlbumSet extends MediaSet {
// 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