afwall icon indicating copy to clipboard operation
afwall copied to clipboard

[FEATURE] Request: add adb command to block/unblock by package-name

Open AndroidDeveloperLB opened this issue 2 years ago • 0 comments

Is your feature request related to a problem? Please describe. Not sure if it's possible...

Describe the solution you'd like While the app is enabled, let us use adb via the PC to block/unblock specific app/s , same as done via the UI.

Describe alternatives you've considered Only thing I've found (searched online and even asked ChatGpt) is this script, but sadly it doesn't seem to work well for all apps, so they can somehow reach the Internet in some ways:

@echo off
set package_name="com.android.chrome"

c:
cd\
cd C:\Users\User\AppData\Local\Android\Sdk\platform-tools

for /f "delims=" %%A in ('adb shell dumpsys package %package_name% ^| findstr "userId="') do (
  for /f "tokens=2 delims== " %%B in ("%%A") do (
    echo Extracted UID: %%B
    adb shell "su -c 'iptables -A OUTPUT -m owner --uid-owner %%B -j DROP'"
  )
)

And to unblock:

@echo off 
set package_name="com.android.chrome"

c:
cd\
cd C:\Users\User\AppData\Local\Android\Sdk\platform-tools

for /f "delims=" %%A in ('adb shell dumpsys package %package_name% ^| findstr "userId="') do (
  for /f "tokens=2 delims== " %%B in ("%%A") do (
    echo Extracted UID: %%B
    adb shell "su -c 'iptables -D OUTPUT -m owner --uid-owner %%B -j DROP'"
  )
)

Additional context I looked at the code. Seems the app is doing much more than a single command. It's probably in the "API" file (in ".../dev/ukanth/ufirewall/"). Seems a lot though.

AndroidDeveloperLB avatar Jun 18 '23 23:06 AndroidDeveloperLB