by Fran T
Demonstrates the use of the Wi-Fi and Hotspot Set State blocks, as well as non-rooted UI workarounds for Android Oreo and above, where the blocks may no longer work due to security changes. Feel free to take the pieces you need for your flows.
Thanks to Kevin for identifying the necessary lock screen UI element!
The flow detects whether the Oreo+ UI workaround is needed by checking for an exception from a Wi-Fi or Hotspot block during setup. In order for the UI method to be able to turn the hotspot or Wi-Fi setting on and off in Android Oreo and above, their tiles must be present in Quick Settings. To see if they are, expand the status bar by swiping down twice. If the Hotspot or Wi-Fi tile isn't present, tap the EDIT or “pen” button, then drag the tile to add it. If the Quick Setting tile on your device is labeled something other than "Hotspot" or "Wi-Fi", change the 'quickSettingTileText' variable near the top of the flow to match it. Note that for Wi-Fi, you'll need to surround the text with asterisk wildcards so that the setting can be found when you're connected to a Wi-Fi network.
Note that the flow needs to unlock the device as necessary to access Quick Settings. A separate demo flow for that is provided. That section and the Hotspot/Wi-Fi setting section are written as subroutines to make them easier to extract for your own flow.
Note: If you notice an exception in the log, that's normal and is the way the flow determines whether the non-root UI workaround is needed to enable the Hotspot or Wi-Fi setting. The flow continues to run normally.
o Added handling for when the device is already unlocked
o Added positive re-locking for Android 9+
o Added a Variable Set block at the start of the flow to accommodate UIs where the text of the Hotspot tile is something other than "Hotspot"; if this is the case on your device, change the second block
o Fix hang when Hotspot tile isn't found
o Fix for Android tile UI class update
o Adaptations for Android 11 and new Automate behavior
o Refactored to also demonstrate how to work around new restrictions with the Wi-Fi Set State block, added demonstrations for settings, added separate flow to demonstrate unlocking the device
o Updated to use the new Automate v1.24 workaround for Wi-Fi Set State block
o Use wildcards for Hotspot quick setting tile text to make it more likely to work on different devices
o Use swipe gesture if Unlock element doesn't exist, wait for device to be manually unlocked if unlocking via the UI fails, separated Hotspot and Wi-Fi flows
Reviews and ratings can be submitted in the app.