joaomgcd / TaskerSettings

Helper app for Tasker
358 stars 10 forks source link

Toggle Bluetooth on MIUI won't work (Tasker 6.2.22, TS 1.6+) #35

Closed happybear88 closed 10 months ago

happybear88 commented 10 months ago

OS and app info

Tasker: 6.2.22 Tasker Settings: 1.6.0, 1.7.1, 1.7.1 Huawei.Xiaomi Android 13 TKQ1 MIUI Global 14.0.6 TaskerBT.zip contains full text of errors, and screenshots of app versions, tasks, permission settings

Issue description

Unable to automatically turn BT on or off with Tasker Settings.

Notes

I'll appreciate any suggestions. Thanks!

joaomgcd commented 10 months ago

I'm prompted to allow BT on or off every time the task runs.

That's usually a setting somewhere in your device's system settings that you have to change. Tasker itself doesn't show that popup. If you can find the system setting that disables that popup, it should work correctly! :)

Hope this helps!

happybear88 commented 10 months ago

Thanks @joaomgcd , but why are you closing as completed already? There are two problems I'm raising here.

1/ The Xiaomi version throws an exception. Why is this not a problem from your perspective?

Here's the Xiaomi version of the app with the BT management setting image and the exception Couldn't toggle bluetooth: : java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT permission for android.content.AttributionSource

2/ The standard version is not working as I expect (my expectations could be wrong, but that's not the end of the story for me).

From the releases On some Huawei devices you'll need to use the special Huawei/Xiaomi APK below so that when you try to toggle WIFI it won't always ask you for permission to toggle it. More info here: https://github.com/joaomgcd/TaskerSettings/pull/13

I'm having a similar issue with Bluetooth, at least the symptom is the same - I'm always prompted for permission. If this version is not able to manage BT the same way it manages Wi-FI, can we convert the issue to the Feature Request for BT?

Thanks!

happybear88 commented 10 months ago

I have clarified the issue description and the comment above, please review again. I've also updated TaskerBT.zip with the originally missing exception info.

joaomgcd commented 10 months ago

Sorry, I closed it because usually the solution I presented fixes the situation and sometimes people forget to reply that it works so I started closing the issue preemptively because I would then forget to close it later if people didn't reply 😅

Ok, let's see.

  1. Can you please try disabling/re-enabling the Bluetooth/Nearby Devices permission for both Tasker and Tasker Settings and see if that helps?
  2. The special release Huawei/Xiaomi release was made because it was found that targeting a higher API level would make the Wifi prompt not show up on some devices. It's not related to the Bluetooth prompt unfortunately. If you're saying that the bluetooth prompt is still appearing and that it can't be disabled in system settings then we'll need to find a different workaround somehow. I'm just not sure what it is...

Hope this helps!

Tyri0n commented 10 months ago

toggling nearby devices permission worked for me (a random lurker), thanks.

1. Can you please try disabling/re-enabling the Bluetooth/Nearby Devices permission for both Tasker and Tasker Settings and see if that helps? 
Gundi17 commented 10 months ago

For me disabling/re-enabling the Bluetooth/Nearby Devices permission for both Tasker and Tasker Settings unfortunately did not work. I tried repeatedly, also in combination with a restart. This problem only started today, and I am not sure what caused it as I did not change anything. I'm on a Xiaomi 11 Lite 5G NE with MIUI 14.0.8.

happybear88 commented 10 months ago

@joaomgcd thanks a lot for your suggestions. The problem with 1.7.1 Huawei.Xiaomi indeed went away after toggling back and forth the Bluetooth and Nearby Devices permissions for both Tasker and Tasker Settings. This survived a reboot as well.

FWIW, I didn't have Tasker Settings installed until today. But Tasker got updated to 6.2.22 and stopped disabling BT for me. So I went ahead with Tasker Settings install and ran into this issue.

joaomgcd commented 10 months ago

Yeah, it's a new issue because I had to update Tasker's target API to 33 which made the app not be able to toggle BT. Glad it's fixed! :) Thanks!

honggiwei commented 10 months ago

I have tried install 'tasker setting', but it still appear user prompt which is annoying. I try install 3'party code. Bt toggle app for instead to on/off bluetooth. It work and no user prompt appear. So, I think 'tasker setting' miss something.

https://github.com/brendanbeavis/Android_BluetoothToggle


01-29 17:14:06.285 28071 32219 E Tasker : 17.14.06#b#E: error: Couldn't toggle bluetooth: : Tasker Settings doesn't have nearby or Bluetooth permissions?

01-29 17:14:06.299 19276 19276 D BtRequestPermission: app package name is com.joaomgcd.taskersettings

01-29 17:14:06.300 1582 3647 I ActivityTaskManager: START u0 {act=com.android.settings.bluetooth.ACTION_INTERNAL_REQUEST_BT_ON cmp=com.android.settings/.bluetooth.RequestPermissionHelperActivity (has extras)} from uid 1000 from pid 19276 callingPackage com.android.settings

01-29 17:14:06.300 3344 3430 E ActivityManagerWrapper: getRecentTasks: mainTaskId=6665 userId=0 baseIntent=Intent { act=android.bluetooth.adapter.action.REQUEST_ENABLE flag=276824064 cmp=ComponentInfo{com.android.settings/com.android.settings.bluetooth.RequestPermissionActivity} }

joaomgcd commented 10 months ago

Hi. Can you try disabling and re-enabling the Bluetooth and Nearby Devices permission for both Tasker and Tasker Settings? Thanks in advance!

honggiwei commented 10 months ago

I know the method you mentioned. I have read your previous articles. Of course, I have also tried it, but it still didn't work, so I looked for alternative software solutions。

Thanks。

On Tue, Jan 30, 2024, 21:09 João Dias @.***> wrote:

Hi. Can you try disabling and re-enabling the Bluetooth and Nearby Devices permission for both Tasker and Tasker Settings? Thanks in advance!

— Reply to this email directly, view it on GitHub https://github.com/joaomgcd/TaskerSettings/issues/35#issuecomment-1916810401, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKIPFFUERLALNOWVYC6NMOLYRDWG3AVCNFSM6AAAAABBWFGVDWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJWHAYTANBQGE . You are receiving this because you commented.Message ID: @.***>