blob: 9f23a39a6d366b106ac71810c09ea7ea6db90e8c [file] [log] [blame]
Colin Crossf45fa6b2012-03-26 12:38:26 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Felipe Leme8268ed22016-08-02 18:18:25 -070017#ifndef FRAMEWORK_NATIVE_CMD_DUMPSTATE_H_
18#define FRAMEWORK_NATIVE_CMD_DUMPSTATE_H_
Colin Crossf45fa6b2012-03-26 12:38:26 -070019
Felipe Lemecbce55d2016-02-08 09:53:18 -080020#ifndef MYLOGD
Felipe Leme60869c92016-02-09 16:07:20 -080021#define MYLOGD(...) fprintf(stderr, __VA_ARGS__); ALOGD(__VA_ARGS__);
Felipe Lemecbce55d2016-02-08 09:53:18 -080022#endif
23
24#ifndef MYLOGI
Felipe Leme60869c92016-02-09 16:07:20 -080025#define MYLOGI(...) fprintf(stderr, __VA_ARGS__); ALOGI(__VA_ARGS__);
Felipe Lemecbce55d2016-02-08 09:53:18 -080026#endif
27
28#ifndef MYLOGE
Felipe Leme60869c92016-02-09 16:07:20 -080029#define MYLOGE(...) fprintf(stderr, __VA_ARGS__); ALOGE(__VA_ARGS__);
Felipe Lemecbce55d2016-02-08 09:53:18 -080030#endif
Felipe Leme93d705b2015-11-10 20:10:25 -080031
Colin Crossf45fa6b2012-03-26 12:38:26 -070032#include <time.h>
33#include <unistd.h>
Colin Cross0c22e8b2012-11-02 15:46:56 -070034#include <stdbool.h>
Colin Crossf45fa6b2012-03-26 12:38:26 -070035#include <stdio.h>
Felipe Leme30dbfa12016-09-02 12:43:26 -070036
37#include <string>
Felipe Leme36b3f6f2015-11-19 15:41:04 -080038#include <vector>
Colin Crossf45fa6b2012-03-26 12:38:26 -070039
Felipe Lemec6bc8bc2016-10-27 15:58:27 -070040#include <android-base/macros.h>
41#include <ziparchive/zip_writer.h>
42
Felipe Lemebda15a02016-11-16 17:48:25 -080043#include "DumpstateUtil.h"
Felipe Leme75876a22016-10-27 16:31:27 -070044#include "android/os/BnDumpstate.h"
45
Felipe Leme35c94f32016-08-12 10:51:54 -070046// Workaround for const char *args[MAX_ARGS_ARRAY_SIZE] variables until they're converted to
47// std::vector<std::string>
Felipe Leme30dbfa12016-09-02 12:43:26 -070048// TODO: remove once not used
Felipe Leme35c94f32016-08-12 10:51:54 -070049#define MAX_ARGS_ARRAY_SIZE 1000
50
Felipe Leme30dbfa12016-09-02 12:43:26 -070051// TODO: remove once moved to HAL
Felipe Leme8620bb42015-11-10 11:04:45 -080052#ifdef __cplusplus
53extern "C" {
54#endif
55
Felipe Leme30dbfa12016-09-02 12:43:26 -070056/*
Felipe Leme30dbfa12016-09-02 12:43:26 -070057 * Helper class used to report how long it takes for a section to finish.
58 *
59 * Typical usage:
60 *
61 * DurationReporter duration_reporter(title);
62 *
63 */
64class DurationReporter {
65 public:
Felipe Leme678727a2016-09-21 17:22:11 -070066 DurationReporter(const std::string& title);
67 DurationReporter(const std::string& title, FILE* out);
Felipe Leme30dbfa12016-09-02 12:43:26 -070068
69 ~DurationReporter();
70
Felipe Lemeb0f669d2016-09-26 18:26:11 -070071 static uint64_t Nanotime();
Felipe Leme30dbfa12016-09-02 12:43:26 -070072
73 private:
74 // TODO: use std::string for title, once dump_files() and other places that pass a char* are
75 // refactored as well.
Felipe Leme678727a2016-09-21 17:22:11 -070076 std::string title_;
Felipe Lemeb0f669d2016-09-26 18:26:11 -070077 FILE* out_;
78 uint64_t started_;
Felipe Leme062926e2016-10-27 15:51:12 -070079
80 DISALLOW_COPY_AND_ASSIGN(DurationReporter);
Felipe Leme30dbfa12016-09-02 12:43:26 -070081};
82
83/*
Felipe Leme7447d7c2016-11-03 18:12:22 -070084 * Keeps track of current progress and estimated max, saving stats on file to tune up future runs.
Felipe Leme71bbfc52015-11-23 14:14:51 -080085 *
Felipe Leme7447d7c2016-11-03 18:12:22 -070086 * Each `dumpstate` section contributes to the total weight by an individual weight, so the overall
87 * progress can be calculated by dividing the estimate max progress by the current progress.
Felipe Leme71bbfc52015-11-23 14:14:51 -080088 *
Felipe Leme7447d7c2016-11-03 18:12:22 -070089 * The estimated max progress is initially set to a value (`kDefaultMax) defined empirically, but
90 * it's adjusted after each dumpstate run by storing the average duration in a file.
Felipe Lemead5f6c42015-11-30 14:26:46 -080091 *
Felipe Leme71bbfc52015-11-23 14:14:51 -080092 */
Felipe Leme7447d7c2016-11-03 18:12:22 -070093class Progress {
94 friend class ProgressTest;
95 friend class DumpstateTest;
96
97 public:
98 /*
99 * Default estimation of the max duration of a bugreport generation.
100 *
101 * It does not need to match the exact sum of all sections, but ideally it should to be slight
102 * more than such sum: a value too high will cause the bugreport to finish before the user
103 * expected (for example, jumping from 70% to 100%), while a value too low will cause the
104 * progress to get stuck at an almost-finished value (like 99%) for a while.
105 *
106 * This constant is only used when the average duration from previous runs cannot be used.
107 */
108 static const int kDefaultMax;
109
110 Progress(const std::string& path = "");
111
112 // Gets the current progress.
113 int32_t Get() const;
114
115 // Gets the current estimated max progress.
116 int32_t GetMax() const;
117
118 // Gets the initial estimated max progress.
119 int32_t GetInitialMax() const;
120
121 // Increments progress (ignored if not positive).
122 // Returns `true` if the max progress increased as well.
123 bool Inc(int32_t delta);
124
125 // Persist the stats.
126 void Save();
127
128 void Dump(int fd, const std::string& prefix) const;
129
130 private:
131 Progress(int32_t initial_max, float growth_factor,
132 const std::string& path = ""); // Used by test cases.
133 Progress(int32_t initial_max, int32_t progress, float growth_factor); // Used by test cases.
134 void Load();
135 int32_t initial_max_;
136 int32_t progress_;
137 int32_t max_;
138 float growth_factor_;
139 int32_t n_runs_;
140 int32_t average_max_;
141 const std::string& path_;
142};
Felipe Leme71bbfc52015-11-23 14:14:51 -0800143
Felipe Leme71bbfc52015-11-23 14:14:51 -0800144/*
Felipe Lemebbaf3c12016-10-11 14:32:25 -0700145 * List of supported zip format versions.
146 *
147 * See bugreport-format.md for more info.
148 */
Felipe Lemed071c682016-10-20 16:48:00 -0700149static std::string VERSION_CURRENT = "1.0";
150
151/*
Felipe Lemee184f662016-10-27 10:04:47 -0700152 * Temporary version that adds a anr-traces.txt entry. Once tools support it, the current version
153 * will be bumped to 2.0-dev-1.
154 */
155static std::string VERSION_SPLIT_ANR = "2.0-dev-1";
156
157/*
Felipe Lemed071c682016-10-20 16:48:00 -0700158 * "Alias" for the current version.
159 */
160static std::string VERSION_DEFAULT = "default";
Felipe Lemebbaf3c12016-10-11 14:32:25 -0700161
162/*
Felipe Lemee844a9d2016-09-21 15:01:39 -0700163 * Main class driving a bugreport generation.
164 *
165 * Currently, it only contains variables that are accessed externally, but gradually the functions
166 * that are spread accross utils.cpp and dumpstate.cpp will be moved to it.
167 */
168class Dumpstate {
Felipe Leme4c2d6632016-09-28 14:32:00 -0700169 friend class DumpstateTest;
170
Felipe Lemee844a9d2016-09-21 15:01:39 -0700171 public:
Felipe Lemebda15a02016-11-16 17:48:25 -0800172 static CommandOptions DEFAULT_DUMPSYS;
173
Felipe Lemee844a9d2016-09-21 15:01:39 -0700174 static Dumpstate& GetInstance();
Felipe Leme71bbfc52015-11-23 14:14:51 -0800175
Felipe Lemee844a9d2016-09-21 15:01:39 -0700176 /*
177 * When running in dry-run mode, skips the real dumps and just print the section headers.
178 *
179 * Useful when debugging dumpstate or other bugreport-related activities.
180 *
181 * Dry-run mode is enabled by setting the system property dumpstate.dry_run to true.
182 */
Felipe Leme2b9b06c2016-10-14 09:13:06 -0700183 bool IsDryRun() const;
Felipe Leme71ca15e2016-05-19 16:18:17 -0700184
Felipe Leme678727a2016-09-21 17:22:11 -0700185 /*
Felipe Leme6ad9c062016-09-28 11:58:36 -0700186 * Gets whether device is running a `user` build.
187 */
Felipe Leme2b9b06c2016-10-14 09:13:06 -0700188 bool IsUserBuild() const;
Felipe Leme6ad9c062016-09-28 11:58:36 -0700189
Felipe Leme1d486fe2016-10-14 18:06:47 -0700190 /* Checkes whether dumpstate is generating a zipped bugreport. */
191 bool IsZipping() const;
192
Felipe Leme6ad9c062016-09-28 11:58:36 -0700193 /*
Felipe Leme678727a2016-09-21 17:22:11 -0700194 * Forks a command, waits for it to finish, and returns its status.
195 *
196 * |title| description of the command printed on `stdout` (or empty to skip
197 * description).
198 * |full_command| array containing the command (first entry) and its arguments.
199 * Must contain at least one element.
200 * |options| optional argument defining the command's behavior.
201 */
202 int RunCommand(const std::string& title, const std::vector<std::string>& fullCommand,
203 const CommandOptions& options = CommandOptions::DEFAULT);
204
205 /*
206 * Runs `dumpsys` with the given arguments, automatically setting its timeout
207 * (`-t` argument)
208 * according to the command options.
209 *
210 * |title| description of the command printed on `stdout` (or empty to skip
211 * description).
212 * |dumpsys_args| `dumpsys` arguments (except `-t`).
213 * |options| optional argument defining the command's behavior.
Felipe Leme9a523ae2016-10-20 15:10:33 -0700214 * |dumpsys_timeout| when > 0, defines the value passed to `dumpsys -t` (otherwise it uses the
Felipe Leme6ad9c062016-09-28 11:58:36 -0700215 * timeout from `options`)
Felipe Leme678727a2016-09-21 17:22:11 -0700216 */
Felipe Leme9a523ae2016-10-20 15:10:33 -0700217 void RunDumpsys(const std::string& title, const std::vector<std::string>& dumpsys_args,
Felipe Lemebda15a02016-11-16 17:48:25 -0800218 const CommandOptions& options = DEFAULT_DUMPSYS, long dumpsys_timeout = 0);
Felipe Leme678727a2016-09-21 17:22:11 -0700219
220 /*
221 * Prints the contents of a file.
222 *
223 * |title| description of the command printed on `stdout` (or empty to skip
224 * description).
225 * |path| location of the file to be dumped.
226 */
227 int DumpFile(const std::string& title, const std::string& path);
228
Felipe Lemebbaf3c12016-10-11 14:32:25 -0700229 /*
Felipe Leme1d486fe2016-10-14 18:06:47 -0700230 * Adds a new entry to the existing zip file.
231 * */
232 bool AddZipEntry(const std::string& entry_name, const std::string& entry_path);
233
234 /*
235 * Adds a new entry to the existing zip file.
236 */
237 bool AddZipEntryFromFd(const std::string& entry_name, int fd);
238
239 /*
240 * Adds a text entry entry to the existing zip file.
241 */
242 bool AddTextZipEntry(const std::string& entry_name, const std::string& content);
243
244 /*
245 * Adds all files from a directory to the zipped bugreport file.
246 */
247 void AddDir(const std::string& dir, bool recursive);
248
249 /*
Felipe Lemebbaf3c12016-10-11 14:32:25 -0700250 * Takes a screenshot and save it to the given `path`.
251 *
252 * If `path` is empty, uses a standard path based on the bugreport name.
253 */
254 void TakeScreenshot(const std::string& path = "");
255
Felipe Leme7447d7c2016-11-03 18:12:22 -0700256 /////////////////////////////////////////////////////////////////////
257 // TODO: members below should be private once refactor is finished //
258 /////////////////////////////////////////////////////////////////////
259
260 // TODO: temporary method until Dumpstate object is properly set
261 void SetProgress(std::unique_ptr<Progress> progress);
Felipe Lemed80e6b62016-10-03 13:08:14 -0700262
263 /*
264 * Updates the overall progress of the bugreport generation by the given weight increment.
265 */
Felipe Leme7447d7c2016-11-03 18:12:22 -0700266 void UpdateProgress(int32_t delta);
Felipe Lemed80e6b62016-10-03 13:08:14 -0700267
Felipe Lemebbaf3c12016-10-11 14:32:25 -0700268 /* Prints the dumpstate header on `stdout`. */
Felipe Leme2b9b06c2016-10-14 09:13:06 -0700269 void PrintHeader() const;
Felipe Lemebbaf3c12016-10-11 14:32:25 -0700270
Felipe Leme1d486fe2016-10-14 18:06:47 -0700271 /*
272 * Adds the temporary report to the existing .zip file, closes the .zip file, and removes the
273 * temporary file.
274 */
275 bool FinishZipFile();
276
Felipe Lemebbaf3c12016-10-11 14:32:25 -0700277 /* Gets the path of a bugreport file with the given suffix. */
Felipe Leme2b9b06c2016-10-14 09:13:06 -0700278 std::string GetPath(const std::string& suffix) const;
Felipe Lemebbaf3c12016-10-11 14:32:25 -0700279
Felipe Lemee844a9d2016-09-21 15:01:39 -0700280 // TODO: initialize fields on constructor
281
282 // dumpstate id - unique after each device reboot.
Felipe Leme7447d7c2016-11-03 18:12:22 -0700283 uint32_t id_;
Felipe Lemee844a9d2016-09-21 15:01:39 -0700284
Felipe Leme75876a22016-10-27 16:31:27 -0700285 // dumpstate pid
286 pid_t pid_;
287
Felipe Lemee844a9d2016-09-21 15:01:39 -0700288 // Whether progress updates should be published.
Felipe Leme9a523ae2016-10-20 15:10:33 -0700289 bool update_progress_ = false;
Felipe Lemee844a9d2016-09-21 15:01:39 -0700290
Felipe Leme009ecbb2016-11-07 10:18:44 -0800291 // How frequently the progess should be updated;the listener will only be notificated when the
292 // delta from the previous update is more than the threshold.
293 int32_t update_progress_threshold_ = 100;
294
295 // Last progress that triggered a listener updated
296 int32_t last_updated_progress_;
297
Felipe Lemebbaf3c12016-10-11 14:32:25 -0700298 // Whether it should take an screenshot earlier in the process.
Felipe Leme9a523ae2016-10-20 15:10:33 -0700299 bool do_early_screenshot_ = false;
Felipe Lemebbaf3c12016-10-11 14:32:25 -0700300
Felipe Leme7447d7c2016-11-03 18:12:22 -0700301 std::unique_ptr<Progress> progress_;
Felipe Lemee844a9d2016-09-21 15:01:39 -0700302
303 // When set, defines a socket file-descriptor use to report progress to bugreportz.
Felipe Leme9a523ae2016-10-20 15:10:33 -0700304 int control_socket_fd_ = -1;
Felipe Lemee844a9d2016-09-21 15:01:39 -0700305
Felipe Lemebbaf3c12016-10-11 14:32:25 -0700306 // Bugreport format version;
Felipe Lemed071c682016-10-20 16:48:00 -0700307 std::string version_ = VERSION_CURRENT;
Felipe Lemee844a9d2016-09-21 15:01:39 -0700308
Felipe Lemebbaf3c12016-10-11 14:32:25 -0700309 // Command-line arguments as string
310 std::string args_;
311
312 // Extra options passed as system property.
Felipe Leme9a523ae2016-10-20 15:10:33 -0700313 std::string extra_options_;
Felipe Lemebbaf3c12016-10-11 14:32:25 -0700314
315 // Full path of the directory where the bugreport files will be written.
Felipe Leme9a523ae2016-10-20 15:10:33 -0700316 std::string bugreport_dir_;
Felipe Lemee844a9d2016-09-21 15:01:39 -0700317
Felipe Lemebbaf3c12016-10-11 14:32:25 -0700318 // Full path of the temporary file containing the screenshot (when requested).
Felipe Leme9a523ae2016-10-20 15:10:33 -0700319 std::string screenshot_path_;
Felipe Lemebbaf3c12016-10-11 14:32:25 -0700320
321 time_t now_;
322
Felipe Leme2b9b06c2016-10-14 09:13:06 -0700323 // Base name (without suffix or extensions) of the bugreport files, typically
324 // `bugreport-BUILD_ID`.
Felipe Leme9a523ae2016-10-20 15:10:33 -0700325 std::string base_name_;
Felipe Lemebbaf3c12016-10-11 14:32:25 -0700326
Felipe Leme2b9b06c2016-10-14 09:13:06 -0700327 // Name is the suffix part of the bugreport files - it's typically the date (when invoked with
328 // `-d`), but it could be changed by the user..
329 std::string name_;
330
Felipe Leme1d486fe2016-10-14 18:06:47 -0700331 // Full path of the temporary file containing the bugreport.
Felipe Leme9a523ae2016-10-20 15:10:33 -0700332 std::string tmp_path_;
Felipe Leme1d486fe2016-10-14 18:06:47 -0700333
334 // Full path of the file containing the dumpstate logs.
Felipe Leme9a523ae2016-10-20 15:10:33 -0700335 std::string log_path_;
Felipe Leme1d486fe2016-10-14 18:06:47 -0700336
337 // Pointer to the actual path, be it zip or text.
Felipe Leme9a523ae2016-10-20 15:10:33 -0700338 std::string path_;
Felipe Leme1d486fe2016-10-14 18:06:47 -0700339
340 // Pointer to the zipped file.
341 std::unique_ptr<FILE, int (*)(FILE*)> zip_file{nullptr, fclose};
342
Felipe Lemec6bc8bc2016-10-27 15:58:27 -0700343 // Pointer to the zip structure.
344 std::unique_ptr<ZipWriter> zip_writer_;
345
Felipe Leme75876a22016-10-27 16:31:27 -0700346 // Binder object listing to progress.
347 android::sp<android::os::IDumpstateListener> listener_;
348 std::string listener_name_;
349
Felipe Lemee844a9d2016-09-21 15:01:39 -0700350 private:
Felipe Lemed80e6b62016-10-03 13:08:14 -0700351 // Used by GetInstance() only.
Felipe Lemed071c682016-10-20 16:48:00 -0700352 Dumpstate(const std::string& version = VERSION_CURRENT, bool dry_run = false,
353 const std::string& build_type = "user");
Felipe Lemed80e6b62016-10-03 13:08:14 -0700354
Felipe Leme4c2d6632016-09-28 14:32:00 -0700355 // Whether this is a dry run.
Felipe Leme9a523ae2016-10-20 15:10:33 -0700356 bool dry_run_;
Felipe Leme4c2d6632016-09-28 14:32:00 -0700357
Felipe Lemed80e6b62016-10-03 13:08:14 -0700358 // Build type (such as 'user' or 'eng').
Felipe Leme9a523ae2016-10-20 15:10:33 -0700359 std::string build_type_;
Felipe Leme062926e2016-10-27 15:51:12 -0700360
361 DISALLOW_COPY_AND_ASSIGN(Dumpstate);
Felipe Lemee844a9d2016-09-21 15:01:39 -0700362};
363
364// for_each_pid_func = void (*)(int, const char*);
365// for_each_tid_func = void (*)(int, int, const char*);
366
367typedef void(for_each_pid_func)(int, const char*);
368typedef void(for_each_tid_func)(int, int, const char*);
Felipe Leme71ca15e2016-05-19 16:18:17 -0700369
Felipe Leme71a74ac2016-03-17 15:43:25 -0700370/* saves the the contents of a file as a long */
371int read_file_as_long(const char *path, long int *output);
372
Christopher Ferris54bcc5f2015-02-10 12:15:01 -0800373/* prints the contents of the fd
374 * fd must have been opened with the flag O_NONBLOCK.
375 */
Christopher Ferris1fe61072014-07-22 16:08:19 -0700376int dump_file_from_fd(const char *title, const char *path, int fd);
Colin Crossf45fa6b2012-03-26 12:38:26 -0700377
Mark Salyzyn326842f2015-04-30 09:49:41 -0700378/* calls skip to gate calling dump_from_fd recursively
379 * in the specified directory. dump_from_fd defaults to
380 * dump_file_from_fd above when set to NULL. skip defaults
381 * to false when set to NULL. dump_from_fd will always be
382 * called with title NULL.
383 */
Felipe Leme678727a2016-09-21 17:22:11 -0700384int dump_files(const std::string& title, const char* dir, bool (*skip)(const char* path),
385 int (*dump_from_fd)(const char* title, const char* path, int fd));
Mark Salyzyn326842f2015-04-30 09:49:41 -0700386
Felipe Lemecf6a8b42016-03-11 10:38:19 -0800387/* switch to non-root user and group */
388bool drop_root_user();
Felipe Leme93d705b2015-11-10 20:10:25 -0800389
Felipe Leme36b3f6f2015-11-19 15:41:04 -0800390/* sends a broadcast using Activity Manager */
391void send_broadcast(const std::string& action, const std::vector<std::string>& args);
392
Colin Crossf45fa6b2012-03-26 12:38:26 -0700393/* prints all the system properties */
394void print_properties();
395
Felipe Leme2628e9e2016-04-12 16:36:51 -0700396/** opens a socket and returns its file descriptor */
397int open_socket(const char *service);
398
Colin Crossf45fa6b2012-03-26 12:38:26 -0700399/* redirect output to a service control socket */
400void redirect_to_socket(FILE *redirect, const char *service);
401
Felipe Leme0f3fb202016-06-10 17:10:53 -0700402/* redirect output to a new file */
Christopher Ferrisff4a4dc2015-02-09 16:24:47 -0800403void redirect_to_file(FILE *redirect, char *path);
Colin Crossf45fa6b2012-03-26 12:38:26 -0700404
Felipe Leme0f3fb202016-06-10 17:10:53 -0700405/* redirect output to an existing file */
406void redirect_to_existing_file(FILE *redirect, char *path);
407
Felipe Leme111b9d02016-02-03 09:28:24 -0800408/* create leading directories, if necessary */
409void create_parent_dirs(const char *path);
410
Jeff Brownbf7f4922012-06-07 16:40:01 -0700411/* dump Dalvik and native stack traces, return the trace file location (NULL if none) */
412const char *dump_traces();
Colin Crossf45fa6b2012-03-26 12:38:26 -0700413
414/* for each process in the system, run the specified function */
Colin Cross0c22e8b2012-11-02 15:46:56 -0700415void for_each_pid(for_each_pid_func func, const char *header);
416
417/* for each thread in the system, run the specified function */
418void for_each_tid(for_each_tid_func func, const char *header);
Colin Crossf45fa6b2012-03-26 12:38:26 -0700419
420/* Displays a blocked processes in-kernel wait channel */
Colin Cross0c22e8b2012-11-02 15:46:56 -0700421void show_wchan(int pid, int tid, const char *name);
Colin Crossf45fa6b2012-03-26 12:38:26 -0700422
Mark Salyzyna297c322016-02-05 15:33:17 -0800423/* Displays a processes times */
424void show_showtime(int pid, const char *name);
425
Colin Crossf45fa6b2012-03-26 12:38:26 -0700426/* Runs "showmap" for a process */
427void do_showmap(int pid, const char *name);
428
429/* Gets the dmesg output for the kernel */
430void do_dmesg();
431
Sreeram Ramachandran2b3bba32014-07-08 15:40:55 -0700432/* Prints the contents of all the routing tables, both IPv4 and IPv6. */
433void dump_route_tables();
434
Colin Crossf45fa6b2012-03-26 12:38:26 -0700435/* Play a sound via Stagefright */
Christopher Ferris1fe61072014-07-22 16:08:19 -0700436void play_sound(const char *path);
Colin Crossf45fa6b2012-03-26 12:38:26 -0700437
438/* Implemented by libdumpstate_board to dump board-specific info */
439void dumpstate_board();
440
Felipe Leme0c80cf02016-01-05 13:25:34 -0800441/* Vibrates for a given durating (in milliseconds). */
442void vibrate(FILE* vibrator, int ms);
443
444/* Checks if a given path is a directory. */
445bool is_dir(const char* pathname);
446
447/** Gets the last modification time of a file, or default time if file is not found. */
448time_t get_mtime(int fd, time_t default_mtime);
449
Calvin On249beee2016-06-03 15:17:07 -0700450/* Dumps eMMC Extended CSD data. */
Felipe Leme78f2c862015-12-21 09:55:22 -0800451void dump_emmc_ecsd(const char *ext_csd_path);
452
Calvin On249beee2016-06-03 15:17:07 -0700453/** Gets command-line arguments. */
Felipe Lemea34efb72016-03-11 09:33:32 -0800454void format_args(int argc, const char *argv[], std::string *args);
Felipe Leme88c79332016-02-22 11:06:49 -0800455
Calvin On249beee2016-06-03 15:17:07 -0700456/** Tells if the device is running a user build. */
457bool is_user_build();
458
Felipe Leme8620bb42015-11-10 11:04:45 -0800459#ifdef __cplusplus
460}
461#endif
462
Felipe Leme8268ed22016-08-02 18:18:25 -0700463#endif /* FRAMEWORK_NATIVE_CMD_DUMPSTATE_H_ */