Loading core/java/android/app/ActivityThread.java +58 −3 Original line number Diff line number Diff line Loading @@ -1355,14 +1355,69 @@ public final class ActivityThread extends ClientTransactionHandler { IoUtils.closeQuietly(pfd); } private void dumpDatabaseInfo(ParcelFileDescriptor pfd, String[] args) { private File getDatabasesDir(Context context) { // There's no simple way to get the databases/ path, so do it this way. return context.getDatabasePath("a").getParentFile(); } private void dumpDatabaseInfo(ParcelFileDescriptor pfd, String[] args, boolean isSystem) { PrintWriter pw = new FastPrintWriter( new FileOutputStream(pfd.getFileDescriptor())); PrintWriterPrinter printer = new PrintWriterPrinter(pw); SQLiteDebug.dump(printer, args); if (isSystem) { dumpDatabaseFileSizes(pw, Environment.getDataSystemDirectory(), true); dumpDatabaseFileSizes(pw, Environment.getDataSystemDeDirectory(), true); dumpDatabaseFileSizes(pw, Environment.getDataSystemCeDirectory(), true); } else { Context context = getApplication(); if (context != null) { dumpDatabaseFileSizes(pw, getDatabasesDir(context.createDeviceProtectedStorageContext()), false); dumpDatabaseFileSizes(pw, getDatabasesDir(context.createCredentialProtectedStorageContext()), false); } } pw.flush(); } private void dumpDatabaseFileSizes(PrintWriter pw, File dir, boolean isSystem) { final File[] files = dir.listFiles(); if (files == null || files.length == 0) { return; } Arrays.sort(files, (a, b) -> a.getName().compareTo(b.getName())); boolean needHeader = true; for (File f : files) { if (isSystem) { // If it's the system server, the directory contains other files too, so // filter by file extensions. // (If it's an app, just print all files because they may not use *.db // extension.) final String name = f.getName(); if (!(name.endsWith(".db") || name.endsWith(".db-wal") || name.endsWith(".db-journal"))) { continue; } } if (needHeader) { pw.println(); pw.println("Database files in " + dir.getAbsolutePath() + ":"); needHeader = false; } pw.print(" "); pw.print(f.getName()); pw.print(" "); pw.print(f.length()); pw.println(" bytes"); } } @Override public void dumpDbInfo(final ParcelFileDescriptor pfd, final String[] args) { if (mSystemThread) { Loading @@ -1383,14 +1438,14 @@ public final class ActivityThread extends ClientTransactionHandler { @Override public void run() { try { dumpDatabaseInfo(dup, args); dumpDatabaseInfo(dup, args, true); } finally { IoUtils.closeQuietly(dup); } } }); } else { dumpDatabaseInfo(pfd, args); dumpDatabaseInfo(pfd, args, false); IoUtils.closeQuietly(pfd); } } Loading Loading
core/java/android/app/ActivityThread.java +58 −3 Original line number Diff line number Diff line Loading @@ -1355,14 +1355,69 @@ public final class ActivityThread extends ClientTransactionHandler { IoUtils.closeQuietly(pfd); } private void dumpDatabaseInfo(ParcelFileDescriptor pfd, String[] args) { private File getDatabasesDir(Context context) { // There's no simple way to get the databases/ path, so do it this way. return context.getDatabasePath("a").getParentFile(); } private void dumpDatabaseInfo(ParcelFileDescriptor pfd, String[] args, boolean isSystem) { PrintWriter pw = new FastPrintWriter( new FileOutputStream(pfd.getFileDescriptor())); PrintWriterPrinter printer = new PrintWriterPrinter(pw); SQLiteDebug.dump(printer, args); if (isSystem) { dumpDatabaseFileSizes(pw, Environment.getDataSystemDirectory(), true); dumpDatabaseFileSizes(pw, Environment.getDataSystemDeDirectory(), true); dumpDatabaseFileSizes(pw, Environment.getDataSystemCeDirectory(), true); } else { Context context = getApplication(); if (context != null) { dumpDatabaseFileSizes(pw, getDatabasesDir(context.createDeviceProtectedStorageContext()), false); dumpDatabaseFileSizes(pw, getDatabasesDir(context.createCredentialProtectedStorageContext()), false); } } pw.flush(); } private void dumpDatabaseFileSizes(PrintWriter pw, File dir, boolean isSystem) { final File[] files = dir.listFiles(); if (files == null || files.length == 0) { return; } Arrays.sort(files, (a, b) -> a.getName().compareTo(b.getName())); boolean needHeader = true; for (File f : files) { if (isSystem) { // If it's the system server, the directory contains other files too, so // filter by file extensions. // (If it's an app, just print all files because they may not use *.db // extension.) final String name = f.getName(); if (!(name.endsWith(".db") || name.endsWith(".db-wal") || name.endsWith(".db-journal"))) { continue; } } if (needHeader) { pw.println(); pw.println("Database files in " + dir.getAbsolutePath() + ":"); needHeader = false; } pw.print(" "); pw.print(f.getName()); pw.print(" "); pw.print(f.length()); pw.println(" bytes"); } } @Override public void dumpDbInfo(final ParcelFileDescriptor pfd, final String[] args) { if (mSystemThread) { Loading @@ -1383,14 +1438,14 @@ public final class ActivityThread extends ClientTransactionHandler { @Override public void run() { try { dumpDatabaseInfo(dup, args); dumpDatabaseInfo(dup, args, true); } finally { IoUtils.closeQuietly(dup); } } }); } else { dumpDatabaseInfo(pfd, args); dumpDatabaseInfo(pfd, args, false); IoUtils.closeQuietly(pfd); } } Loading