Loading cmds/statsd/tools/localtools/src/com/android/statsd/shelltools/Utils.java +11 −4 Original line number Diff line number Diff line Loading @@ -70,9 +70,16 @@ public class Utils { /** * Dumps the report from the device and converts it to a ConfigMetricsReportList. * Erases the data if clearData is true. * @param configId id of the config * @param clearData whether to erase the report data from statsd after getting the report. * @param useShellUid Pulls data for the {@link SHELL_UID} instead of the caller's uid. * @param logger Logger to log error messages * @return * @throws IOException * @throws InterruptedException */ public static ConfigMetricsReportList getReportList(long configId, boolean clearData, Logger logger) throws IOException, InterruptedException { boolean useShellUid, Logger logger) throws IOException, InterruptedException { try { File outputFile = File.createTempFile("statsdret", ".bin"); outputFile.deleteOnExit(); Loading @@ -82,7 +89,7 @@ public class Utils { "adb", "shell", CMD_DUMP_REPORT, SHELL_UID, useShellUid ? SHELL_UID : "", String.valueOf(configId), clearData ? "" : "--keep_data", "--include_current_bucket", Loading @@ -93,8 +100,8 @@ public class Utils { } catch (com.google.protobuf.InvalidProtocolBufferException e) { logger.severe("Failed to fetch and parse the statsd output report. " + "Perhaps there is not a valid statsd config for the requested " + "uid=" + SHELL_UID + ", configId=" + configId + (useShellUid ? ("uid=" + SHELL_UID + ", ") : "") + "configId=" + configId + "."); throw (e); } Loading cmds/statsd/tools/localtools/src/com/android/statsd/shelltools/localdrive/LocalDrive.java +3 −3 Original line number Diff line number Diff line Loading @@ -165,7 +165,7 @@ public class LocalDrive { try { Utils.runCommand(null, sLogger, "adb", "shell", Utils.CMD_REMOVE_CONFIG, Utils.SHELL_UID, String.valueOf(configId)); Utils.getReportList(configId, true /* clearData */, sLogger); Utils.getReportList(configId, true /* clearData */, true /* SHELL_UID */, sLogger); } catch (InterruptedException | IOException e) { sLogger.severe("Failed to remove config: " + e.getMessage()); return false; Loading Loading @@ -234,7 +234,7 @@ public class LocalDrive { // Even if the args request no modifications, we still parse it to make sure it's valid. ConfigMetricsReportList reportList; try { reportList = Utils.getReportList(configId, clearData, sLogger); reportList = Utils.getReportList(configId, clearData, true /* SHELL_UID */, sLogger); } catch (IOException | InterruptedException e) { sLogger.severe("Failed to get report list: " + e.getMessage()); return false; Loading Loading @@ -278,7 +278,7 @@ public class LocalDrive { sLogger.fine(String.format("cmdClear with %d", configId)); try { Utils.getReportList(configId, true /* clearData */, sLogger); Utils.getReportList(configId, true /* clearData */, true /* SHELL_UID */, sLogger); } catch (IOException | InterruptedException e) { sLogger.severe("Failed to get report list: " + e.getMessage()); return false; Loading cmds/statsd/tools/localtools/src/com/android/statsd/shelltools/testdrive/TestDrive.java +1 −1 Original line number Diff line number Diff line Loading @@ -165,7 +165,7 @@ public class TestDrive { } private void dumpMetrics() throws Exception { ConfigMetricsReportList reportList = Utils.getReportList(CONFIG_ID, true, logger); ConfigMetricsReportList reportList = Utils.getReportList(CONFIG_ID, true, false, logger); // We may get multiple reports. Take the last one. ConfigMetricsReport report = reportList.getReports(reportList.getReportsCount() - 1); // Really should be only one metric. Loading Loading
cmds/statsd/tools/localtools/src/com/android/statsd/shelltools/Utils.java +11 −4 Original line number Diff line number Diff line Loading @@ -70,9 +70,16 @@ public class Utils { /** * Dumps the report from the device and converts it to a ConfigMetricsReportList. * Erases the data if clearData is true. * @param configId id of the config * @param clearData whether to erase the report data from statsd after getting the report. * @param useShellUid Pulls data for the {@link SHELL_UID} instead of the caller's uid. * @param logger Logger to log error messages * @return * @throws IOException * @throws InterruptedException */ public static ConfigMetricsReportList getReportList(long configId, boolean clearData, Logger logger) throws IOException, InterruptedException { boolean useShellUid, Logger logger) throws IOException, InterruptedException { try { File outputFile = File.createTempFile("statsdret", ".bin"); outputFile.deleteOnExit(); Loading @@ -82,7 +89,7 @@ public class Utils { "adb", "shell", CMD_DUMP_REPORT, SHELL_UID, useShellUid ? SHELL_UID : "", String.valueOf(configId), clearData ? "" : "--keep_data", "--include_current_bucket", Loading @@ -93,8 +100,8 @@ public class Utils { } catch (com.google.protobuf.InvalidProtocolBufferException e) { logger.severe("Failed to fetch and parse the statsd output report. " + "Perhaps there is not a valid statsd config for the requested " + "uid=" + SHELL_UID + ", configId=" + configId + (useShellUid ? ("uid=" + SHELL_UID + ", ") : "") + "configId=" + configId + "."); throw (e); } Loading
cmds/statsd/tools/localtools/src/com/android/statsd/shelltools/localdrive/LocalDrive.java +3 −3 Original line number Diff line number Diff line Loading @@ -165,7 +165,7 @@ public class LocalDrive { try { Utils.runCommand(null, sLogger, "adb", "shell", Utils.CMD_REMOVE_CONFIG, Utils.SHELL_UID, String.valueOf(configId)); Utils.getReportList(configId, true /* clearData */, sLogger); Utils.getReportList(configId, true /* clearData */, true /* SHELL_UID */, sLogger); } catch (InterruptedException | IOException e) { sLogger.severe("Failed to remove config: " + e.getMessage()); return false; Loading Loading @@ -234,7 +234,7 @@ public class LocalDrive { // Even if the args request no modifications, we still parse it to make sure it's valid. ConfigMetricsReportList reportList; try { reportList = Utils.getReportList(configId, clearData, sLogger); reportList = Utils.getReportList(configId, clearData, true /* SHELL_UID */, sLogger); } catch (IOException | InterruptedException e) { sLogger.severe("Failed to get report list: " + e.getMessage()); return false; Loading Loading @@ -278,7 +278,7 @@ public class LocalDrive { sLogger.fine(String.format("cmdClear with %d", configId)); try { Utils.getReportList(configId, true /* clearData */, sLogger); Utils.getReportList(configId, true /* clearData */, true /* SHELL_UID */, sLogger); } catch (IOException | InterruptedException e) { sLogger.severe("Failed to get report list: " + e.getMessage()); return false; Loading
cmds/statsd/tools/localtools/src/com/android/statsd/shelltools/testdrive/TestDrive.java +1 −1 Original line number Diff line number Diff line Loading @@ -165,7 +165,7 @@ public class TestDrive { } private void dumpMetrics() throws Exception { ConfigMetricsReportList reportList = Utils.getReportList(CONFIG_ID, true, logger); ConfigMetricsReportList reportList = Utils.getReportList(CONFIG_ID, true, false, logger); // We may get multiple reports. Take the last one. ConfigMetricsReport report = reportList.getReports(reportList.getReportsCount() - 1); // Really should be only one metric. Loading