Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Tasker integrations #591

Merged
merged 6 commits into from
Aug 6, 2024
Merged

Conversation

zacharee
Copy link
Contributor

I have a use-case for VPN Hotspot that requires enabling USB tethering automatically when USB is connected. I can't use the developer option to have my default USB configuration be USB tethering, since my plan has no hotspot support at all. I did try using Tasker to enable USB tethering manually, but wasn't really getting anywhere. VPN Hotspot would show it being active but no traffic would be passed.

Since I've seen some other requests for automation, and it comes in handy for me, I decided to add Tasker Plugin support to VPN Hotspot. These are the features I implemented:

Actions

  • Enable/disable Wifi Tethering.
  • Enable/disable USB Tethering.
  • Enable/disable Ethernet Tethering.
  • Enable/disable Bluetooth Tethering.

Using the configuration button in Tasker will toggle whether the action will enable or disable tethering. This isn't the best UI, but I think it might be preferable to implementing a new Activity just to show a single toggle. I'm definitely open to other opinions.

State Actions

  • Get current tethering state as an object with boolean fields:
    • %wifi
    • %usb
    • %ethernet
    • %bluetooth

State Events

  • Current tethering state as an object with the same fields as above.

@zacharee zacharee force-pushed the add-tasker-integration branch 11 times, most recently from b3f795a to 0373f82 Compare July 22, 2024 21:28
@Mygod
Copy link
Owner

Mygod commented Jul 24, 2024

Hi thanks for the PR! I will definitely take a closer look later.

@Mygod Mygod self-assigned this Jul 26, 2024
@zacharee zacharee force-pushed the add-tasker-integration branch from 0373f82 to 39639a6 Compare July 30, 2024 01:21
@zacharee zacharee force-pushed the add-tasker-integration branch from 39639a6 to 2941b10 Compare August 6, 2024 03:04
@Mygod
Copy link
Owner

Mygod commented Aug 6, 2024

I'll take over and fix the rest. Thanks! Please don't force push again. :)

Copy link
Owner

@Mygod Mygod left a comment

Choose a reason for hiding this comment

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

Hi this is ready to be merged. Let me know.

@zacharee
Copy link
Contributor Author

zacharee commented Aug 6, 2024

Just made a change to remove the TetheringStateInput class since the data is coming directly from the static set you added instead.

@zacharee
Copy link
Contributor Author

zacharee commented Aug 6, 2024

I can't merge this myself since I don't have write access.

@Mygod Mygod merged commit c01cee6 into Mygod:master Aug 6, 2024
2 checks passed
@Mygod
Copy link
Owner

Mygod commented Aug 6, 2024

This PR is now merged. It will go into the next beta release (v2.18.0). Thanks again!

@Mygod Mygod mentioned this pull request Aug 12, 2024
@Mygod
Copy link
Owner

Mygod commented Oct 22, 2024

Hi @zacharee, can you help with the Google Play foreground service declaration? Meanwhile I will remove this feature from the Google Play variant until Google approves it. We need the following:

  • Provide a video demonstrating how your app uses the FOREGROUND_SERVICE_SPECIAL_USE permission for the tasks you've selected
  • Describe your app's use of this permission, including why the task must start immediately and cannot be paused or restarted

@zacharee
Copy link
Contributor Author

Sorry for taking so long to respond. You should be able to just exclude the foreground service permissions. Newer Tasker versions don't need them.

Lines 27, 28, 368-385 here as an example: https://github.com/zacharee/LockscreenWidgets/blob/bd85750d488b9534edf001147471a84cc3186770/app/src/main/AndroidManifest.xml

@Mygod
Copy link
Owner

Mygod commented Nov 16, 2024

Got it. Will try for the next release. 👍

Mygod added a commit that referenced this pull request Dec 6, 2024
@Mygod
Copy link
Owner

Mygod commented Jan 4, 2025

@zacharee Getting this error. Is there a better library to use maybe?

Fatal Exception: java.lang.IllegalArgumentException
foregroundServiceType 0x40000000 is not a subset of foregroundServiceType attribute 0x00000000 in service element of manifest file
android.os.Parcel.createExceptionOrNull (Parcel.java:3061)
android.os.Parcel.createException (Parcel.java:3041)
android.os.Parcel.readException (Parcel.java:3024)
android.os.Parcel.readException (Parcel.java:2966)
android.app.IActivityManager$Stub$Proxy.setServiceForeground (IActivityManager.java:6825)
android.app.Service.startForeground (Service.java:862)
com.joaomgcd.taskerpluginlibrary.runner.TaskerPluginRunner$Companion.startForegroundIfNeeded (TaskerPluginRunner.kt:86)
com.joaomgcd.taskerpluginlibrary.runner.TaskerPluginRunner$Companion.startForegroundIfNeeded$default (TaskerPluginRunner.kt:79)
com.joaomgcd.taskerpluginlibrary.runner.IntentServiceParallel.startForegroundIfNeeded$default (IntentServiceParallel.kt:27)
com.joaomgcd.taskerpluginlibrary.runner.IntentServiceParallel.startForegroundIfNeeded (IntentServiceParallel.kt:27)
com.joaomgcd.taskerpluginlibrary.action.IntentServiceAction.onHandleIntent (ActionReceivers.kt:27)
com.joaomgcd.taskerpluginlibrary.runner.IntentServiceParallel.onStart$lambda$3 (IntentServiceParallel.kt:71)
java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:487)
java.util.concurrent.FutureTask.run (FutureTask.java:264)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:644)
java.lang.Thread.run (Thread.java:1012)

@altemon1990
Copy link

Hello @Mygod @zacharee

I tried using it with tasker and get following problem

04.07.12/ActionArgBundle Wi‑Fi hotspot: extra key not found in bundle:
04.07.12/E FIRE PLUGIN: Wi‑Fi hotspot / com.twofortyfouram.locale.intent.action.FIRE_SETTING: 7 bundle keys
04.07.12/E Wi‑Fi hotspot: plugin comp: be.mygod.vpnhotspot/com.joaomgcd.taskerpluginlibrary.action.IntentServiceAction
04.07.12/Ew add wait type Plugin1 time 60
04.07.12/Ew add wait type Plugin1 done
04.07.12/E handlePluginFinish: taskExeID: 1 result 3
04.07.12/E pending result code
04.07.12/E add wait task
04.07.12/E Error: 2
04.07.12/E Need TETHER_PRIVILEGED or WRITE_SETTINGS permission

OF COURSE the modify system settings is granted to both tasker and vpnhotspot

Pls help :-)

@zacharee
Copy link
Contributor Author

zacharee commented Jan 5, 2025

@zacharee Getting this error. Is there a better library to use maybe?

Fatal Exception: java.lang.IllegalArgumentException
foregroundServiceType 0x40000000 is not a subset of foregroundServiceType attribute 0x00000000 in service element of manifest file
android.os.Parcel.createExceptionOrNull (Parcel.java:3061)
android.os.Parcel.createException (Parcel.java:3041)
android.os.Parcel.readException (Parcel.java:3024)
android.os.Parcel.readException (Parcel.java:2966)
android.app.IActivityManager$Stub$Proxy.setServiceForeground (IActivityManager.java:6825)
android.app.Service.startForeground (Service.java:862)
com.joaomgcd.taskerpluginlibrary.runner.TaskerPluginRunner$Companion.startForegroundIfNeeded (TaskerPluginRunner.kt:86)
com.joaomgcd.taskerpluginlibrary.runner.TaskerPluginRunner$Companion.startForegroundIfNeeded$default (TaskerPluginRunner.kt:79)
com.joaomgcd.taskerpluginlibrary.runner.IntentServiceParallel.startForegroundIfNeeded$default (IntentServiceParallel.kt:27)
com.joaomgcd.taskerpluginlibrary.runner.IntentServiceParallel.startForegroundIfNeeded (IntentServiceParallel.kt:27)
com.joaomgcd.taskerpluginlibrary.action.IntentServiceAction.onHandleIntent (ActionReceivers.kt:27)
com.joaomgcd.taskerpluginlibrary.runner.IntentServiceParallel.onStart$lambda$3 (IntentServiceParallel.kt:71)
java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:487)
java.util.concurrent.FutureTask.run (FutureTask.java:264)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:644)
java.lang.Thread.run (Thread.java:1012)

There isn't a better library since this is the official and only one. You should only see this error from people using old versions of Tasker that don't support binding the runner Services instead of starting them, so they should be safe to ignore or filter out.

@zacharee
Copy link
Contributor Author

zacharee commented Jan 5, 2025

Hello @Mygod @zacharee

I tried using it with tasker and get following problem

04.07.12/ActionArgBundle Wi‑Fi hotspot: extra key not found in bundle: 04.07.12/E FIRE PLUGIN: Wi‑Fi hotspot / com.twofortyfouram.locale.intent.action.FIRE_SETTING: 7 bundle keys 04.07.12/E Wi‑Fi hotspot: plugin comp: be.mygod.vpnhotspot/com.joaomgcd.taskerpluginlibrary.action.IntentServiceAction 04.07.12/Ew add wait type Plugin1 time 60 04.07.12/Ew add wait type Plugin1 done 04.07.12/E handlePluginFinish: taskExeID: 1 result 3 04.07.12/E pending result code 04.07.12/E add wait task 04.07.12/E Error: 2 04.07.12/E Need TETHER_PRIVILEGED or WRITE_SETTINGS permission

OF COURSE the modify system settings is granted to both tasker and vpnhotspot

Pls help :-)

WRITE_SETTINGS is granted through App Details >> Change system settings >> Allow permission. It's different from WRITE_SECURE_SETTINGS.

@altemon1990
Copy link

@zacharee

This is how I did it:

Screenshot_20250105-202829_Settings

@zacharee
Copy link
Contributor Author

zacharee commented Jan 5, 2025

I think you also need to grant it to Tasker.

@altemon1990
Copy link

I think you also need to grant it to Tasker.

I did, following exactly same procedure.

I also tried systemizing the vpnhotspot app.

No cigar (

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants