[core] Force logging on boot (#996)
This commit is contained in:
parent
0e20e5cd7e
commit
24120e75ad
|
|
@ -67,8 +67,6 @@ import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import rikka.core.os.FileUtils;
|
import rikka.core.os.FileUtils;
|
||||||
import rikka.core.res.ResourcesKt;
|
|
||||||
import rikka.insets.WindowInsetsHelperKt;
|
|
||||||
import rikka.recyclerview.RecyclerViewKt;
|
import rikka.recyclerview.RecyclerViewKt;
|
||||||
|
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
|
|
@ -114,28 +112,23 @@ public class LogsFragment extends BaseFragment {
|
||||||
binding.recyclerView.getBorderViewDelegate().setBorderVisibilityChangedListener((top, oldTop, bottom, oldBottom) -> binding.appBar.setRaised(!top));
|
binding.recyclerView.getBorderViewDelegate().setBorderVisibilityChangedListener((top, oldTop, bottom, oldBottom) -> binding.appBar.setRaised(!top));
|
||||||
|
|
||||||
|
|
||||||
if (!ConfigManager.isVerboseLogEnabled()) {
|
binding.slidingTabs.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||||
WindowInsetsHelperKt.setInitialPadding(binding.recyclerView, 0, ResourcesKt.resolveDimensionPixelOffset(requireActivity().getTheme(), androidx.appcompat.R.attr.actionBarSize, 0), 0, 0);
|
@Override
|
||||||
binding.slidingTabs.setVisibility(View.GONE);
|
public void onTabSelected(TabLayout.Tab tab) {
|
||||||
} else {
|
verbose = tab.getPosition() == 1;
|
||||||
binding.slidingTabs.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
reloadErrorLog();
|
||||||
@Override
|
}
|
||||||
public void onTabSelected(TabLayout.Tab tab) {
|
|
||||||
verbose = tab.getPosition() == 1;
|
|
||||||
reloadErrorLog();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTabUnselected(TabLayout.Tab tab) {
|
public void onTabUnselected(TabLayout.Tab tab) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTabReselected(TabLayout.Tab tab) {
|
public void onTabReselected(TabLayout.Tab tab) {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
adapter = new LogsAdapter();
|
adapter = new LogsAdapter();
|
||||||
RecyclerViewKt.fixEdgeEffect(binding.recyclerView, false, true);
|
RecyclerViewKt.fixEdgeEffect(binding.recyclerView, false, true);
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ private:
|
||||||
size_t verbose_file_part_ = 0;
|
size_t verbose_file_part_ = 0;
|
||||||
size_t verbose_print_count_ = 0;
|
size_t verbose_print_count_ = 0;
|
||||||
|
|
||||||
bool verbose_ = false;
|
bool verbose_ = true;
|
||||||
|
|
||||||
const std::string start_verbose_inst_ = "!!start_verbose!!";
|
const std::string start_verbose_inst_ = "!!start_verbose!!";
|
||||||
const std::string stop_verbose_inst_ = "!!stop_verbose!!";
|
const std::string stop_verbose_inst_ = "!!stop_verbose!!";
|
||||||
|
|
@ -124,8 +124,8 @@ void Logcat::ProcessBuffer(struct log_msg *buf) {
|
||||||
if (entry.pid == getpid() && tag == "LSPosedLogcat") [[unlikely]] {
|
if (entry.pid == getpid() && tag == "LSPosedLogcat") [[unlikely]] {
|
||||||
if (std::string_view(entry.message).starts_with(start_verbose_inst_)) {
|
if (std::string_view(entry.message).starts_with(start_verbose_inst_)) {
|
||||||
verbose_ = true;
|
verbose_ = true;
|
||||||
RefreshFd(true);
|
|
||||||
id_ = std::string(entry.message, start_verbose_inst_.length(), std::string::npos);
|
id_ = std::string(entry.message, start_verbose_inst_.length(), std::string::npos);
|
||||||
|
verbose_print_count_ += PrintLogLine(entry, verbose_file_.get());
|
||||||
} else if (std::string_view(entry.message) == stop_verbose_inst_ + id_) {
|
} else if (std::string_view(entry.message) == stop_verbose_inst_ + id_) {
|
||||||
verbose_ = false;
|
verbose_ = false;
|
||||||
}
|
}
|
||||||
|
|
@ -135,6 +135,7 @@ void Logcat::ProcessBuffer(struct log_msg *buf) {
|
||||||
void Logcat::Run() {
|
void Logcat::Run() {
|
||||||
constexpr size_t tail_after_crash = 10U;
|
constexpr size_t tail_after_crash = 10U;
|
||||||
size_t tail = 0;
|
size_t tail = 0;
|
||||||
|
RefreshFd(true);
|
||||||
RefreshFd(false);
|
RefreshFd(false);
|
||||||
while (true) {
|
while (true) {
|
||||||
std::unique_ptr<logger_list, decltype(&android_logger_list_free)> logger_list{
|
std::unique_ptr<logger_list, decltype(&android_logger_list_free)> logger_list{
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,6 @@ public class LogcatService implements Runnable {
|
||||||
id++;
|
id++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public File getVerboseLog() {
|
public File getVerboseLog() {
|
||||||
return verboseLog;
|
return verboseLog;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,9 +82,6 @@ public class ServiceManager {
|
||||||
|
|
||||||
logcatService = new LogcatService();
|
logcatService = new LogcatService();
|
||||||
logcatService.start();
|
logcatService.start();
|
||||||
if (ConfigManager.getInstance().verboseLog()) {
|
|
||||||
logcatService.startVerbose();
|
|
||||||
}
|
|
||||||
|
|
||||||
Process.setThreadPriority(Process.THREAD_PRIORITY_FOREGROUND);
|
Process.setThreadPriority(Process.THREAD_PRIORITY_FOREGROUND);
|
||||||
Looper.prepareMainLooper();
|
Looper.prepareMainLooper();
|
||||||
|
|
@ -124,6 +121,11 @@ public class ServiceManager {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Force logging on boot, now let's see if we need to stop logging
|
||||||
|
if (!ConfigManager.getInstance().verboseLog()) {
|
||||||
|
logcatService.stopVerbose();
|
||||||
|
}
|
||||||
|
|
||||||
Looper.loop();
|
Looper.loop();
|
||||||
throw new RuntimeException("Main thread loop unexpectedly exited");
|
throw new RuntimeException("Main thread loop unexpectedly exited");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue