Copy Kernel Logs

Give user option to copy kernel logs to current storage

Change-Id: I0c61122fb34826ddb08977e6cbf98e3adf477acd
This commit is contained in:
bigbiff bigbiff
2016-07-29 21:18:13 -04:00
parent 3fdcda4662
commit bad332a3d1
7 changed files with 136 additions and 32 deletions
+9 -3
View File
@@ -639,13 +639,19 @@ int GUIAction::copylog(std::string arg __unused)
operation_start("Copy Log");
if (!simulate)
{
string dst;
string dst, curr_storage;
int copy_kernel_log = 0;
DataManager::GetValue("tw_include_kernel_log", copy_kernel_log);
PartitionManager.Mount_Current_Storage(true);
dst = DataManager::GetCurrentStoragePath() + "/recovery.log";
curr_storage = DataManager::GetCurrentStoragePath();
dst = curr_storage + "/recovery.log";
TWFunc::copy_file("/tmp/recovery.log", dst.c_str(), 0755);
tw_set_default_metadata(dst.c_str());
if (copy_kernel_log)
TWFunc::copy_kernel_log(curr_storage);
sync();
gui_msg(Msg("copy_log=Copied recovery log to {1}.")(DataManager::GetCurrentStoragePath()));
gui_msg(Msg("copy_log=Copied recovery log to {1}")(dst));
} else
simulate_progress_bar();
operation_end(0);
+40 -9
View File
@@ -3132,6 +3132,45 @@
</action>
</page>
<page name="copylog">
<template name="page"/>
<text style="text_l">
<placement x="%col1_x_header%" y="%row3_header_y%"/>
<text>{@copying_log=Copy Logs to SD Card}</text>
</text>
<checkbox>
<placement x="%indent%" y="%row4_y%"/>
<text>{@include_kernel_log=Include Kernel Log}</text>
<data variable="tw_include_kernel_log" value="1"/>
</checkbox>
<slider>
<text>{@copying_log=Copy Logs to SD Card}</text>
<actions>
<action function="set">tw_back=advanced</action>
<action function="set">tw_action=copylog</action>
<action function="set">tw_action_text1={@copying_log=Copy Logs to SD Card}</action>
<action function="set">tw_complete_text1={@copy_log_complete=Logs Copy Completed}</action>
<action function="page">action_page</action>
</actions>
</slider>
<action>
<touch key="home"/>
<action function="page">main</action>
</action>
<action>
<touch key="back"/>
<actions>
<action function="page">advanced</action>
</actions>
</action>
</page>
<page name="advanced">
<template name="page"/>
@@ -3143,15 +3182,7 @@
<button style="main_button">
<placement x="%col1_x_left%" y="%row2_y%"/>
<text>{@copy_log_btn=Copy Log}</text>
<actions>
<action function="set">tw_back=advanced</action>
<action function="set">tw_action=copylog</action>
<action function="set">tw_text1={@copy_log_confirm=Copy Log to SD Card?}</action>
<action function="set">tw_action_text1={@copying_log=Copying Log to SD Card...}</action>
<action function="set">tw_complete_text1={@copy_log_complete=Log Copy Complete}</action>
<action function="set">tw_slider_text={@swipe_to_confirm=Swipe to Confirm}</action>
<action function="page">confirm_action</action>
</actions>
<action function="page">copylog</action>
</button>
<button style="main_button">
+4 -2
View File
@@ -364,8 +364,8 @@
<string name="set_language_btn">Set Language</string>
<string name="advanced_hdr">Advanced</string>
<string name="copy_log_confirm">Copy Log to SD Card?</string>
<string name="copying_log">Copying Log to SD Card...</string>
<string name="copy_log_complete">Log Copy Complete</string>
<string name="copying_log" version="2">Copying Logs to SD Card...</string>
<string name="copy_log_complete" version="2">Logs Copy Complete</string>
<string name="fix_context_btn">Fix Contexts</string>
<string name="part_sd_btn">Partition SD Card</string>
<string name="part_sd_s_btn">SD Card</string>
@@ -673,5 +673,7 @@
<string name="adbbackup_control_error">Cannot write to adb control channel</string>
<string name="twrp_adbbu_option">--twrp option is required to enable twrp adb backup</string>
<string name="partition_not_found">path: {1} not found in partititon list</string>
<string name="copy_kernel_log">Copied kernel log to {1}</string>
<string name="include_kernel_log">Include Kernel Log</string>
</resources>
</language>
+40 -9
View File
@@ -3216,6 +3216,45 @@
</action>
</page>
<page name="copylog">
<template name="page"/>
<text style="text_l">
<placement x="%col1_x_header%" y="%row3_header_y%"/>
<text>{@copying_log=Copy Logs to SD Card}</text>
</text>
<checkbox>
<placement x="%indent%" y="%row4_y%"/>
<text>{@include_kernel_log=Include Kernel Log}</text>
<data variable="tw_include_kernel_log" value="1"/>
</checkbox>
<slider>
<text>{@copying_log=Copy Logs to SD Card}</text>
<actions>
<action function="set">tw_back=advanced</action>
<action function="set">tw_action=copylog</action>
<action function="set">tw_action_text1={@copying_log=Copy Logs to SD Card}</action>
<action function="set">tw_complete_text1={@copy_log_complete=Logs Copy Completed}</action>
<action function="page">action_page</action>
</actions>
</slider>
<action>
<touch key="home"/>
<action function="page">main</action>
</action>
<action>
<touch key="back"/>
<actions>
<action function="page">advanced</action>
</actions>
</action>
</page>
<page name="advanced">
<template name="page"/>
@@ -3227,15 +3266,7 @@
<button style="main_button">
<placement x="%indent%" y="%row2a_y%"/>
<text>{@copy_log_btn=Copy Log}</text>
<actions>
<action function="set">tw_back=advanced</action>
<action function="set">tw_action=copylog</action>
<action function="set">tw_text1={@copy_log_confirm=Copy Log to SD Card?}</action>
<action function="set">tw_action_text1={@copying_log=Copying Log to SD Card...}</action>
<action function="set">tw_complete_text1={@copy_log_complete=Log Copy Complete}</action>
<action function="set">tw_slider_text={@swipe_to_confirm=Swipe to Confirm}</action>
<action function="page">confirm_action</action>
</actions>
<action function="page">copylog</action>
</button>
<button style="main_button">
+32 -9
View File
@@ -237,6 +237,37 @@
</button>
</page>
<page name="copylog">
<template name="page"/>
<checkbox>
<placement x="%indent%" y="%row1_y%"/>
<text>{@include_kernel_log=Include Kernel Log}</text>
<data variable="tw_include_kernel_log" value="1"/>
</checkbox>
<slider>
<text>{@swipe_confirm= Confirm}</text>
<actions>
<action function="set">tw_back=main3</action>
<action function="set">tw_action=copylog</action>
<action function="set">tw_action_text1={@copying_log=Copy Logs to SD Card}</action>
<action function="set">tw_complete_text1={@copy_log_complete=Logs Copy Completed}</action>
<action function="page">action_page</action>
</actions>
</slider>
<action>
<touch key="back"/>
<action function="page">main2</action>
</action>
<action>
<touch key="home"/>
<action function="page">main</action>
</action>
</page>
<page name="main3">
<template name="page"/>
@@ -261,15 +292,7 @@
<button style="main_button">
<placement x="%col1_x_right%" y="%row6_y%"/>
<text>{@copy_log_btn=Copy Log}</text>
<actions>
<action function="set">tw_back=main3</action>
<action function="set">tw_action=copylog</action>
<action function="set">tw_text1={@copy_log_confirm=Copy Log to SD Card?}</action>
<action function="set">tw_action_text1={@copying_log=Copying Log to SD Card...}</action>
<action function="set">tw_complete_text1={@copy_log_complete=Log Copy Complete}</action>
<action function="set">tw_slider_text={@swipe_confirm= Confirm}</action>
<action function="page">confirm_action</action>
</actions>
<action function="page">copylog</action>
</button>
<button style="main_button">
+10
View File
@@ -1070,4 +1070,14 @@ unsigned long long TWFunc::IOCTL_Get_Block_Size(const char* block_device) {
return 0;
}
void TWFunc::copy_kernel_log(string curr_storage) {
std::string dmesgDst = curr_storage + "/dmesg.log";
std::string dmesgCmd = "/sbin/dmesg";
std::string result;
Exec_Cmd(dmesgCmd, result);
write_file(dmesgDst, result);
gui_msg(Msg("copy_kernel_log=Copied kernel log to {1}")(dmesgDst));
tw_set_default_metadata(dmesgDst.c_str());
}
#endif // ndef BUILD_TWRPTAR_MAIN
+1
View File
@@ -94,6 +94,7 @@ public:
static void SetPerformanceMode(bool mode); // support recovery.perf.mode
static void Disable_Stock_Recovery_Replace(); // Disable stock ROMs from replacing TWRP with stock recovery
static unsigned long long IOCTL_Get_Block_Size(const char* block_device);
static void copy_kernel_log(string curr_storage); // Copy Kernel Log to Current Storage (PSTORE/KMSG)
private:
static void Copy_Log(string Source, string Destination);