Merge "Revert "Merge "print certain rows from downloads.db when bugreports are taken"""

This commit is contained in:
Vasu Nori
2010-11-29 11:05:22 -08:00
committed by Android (Google) Code Review
3 changed files with 8 additions and 56 deletions

View File

@@ -870,12 +870,6 @@ 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));
}
}
}
}

View File

@@ -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(), getDataDump(db)));
db.getCachesize()));
}
}
// 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(), null));
pDb.getCacheMissNum(), pDb.getCachesize()));
}
}
} catch (SQLiteException e) {
@@ -2529,44 +2529,6 @@ 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.

View File

@@ -121,31 +121,27 @@ public final class SQLiteDebug {
*/
public static class DbStats {
/** name of the database */
public final String dbName;
public String dbName;
/** the page size for the database */
public final long pageSize;
public long pageSize;
/** the database size */
public final long dbSize;
public long dbSize;
/** documented here http://www.sqlite.org/c3ref/c_dbstatus_lookaside_used.html */
public final int lookaside;
public int lookaside;
/** statement cache stats: hits/misses/cachesize */
public final String cache;
/** database dump of 'useful info for debugging only */
public final ArrayList<String> dataDump;
public String cache;
public DbStats(String dbName, long pageCount, long pageSize, int lookaside,
int hits, int misses, int cachesize, ArrayList<String> data) {
int hits, int misses, int cachesize) {
this.dbName = dbName;
this.pageSize = pageSize / 1024;
dbSize = (pageCount * pageSize) / 1024;
this.lookaside = lookaside;
this.cache = hits + "/" + misses + "/" + cachesize;
this.dataDump = data;
}
}