by منصة شليله
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
Rate and review within the app in the Community section.