Skip to content

Comments

Min sdk binary reader coroutines deduplicate logcat reader#2

Open
evermind-zz wants to merge 15 commits intokyze8439690:masterfrom
evermind-zz:minSdk_binaryReader_coroutines_deduplicate-LogcatReader
Open

Min sdk binary reader coroutines deduplicate logcat reader#2
evermind-zz wants to merge 15 commits intokyze8439690:masterfrom
evermind-zz:minSdk_binaryReader_coroutines_deduplicate-LogcatReader

Conversation

@evermind-zz
Copy link

This is no real PR. I just have some changes that might be worth upstreaming but first I want to make sure you are interested at all. My goals were:

  • use LogcatBinaryParser (from brudasven)
  • deduplicate code (LogcatReader)
  • convert more to corroutines
  • custom output format (LogFileFormat)
  • minSdk 19

@gemini-code-assist
Copy link

Summary of Changes

Hello @evermind-zz, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors and modernizes the LogcatViewer library. The primary goal is to enhance maintainability, performance, and compatibility by introducing a dedicated LogcatReader that leverages Kotlin Coroutines and Flow for efficient log processing. It also lowers the minimum supported Android SDK to 19, integrates a binary logcat parser for improved reliability, and provides a flexible mechanism for customizing log export formats. The build system has also been updated to the latest versions.

Highlights

  • Min SDK 19 Support: The library now targets Android API level 19, expanding compatibility to older devices.
  • Logcat Reading Refactor: The core logcat reading logic has been extracted into a new LogcatReader class, promoting code deduplication and modularity.
  • Coroutine and Flow Integration: Logcat processing has been modernized using Kotlin Coroutines and Flow, enabling efficient asynchronous operations and better responsiveness.
  • Binary Logcat Parsing: The library now utilizes LogcatBinaryParser for more robust and potentially faster parsing of logcat output.
  • Customizable Log Export Format: A new LogFileFormat interface allows developers to define their own output format when exporting log files.
  • Gradle Build System Update: The project's build system has been upgraded to Gradle 9.3.0, Android Gradle Plugin 8.13.2, and Kotlin Gradle Plugin 2.2.21, along with updated dependencies.
Changelog
  • README.md
    • Added a new section "About this fork" detailing new features (min SDK 19, LogcatBinaryParser, custom output format) and internal fixes (coroutines, code deduplication).
    • Included instructions for integrating the library via JitPack.
  • build.gradle.kts
    • Upgraded Android Gradle Plugin to 8.13.2 and Kotlin Gradle Plugin to 2.2.21.
    • Lowered minSdk from 21 to 19.
    • Updated Java compatibility to version 17 and Kotlin JVM target to 17.
    • Configured maven-publish for library distribution.
    • Added Kotlin Coroutines, kotlinx-datetime, and kotlinx-io-core dependencies.
  • gradle.properties
    • Added android.useAndroidX=true for AndroidX compatibility.
  • gradle/wrapper/gradle-wrapper.properties
    • Updated Gradle wrapper to version 9.3.0.
  • gradlew
    • Added Gradle wrapper script for POSIX systems.
  • gradlew.bat
    • Added Gradle wrapper script for Windows systems.
  • jitpack.yml
    • Added JitPack configuration to specify JDK 17 and execute gradlew.
  • settings.gradle.kts
    • Introduced pluginManagement and dependencyResolutionManagement blocks for centralized repository and plugin management.
  • src/main/java/com/github/logviewer/ExportLogFileUtils.kt
    • Introduced LogFileFormat interface and defaultLogFileFormat for custom log export formatting.
    • Modified exportLogs to utilize the new LogFileFormat for writing log data.
  • src/main/java/com/github/logviewer/FloatingLogcatService.java
    • Refactored to use the new LogcatReader for all logcat reading and export operations.
    • Integrated Kotlin Coroutine Job and CoroutineScope for managing the service's lifecycle.
    • Updated intent extra key for exclude list to LogcatReader.EXCLUDE_LIST_KEY.
  • src/main/java/com/github/logviewer/LogItem.java
    • Adapted to consume de.brudaswen.android.logcat.core.data.LogcatItem objects instead of raw log strings.
    • Replaced priority field with level and updated related color and filter logic.
    • Removed internal regex patterns for log parsing.
  • src/main/java/com/github/logviewer/LogcatActivity.kt
    • Updated intent extra key for exclude list to LogcatReader.EXCLUDE_LIST_KEY.
  • src/main/java/com/github/logviewer/LogcatAdapter.java
    • Modified append method to appendList to accept and process a list of LogItems, improving batch updates.
    • Adjusted log item display in Holder.parse to use level and updated formatting.
  • src/main/java/com/github/logviewer/LogcatFragment.kt
    • Refactored to delegate logcat reading and export to the new LogcatReader.
    • Removed previous manual logcat reading thread and related state.
    • Updated argument bundle key for exclude list to LogcatReader.EXCLUDE_LIST_KEY.
  • src/main/java/com/github/logviewer/LogcatReader.kt
    • New file: Centralized logcat reading logic using LogcatBinaryParser, Kotlin Coroutines, and Flow.
    • Manages the lifecycle of logcat reading jobs.
    • Provides methods for starting, stopping, and exporting logs.
  • src/main/java/de/brudaswen/android/logcat/core/cmd/ShellCommand.kt
    • New file: Utility for executing shell commands asynchronously with coroutines.
  • src/main/java/de/brudaswen/android/logcat/core/data/LogcatItem.kt
    • New file: Data class defining the structure of a parsed logcat entry.
  • src/main/java/de/brudaswen/android/logcat/core/data/LogcatLevel.kt
    • New file: Enum for standard logcat levels.
  • src/main/java/de/brudaswen/android/logcat/core/parser/LogcatBinaryParser.kt
    • New file: Implements parsing of binary logcat streams into LogcatItem objects.
  • src/main/java/de/brudaswen/android/logcat/core/uuid/UuidV5.kt
    • New file: Helper functions for generating UUID version 5.
  • src/main/res/layout/logcat_viewer_item_logcat.xml
    • Renamed the TextView ID from tag to level for consistency with LogItem changes.
  • src/main/res/layout/logcat_viewer_item_logcat_dropdown.xml
    • Adjusted text styling for dropdown items (normal text style, smaller font size).
Activity
  • The author, evermind-zz, has implemented a significant refactoring and modernization of the LogcatViewer library.
  • The pull request description indicates these changes are being presented for potential upstreaming, suggesting an initial proposal rather than a completed review cycle.
  • No specific review comments or further activity are available in the provided context.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a significant and valuable refactoring. It successfully modernizes the codebase by introducing Kotlin coroutines and flows for asynchronous log reading, replacing the old thread-based implementation. The switch to parsing binary logcat data via LogcatBinaryParser is a great improvement for efficiency. Deduplicating the log reading logic into the new LogcatReader class greatly improves maintainability and cleans up the Activity and Service. The addition of a customizable log export format is also a nice feature. While the changes are excellent overall, I've identified a few critical issues that could lead to crashes, along with some suggestions to further improve performance and code quality.

@evermind-zz evermind-zz force-pushed the minSdk_binaryReader_coroutines_deduplicate-LogcatReader branch from e0bf029 to fdde393 Compare February 10, 2026 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant