2

Here's my problem: I used to run Lineage 16 on my Pixel3a, which still had the "profile" option where I could do things like "When my home network is not within reach, switch to another profile". I used this to turn off wifi when leaving the house and it worked very well. Important: This did not need my location services to be on to work.

Now I've upgraded to Lineage 17.1 (Android 10) and this option is gone. I am now looking into how to rebuild that functionality. My phone is rooted (via Magisk), and as a software developer I am ready to use all tools I have available.

What I've tried: I've built an app that periodically checks if I am connected to one specific SSID (since that is all I can see on Android 10 anymore - "Am I connected to "my-ssid"?) and then turns of wifi using the shell and sulike this: sudo("svc wifi disable"). sudo() is my function that opens a process and talks to the shell.

The problem is I don't think there is a way I can guarantee my app always runs, and I'd like this to also work when the app is off? It doesn't even need to be a specific SSID, I'd be happy if my result is: "If we're not connected to a wifi network for more than 3min, turn wifi off.

so what other options do I have? Tasker, just like my own attempt, kind of works but only with location services on, which I'd like to avoid. What else can I do. Can I run some kind of script or a job just on the shell or so? Is there anything I can do with Magisk or Xposed?

Happy for any help here - the internet is full of links and tips, but they all target older OS versions. Btw the source for my (extremely rough draft) app is here if anyone is curious.

1
  • if you have Xposed installed, you can try installing Xposed Edge. Open it, go to More triggers > Wifi Disconncted > Wifi > Turn off. It will turn off wifi as soon as the phone is disconnected from any network. – Reddy Lutonadio Jan 15 at 17:24
2

With methods described below, when the phone disconnect from your wifi network, wifi will be immediately switched off. Also they don't require the Location Services to be on.

A. Xposed Edge

Open Xposed Edge, go to More triggers > Wifi Disconncted > Wifi > Turn off.

B. Macrodroid

  1. Open Macrodroid, click Add Macro.
  2. Click the + on the right of Trigger. Click Connectivity > Wifi State Change > Disconnected from network. Click OK. Select your network(s).
  3. Click the + on the right of Actions. Click Connectivity > Wifi Configure > Disable Wifi. Click Ok
  4. Give your macro a name. Press back, save the macro. The macro will look like this:

Switch Wifi off when disconnected from my network macro

C. Automate

  1. Open Automate, click the + at the bottom of the screen to add a new flow.
  2. Click +, Connectivity > Wifi enable?. Click the Wifi enable? block, set Options to Immediately. Click Save.
  3. Click +, Connectivity > Wifi network connected?. Click Wifi network connected? block, Don't click on pick the network, but enter the network name (SSID) manually. Set Options to Immediately. Click Save.
  4. Click +, Date & time > Delay. Click on the Delay block, set the duration to 3s. Click Save.
  5. Click +, Connectivity > Wifi set state. Click on the Wifi set state block, select Off. Note that this block is not officially supported for Android 10+ and might not work.
  6. Link the block has shown on the image below. Press back. Give your flow a name. Press Start to start the flow.

IMG:

D. Ping your home router You can use a script in combination with the app mentioned to ping your home router. When the pings are successful, the phone wifi stays on. When they are unsuccessful, disable you phone wifi.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.