ShizuStore

usb pd bs

ONDER1E

2.0.0 · GitHub

Download APK
Power management Android 8.0+ 5 months ago Proprietary
86 ShizuStore
402 GitHub
11 Stars
4 MB Size

More about this app

Toggles USB PD battery-bypass mode at charge thresholds via Shizuku with self-healing recovery.

USB PD BS - Univeral Serial Bus Power Delivery Bypass Script

A native Android app that monitors battery level and automatically toggles USB PD battery bypass (pass-through) mode via the Shizuku API.

This is the native successor to tbp, which accomplished the same goal using shell scripts in Termux. This version runs as a proper Android foreground service and includes a "Self-Healing" recovery system to maintain the bypass state even if Shizuku or WiFi drops.


Why This Exists

The original shell-based tbp worked well, but had fundamental limitations:

  • Required Termux and a manually acquired wakelock to stay alive.
  • The wakelock prevented the SoC from entering deep sleep states.
  • Battery reads relied on spawning dumpsys subprocesses every 5 seconds.
  • No boot autostart without Termux:Boot.

This app replaces all of that with a native, event-driven architecture that allows the CPU to sleep between battery updates.


How It Works

Instead of polling every 5 seconds, the app registers for Android's ACTION_BATTERY_CHANGED broadcast. The CPU is not woken on a timer — it only wakes when the OS broadcasts a change in battery state.

  1. Listen: The service waits for the ACTION_BATTERY_CHANGED event.
  2. Evaluate: Compares the current level against user-defined Enable/Disable thresholds (Hysteresis).
  3. Execute: Calls settings put system pass_through <0|1> via Shizuku IPC.
  4. Recover: If Shizuku is disconnected, the app uses a local rish binary and Termux RunCommand to automatically restore the environment.

Features

  • Event-Driven: Zero polling; the SoC can enter deep sleep between events.
  • Self-Healing: Automated Shizuku/WiFi recovery using rish.
  • Hysteresis Zone: Separate thresholds to prevent rapid toggle "flapping."
  • Live Logs: Real-time monitoring of service logic and system events.
  • Boot Autostart: Automatically starts the monitor on device boot.

Build Tutorial

Prerequisites

  • JDK 17 or higher.
  • Android SDK (Command line tools or Android Studio).

Build Steps (Windows)

  1. Clone the repository:
    git clone [https://github.com/ONDER1E/usbpdbs.git](https://github.com/ONDER1E/usbpdbs.git)
    cd tbp-android
    
    
  2. Build the Debug APK:
    .\gradlew.bat assembleDebug
    
  3. Locate your APK at: app/build/outputs/apk/debug/app-debug.apk

Device Compatibility

This app uses the same pass_through system setting as the original shell scripts.

  • Samsung: S22/S23/S24 series (via "Pause USB Power Delivery").
  • ASUS: ROG Phone / Zenfone (Bypass Charging).
  • Sony: Xperia (H.S. Power Control).
  • Others: RedMagic, Black Shark, Lenovo Legion.

FAQ

Q: Does this require Root?

A: No. It only requires Shizuku, which can be started via Wireless Debugging (ADB).

Q: Why do I need Termux for "Recovery"?

A: Shizuku often stops after reboots or WiFi toggles. The app uses Termux's RunCommand API to trigger a script that restarts the Shizuku environment and WiFi without needing a PC.

Q: My device isn't reacting to the toggle.

A: Ensure your charger supports USB-PD PPS. Standard "Fast Chargers" may not support the PD protocols required for system-level bypass.

Q: Is this safe for my battery?

A: Yes. It reduces heat by preventing the battery from charging/discharging while the device is under high load (gaming/navigation), which preserves long-term health.

Q: How do I know it's working?

A: Check the "Live Logs" tab. You will see "Setting pass_through to 1" when the enable threshold is hit. On many devices, the battery icon will show "Plugged in, not charging."


Differences from tbp (Shell Version)

Feature tbp (shell) tbp-android (this)
Monitoring Method 5s Polling Loop Event-Driven (ACTION_BATTERY_CHANGED)
CPU State Constant Wake Deep Sleep between events
Recovery Manual Automated via Rish/Termux
UI CLI / Notifications Full GUI + Live Logs
Boot Autostart Termux:Boot Native BOOT_COMPLETED

Safety Disclaimer

This app modifies system-level power settings. Use at your own risk. Improper thresholds or unsupported hardware may lead to battery degradation or unexpected behaviour.


Known issues

There are known issues regarding the permissions of the following:

  • Write Secure Settings
  • Rish Setup Solutions can be found here

Licence

See LICENCE.

Close

How Shizuku is used

Can toggle USB PD bypass charging at battery thresholds and self grant permissions via `rish` shell through Shizuku.

This is an AI-assisted analysis of Shizuku-related usages in the app's public source code. It is best effort, so it may not catch every single usage.

How this app uses Shizuku

The app uses Shizuku through its bundled rish shell to control USB PD battery bypass mode and to manage its own permissions and recovery.

  • Toggle bypass charging: a background monitor watches the battery level and automatically turns USB PD battery bypass on or off at user chosen charge thresholds by writing the settings put system pass_through value through Shizuku, after reading the current value with settings get system pass_through.
  • Self grant permissions: permission fix buttons grant the app its required permissions through Shizuku with fixed pm grant commands for secure settings, Termux command and notification access, plus cmd appops set for display over other apps.
  • Heal Shizuku session: when the Shizuku connection dies, a user triggered recovery flow closes the Shizuku app UI with the am force-stop shell command through Shizuku after the connection returns.

Android APIs or commands used

  • settings put system pass_through
  • settings get system pass_through
  • pm grant
  • cmd appops set
  • am force-stop

Notable details

If Shizuku or the rish bridge is not ready, permission fixes fall back to copying the equivalent ADB command for manual use. Recovery also uses Termux commands to turn WiFi on and off around the Shizuku restart when needed.

Close

Changelog

What's new for version 2.0.0

USB PD Bypass Script (v2.0.0-Stable)


Changelog

  • Adds dynamic ordering: Shizuku and Rish setup now appear first.
  • Adds "Grant All via Shizuku" button for automated setup.
  • Adds auto-redirect to Permissions tab if any requirements are missing.
  • Fixes logic flow where Write Secure Settings required Rish to be ready.
  • Matches UI button styling and text colors with MainFragment.

Disclaimer

This utility interacts with hardware charging protocols. While designed for efficiency, use it at your own risk. Ensure your device hardware supports USB PD Bypass before enabling advanced monitoring features.

Filename: USB_PD_Bypass_Script_v2.0.0.apk MD5 Checksum: cf3b3ff64e435e195866500c77e2cdf0 SHA-256: a59b468e4aafc7cad6f13821bbf60d3636689792d2129d384aa7efc53887e82a

Close

Permissions

15 permissions requested

  • android.permission.FOREGROUND_SERVICE
  • android.permission.FOREGROUND_SERVICE_SPECIAL_USE
  • android.permission.RECEIVE_BOOT_COMPLETED
  • android.permission.WAKE_LOCK
  • android.permission.BATTERY_STATS
  • android.permission.POST_NOTIFICATIONS
  • android.permission.SYSTEM_ALERT_WINDOW
  • android.permission.ACCESS_WIFI_STATE
  • android.permission.CHANGE_WIFI_STATE
  • android.permission.WRITE_SECURE_SETTINGS
  • com.termux.permission.RUN_COMMAND
  • android.permission.READ_EXTERNAL_STORAGE
  • android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
  • com.onder1e.usbpdbs.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION
  • moe.shizuku.manager.permission.API_V23
Close