1 #pragma once 2 3 #include "android_property_manager.h" 4 #include "dumper.h" 5 6 namespace modem { 7 namespace logging { 8 9 /** 10 * @brief Responsible for dumping all relevant modem logs. 11 */ 12 class ModemLogDumper { 13 public: ModemLogDumper(Dumper & dumper,AndroidPropertyManager & android_property_manager)14 ModemLogDumper(Dumper& dumper, 15 AndroidPropertyManager& android_property_manager) 16 : dumper_(dumper), android_property_manager_(android_property_manager){}; 17 18 /** 19 * @brief Dumps modem related logs and persistent files to bugreport. 20 * 21 * If PILOT and On Demand Logging are both not enabled, this method will 22 * attempt to stop modem logging, copy over the logs, and then restart so that 23 * the original logging enabled / disabled state is preserved. Additionally, 24 * all directories specified in `kLogDumpInfo` and all files in 25 * `kFileCopyInfo` will be included. 26 */ 27 void DumpModemLogs(); 28 29 private: 30 /** 31 * @brief Checks modem logging status property to assert if logging is 32 * running or not. 33 */ 34 bool isModemLoggingRunning(); 35 36 /** 37 * @brief Checks if On Demand Logging or PILOT Logging is enabled. 38 * 39 * If either of them are enabled, then the `log_path` property will no longer 40 * point to the always on logging directory. 41 */ 42 bool allowedToStopModemLogging(); 43 44 /** 45 * @brief Stops modem logging. 46 * 47 * This sets the modem logging property which in turn triggers 48 * modem_logging_control's modem_logging_stop service. Modem logging isn't 49 * guaranteed to have stopped after this call, so it's necessary to poll the 50 * status property to ensure it's stopped before proceeding. 51 */ 52 void stopModemLogging(); 53 54 /** 55 * @brief Polls modem logging status property to ensure modem logging has 56 * stopped. 57 * 58 * Even after the property is confirmed to be false, it will continue to 59 * sleep for a second to ensure that the modem_logging_stop service has exited 60 * properly. 61 */ 62 void waitForStopModemLogging(); 63 64 /** 65 * @brief Starts modem logging. 66 * 67 * This sets the modem logging property which in turn triggers 68 * modem_logging_control's modem_logging_start service. Modem logging isn't 69 * guaranteed to have started after this call, so it's necessary to poll the 70 * status property to ensure it's started before proceeding to guarantee 71 * success. 72 */ 73 void startModemLogging(); 74 75 private: 76 Dumper& dumper_; 77 AndroidPropertyManager& android_property_manager_; 78 }; 79 80 } // namespace logging 81 } // namespace modem 82