diff options
| -rw-r--r-- | core/java/android/app/ActivityThread.java | 6 | ||||
| -rw-r--r-- | core/java/android/database/sqlite/SQLiteDatabase.java | 42 | ||||
| -rw-r--r-- | core/java/android/database/sqlite/SQLiteDebug.java | 16 | ||||
| -rw-r--r-- | media/jni/android_media_PtpCursor.cpp | 8 | ||||
| -rw-r--r-- | media/mtp/Android.mk | 31 | ||||
| -rw-r--r-- | media/mtp/PtpCursor.cpp (renamed from media/mtp/MtpCursor.cpp) | 46 | ||||
| -rw-r--r-- | media/mtp/PtpCursor.h (renamed from media/mtp/MtpCursor.h) | 12 |
7 files changed, 90 insertions, 71 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index c0714e3bba25..5c4f57a51ac0 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -870,6 +870,12 @@ public final class ActivityThread { (dbStats.dbSize > 0) ? String.valueOf(dbStats.dbSize) : " ", (dbStats.lookaside > 0) ? String.valueOf(dbStats.lookaside) : " ", dbStats.cache, dbStats.dbName); + if (dbStats.dataDump != null) { + int size = dbStats.dataDump.size(); + for (int dumpIndex = 0; dumpIndex < size; dumpIndex++) { + printRow(pw, "%s", dbStats.dataDump.get(dumpIndex)); + } + } } } diff --git a/core/java/android/database/sqlite/SQLiteDatabase.java b/core/java/android/database/sqlite/SQLiteDatabase.java index 7efb7fdc1ac1..87f55d2045d1 100644 --- a/core/java/android/database/sqlite/SQLiteDatabase.java +++ b/core/java/android/database/sqlite/SQLiteDatabase.java @@ -2507,7 +2507,7 @@ public class SQLiteDatabase extends SQLiteClosable { if (pageCount > 0) { dbStatsList.add(new DbStats(dbName, pageCount, db.getPageSize(), lookasideUsed, db.getCacheHitNum(), db.getCacheMissNum(), - db.getCachesize())); + db.getCachesize(), getDataDump(db))); } } // if there are pooled connections, return the cache stats for them also. @@ -2518,7 +2518,7 @@ public class SQLiteDatabase extends SQLiteClosable { for (SQLiteDatabase pDb : connPool.getConnectionList()) { dbStatsList.add(new DbStats("(pooled # " + pDb.mConnectionNum + ") " + lastnode, 0, 0, 0, pDb.getCacheHitNum(), - pDb.getCacheMissNum(), pDb.getCachesize())); + pDb.getCacheMissNum(), pDb.getCachesize(), null)); } } } catch (SQLiteException e) { @@ -2529,6 +2529,44 @@ public class SQLiteDatabase extends SQLiteClosable { return dbStatsList; } + private static ArrayList<String> getDataDump(SQLiteDatabase db) { + // create database dump of certain data from certain databases for debugging purposes + if (db.getPath().equalsIgnoreCase( + "/data/data/com.android.providers.downloads/databases/downloads.db")) { + String sql = + "select * from downloads " + + " where notificationpackage = 'com.google.android.gsf'" + + " or status >= 400"; + Cursor cursor = db.rawQuery(sql, null); + try { + int count = cursor.getCount(); + if (count == 0) { + return null; + } + ArrayList<String> buff = new ArrayList<String>(); + buff.add(" Data from downloads.db"); + int columnCount = cursor.getColumnCount(); + for (int i =0; i < count && cursor.moveToNext(); i++) { + buff.add(" Row#" + i + ""); + for (int j = 0; j < columnCount; j++) { + String colName = cursor.getColumnName(j); + String value = cursor.getString(j); + buff.add(" " + colName + " = " + value); + } + } + for (String s : buff) Log.i("vnoritag", s); + return buff; + } catch (SQLiteException e) { + Log.w(TAG, "exception in executing the sql: " + sql, e); + } finally { + if (cursor != null) { + cursor.close(); + } + } + } + return null; + } + /** * Returns list of full pathnames of all attached databases including the main database * by executing 'pragma database_list' on the database. diff --git a/core/java/android/database/sqlite/SQLiteDebug.java b/core/java/android/database/sqlite/SQLiteDebug.java index 9496079178e6..72377f074bf5 100644 --- a/core/java/android/database/sqlite/SQLiteDebug.java +++ b/core/java/android/database/sqlite/SQLiteDebug.java @@ -121,27 +121,31 @@ public final class SQLiteDebug { */ public static class DbStats { /** name of the database */ - public String dbName; + public final String dbName; /** the page size for the database */ - public long pageSize; + public final long pageSize; /** the database size */ - public long dbSize; + public final long dbSize; /** documented here http://www.sqlite.org/c3ref/c_dbstatus_lookaside_used.html */ - public int lookaside; + public final int lookaside; /** statement cache stats: hits/misses/cachesize */ - public String cache; + public final String cache; + + /** database dump of 'useful info for debugging only */ + public final ArrayList<String> dataDump; public DbStats(String dbName, long pageCount, long pageSize, int lookaside, - int hits, int misses, int cachesize) { + int hits, int misses, int cachesize, ArrayList<String> data) { this.dbName = dbName; this.pageSize = pageSize / 1024; dbSize = (pageCount * pageSize) / 1024; this.lookaside = lookaside; this.cache = hits + "/" + misses + "/" + cachesize; + this.dataDump = data; } } diff --git a/media/jni/android_media_PtpCursor.cpp b/media/jni/android_media_PtpCursor.cpp index c5af3a89099e..76c88f6e4ccd 100644 --- a/media/jni/android_media_PtpCursor.cpp +++ b/media/jni/android_media_PtpCursor.cpp @@ -29,7 +29,7 @@ #include "binder/CursorWindow.h" #include "MtpClient.h" -#include "MtpCursor.h" +#include "PtpCursor.h" using namespace android; @@ -63,7 +63,7 @@ android_media_PtpCursor_setup(JNIEnv *env, jobject thiz, jobject javaClient, } MtpClient* client = get_client_from_object(env, javaClient); - MtpCursor* cursor = new MtpCursor(client, queryType, + PtpCursor* cursor = new PtpCursor(client, queryType, deviceID, storageID, objectID, columnCount, columns); if (columns) @@ -77,7 +77,7 @@ android_media_PtpCursor_finalize(JNIEnv *env, jobject thiz) { #ifdef HAVE_ANDROID_OS LOGD("finalize\n"); - MtpCursor *cursor = (MtpCursor *)env->GetIntField(thiz, field_context); + PtpCursor *cursor = (PtpCursor *)env->GetIntField(thiz, field_context); delete cursor; #endif } @@ -93,7 +93,7 @@ android_media_PtpCursor_fill_window(JNIEnv *env, jobject thiz, jobject javaWindo "Bad CursorWindow"); return 0; } - MtpCursor *cursor = (MtpCursor *)env->GetIntField(thiz, field_context); + PtpCursor *cursor = (PtpCursor *)env->GetIntField(thiz, field_context); return cursor->fillWindow(window, startPos); #else diff --git a/media/mtp/Android.mk b/media/mtp/Android.mk index 7502f6e890ad..b7e1a2a14532 100644 --- a/media/mtp/Android.mk +++ b/media/mtp/Android.mk @@ -22,7 +22,6 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ MtpClient.cpp \ - MtpCursor.cpp \ MtpDataPacket.cpp \ MtpDebug.cpp \ MtpDevice.cpp \ @@ -38,6 +37,7 @@ LOCAL_SRC_FILES:= \ MtpStringBuffer.cpp \ MtpStorage.cpp \ MtpUtils.cpp \ + PtpCursor.cpp \ LOCAL_MODULE:= libmtp @@ -47,32 +47,3 @@ include $(BUILD_STATIC_LIBRARY) endif -ifeq ($(HOST_OS),linux) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES:= \ - MtpClient.cpp \ - MtpCursor.cpp \ - MtpDataPacket.cpp \ - MtpDebug.cpp \ - MtpDevice.cpp \ - MtpEventPacket.cpp \ - MtpDeviceInfo.cpp \ - MtpObjectInfo.cpp \ - MtpPacket.cpp \ - MtpProperty.cpp \ - MtpRequestPacket.cpp \ - MtpResponsePacket.cpp \ - MtpStorageInfo.cpp \ - MtpStringBuffer.cpp \ - MtpStorage.cpp \ - MtpUtils.cpp \ - -LOCAL_MODULE:= libmtp - -LOCAL_CFLAGS := -DMTP_HOST - -include $(BUILD_HOST_STATIC_LIBRARY) - -endif diff --git a/media/mtp/MtpCursor.cpp b/media/mtp/PtpCursor.cpp index 35d90dcbfd96..7294cefb62d2 100644 --- a/media/mtp/MtpCursor.cpp +++ b/media/mtp/PtpCursor.cpp @@ -14,11 +14,11 @@ * limitations under the License. */ -#define LOG_TAG "MtpCursor" +#define LOG_TAG "PtpCursor" #include "MtpDebug.h" #include "MtpClient.h" -#include "MtpCursor.h" +#include "PtpCursor.h" #include "MtpDevice.h" #include "MtpDeviceInfo.h" #include "MtpObjectInfo.h" @@ -30,19 +30,19 @@ namespace android { /* Device Column IDs */ -/* These must match the values in MtpCursor.java */ +/* These must match the values in PtpCursor.java */ #define DEVICE_ROW_ID 1 #define DEVICE_MANUFACTURER 2 #define DEVICE_MODEL 3 /* Storage Column IDs */ -/* These must match the values in MtpCursor.java */ +/* These must match the values in PtpCursor.java */ #define STORAGE_ROW_ID 101 #define STORAGE_IDENTIFIER 102 #define STORAGE_DESCRIPTION 103 /* Object Column IDs */ -/* These must match the values in MtpCursor.java */ +/* These must match the values in PtpCursor.java */ #define OBJECT_ROW_ID 201 #define OBJECT_STORAGE_ID 202 #define OBJECT_FORMAT 203 @@ -65,7 +65,7 @@ namespace android { #define OBJECT_KEYWORDS 220 #define OBJECT_THUMB 221 -MtpCursor::MtpCursor(MtpClient* client, int queryType, int deviceID, +PtpCursor::PtpCursor(MtpClient* client, int queryType, int deviceID, MtpStorageID storageID, MtpObjectHandle objectID, int columnCount, int* columns) : mClient(client), @@ -82,12 +82,12 @@ MtpCursor::MtpCursor(MtpClient* client, int queryType, int deviceID, } } -MtpCursor::~MtpCursor() { +PtpCursor::~PtpCursor() { delete[] mColumns; } -int MtpCursor::fillWindow(CursorWindow* window, int startPos) { - LOGD("MtpCursor::fillWindow mQueryType: %d\n", mQueryType); +int PtpCursor::fillWindow(CursorWindow* window, int startPos) { + LOGD("PtpCursor::fillWindow mQueryType: %d\n", mQueryType); switch (mQueryType) { case DEVICE: @@ -107,12 +107,12 @@ int MtpCursor::fillWindow(CursorWindow* window, int startPos) { case OBJECT_CHILDREN: return fillObjects(window, mQbjectID, startPos); default: - LOGE("MtpCursor::fillWindow: unknown query type %d\n", mQueryType); + LOGE("PtpCursor::fillWindow: unknown query type %d\n", mQueryType); return 0; } } -int MtpCursor::fillDevices(CursorWindow* window, int startPos) { +int PtpCursor::fillDevices(CursorWindow* window, int startPos) { int count = 0; MtpDeviceList& deviceList = mClient->getDeviceList(); for (int i = 0; i < deviceList.size(); i++) { @@ -127,7 +127,7 @@ int MtpCursor::fillDevices(CursorWindow* window, int startPos) { return count; } -int MtpCursor::fillDevice(CursorWindow* window, int startPos) { +int PtpCursor::fillDevice(CursorWindow* window, int startPos) { MtpDevice* device = mClient->getDevice(mDeviceID); if (device && fillDevice(window, device, startPos)) return 1; @@ -135,7 +135,7 @@ int MtpCursor::fillDevice(CursorWindow* window, int startPos) { return 0; } -int MtpCursor::fillStorages(CursorWindow* window, int startPos) { +int PtpCursor::fillStorages(CursorWindow* window, int startPos) { int count = 0; MtpDevice* device = mClient->getDevice(mDeviceID); if (!device) @@ -157,7 +157,7 @@ int MtpCursor::fillStorages(CursorWindow* window, int startPos) { return count; } -int MtpCursor::fillStorage(CursorWindow* window, int startPos) { +int PtpCursor::fillStorage(CursorWindow* window, int startPos) { MtpDevice* device = mClient->getDevice(mDeviceID); if (device && fillStorage(window, device, mStorageID, startPos)) return 1; @@ -165,7 +165,7 @@ int MtpCursor::fillStorage(CursorWindow* window, int startPos) { return 0; } -int MtpCursor::fillObjects(CursorWindow* window, int parent, int startPos) { +int PtpCursor::fillObjects(CursorWindow* window, int parent, int startPos) { int count = 0; MtpDevice* device = mClient->getDevice(mDeviceID); if (!device) @@ -187,7 +187,7 @@ int MtpCursor::fillObjects(CursorWindow* window, int parent, int startPos) { return count; } -int MtpCursor::fillObject(CursorWindow* window, int startPos) { +int PtpCursor::fillObject(CursorWindow* window, int startPos) { MtpDevice* device = mClient->getDevice(mDeviceID); if (device && fillObject(window, device, mQbjectID, startPos)) return 1; @@ -195,7 +195,7 @@ int MtpCursor::fillObject(CursorWindow* window, int startPos) { return 0; } -bool MtpCursor::fillDevice(CursorWindow* window, MtpDevice* device, int row) { +bool PtpCursor::fillDevice(CursorWindow* window, MtpDevice* device, int row) { MtpDeviceInfo* deviceInfo = device->getDeviceInfo(); if (!deviceInfo) return false; @@ -225,7 +225,7 @@ bool MtpCursor::fillDevice(CursorWindow* window, MtpDevice* device, int row) { return true; } -bool MtpCursor::fillStorage(CursorWindow* window, MtpDevice* device, +bool PtpCursor::fillStorage(CursorWindow* window, MtpDevice* device, MtpStorageID storageID, int row) { LOGD("fillStorage %d\n", storageID); @@ -273,7 +273,7 @@ fail: return false; } -bool MtpCursor::fillObject(CursorWindow* window, MtpDevice* device, +bool PtpCursor::fillObject(CursorWindow* window, MtpDevice* device, MtpObjectHandle objectID, int row) { MtpObjectInfo* objectInfo = device->getObjectInfo(objectID); @@ -385,7 +385,7 @@ fail: return false; } -bool MtpCursor::prepareRow(CursorWindow* window) { +bool PtpCursor::prepareRow(CursorWindow* window) { if (!window->setNumColumns(mColumnCount)) { LOGE("Failed to change column count from %d to %d", window->getNumColumns(), mColumnCount); return false; @@ -399,7 +399,7 @@ bool MtpCursor::prepareRow(CursorWindow* window) { } -bool MtpCursor::putLong(CursorWindow* window, int64_t value, int row, int column) { +bool PtpCursor::putLong(CursorWindow* window, int64_t value, int row, int column) { if (!window->putLong(row, column, value)) { window->freeLastRow(); LOGE("Failed allocating space for a long in column %d", column); @@ -408,7 +408,7 @@ bool MtpCursor::putLong(CursorWindow* window, int64_t value, int row, int column return true; } -bool MtpCursor::putString(CursorWindow* window, const char* text, int row, int column) { +bool PtpCursor::putString(CursorWindow* window, const char* text, int row, int column) { int size = strlen(text) + 1; int offset = window->alloc(size); if (!offset) { @@ -427,7 +427,7 @@ bool MtpCursor::putString(CursorWindow* window, const char* text, int row, int c return true; } -bool MtpCursor::putThumbnail(CursorWindow* window, MtpObjectHandle objectID, +bool PtpCursor::putThumbnail(CursorWindow* window, MtpObjectHandle objectID, MtpObjectFormat format, int row, int column) { MtpDevice* device = mClient->getDevice(mDeviceID); void* thumbnail; diff --git a/media/mtp/MtpCursor.h b/media/mtp/PtpCursor.h index 2e03c29cfd96..38a1d47f9314 100644 --- a/media/mtp/MtpCursor.h +++ b/media/mtp/PtpCursor.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef _MTP_CURSOR_H -#define _MTP_CURSOR_H +#ifndef _PTP_CURSOR_H +#define _PTP_CURSOR_H #include "MtpTypes.h" @@ -23,7 +23,7 @@ namespace android { class CursorWindow; -class MtpCursor { +class PtpCursor { private: enum { DEVICE = 1, @@ -45,10 +45,10 @@ private: int* mColumns; public: - MtpCursor(MtpClient* client, int queryType, int deviceID, + PtpCursor(MtpClient* client, int queryType, int deviceID, MtpStorageID storageID, MtpObjectHandle objectID, int columnCount, int* columns); - virtual ~MtpCursor(); + virtual ~PtpCursor(); int fillWindow(CursorWindow* window, int startPos); @@ -75,4 +75,4 @@ private: }; // namespace android -#endif // _MTP_CURSOR_H +#endif // _PTP_CURSOR_H |