On my OnePlus 6 running OxygenOS 10.3.11 (Android 10) I can find out the culprit using the following adb commands:
adb shell
dumpsys bluetooth_manager | toybox sed -ne '/abled.*due.*to.*APPLICATION_REQUEST.*/p'
Example:
$ adb shell
$ dumpsys bluetooth_manager | toybox sed -ne '/abled.*due.*to.*APPLICATION_REQUEST.*/p'
01-05 13:31:04 Enabled due to APPLICATION_REQUEST by com.arlosoft.macrodroid
01-05 13:31:18 Disabled due to APPLICATION_REQUEST by com.android.systemui
01-05 13:31:27 Enabled due to APPLICATION_REQUEST by com.arlosoft.macrodroid
01-05 13:32:22 Disabled due to APPLICATION_REQUEST by com.arlosoft.macrodroid
01-05 13:34:24 Enabled due to APPLICATION_REQUEST by com.arlosoft.macrodroid
01-05 13:39:22 Disabled due to APPLICATION_REQUEST by com.android.systemui
As you can see the command queries Bluetooth Manager service and filters out information relevant to us. If you want to find out where this information is in the full log/dump, look for the heading Enable log:
in the full dump of bluetooth_manager
using dumpsys bluetooth_manager
. This information may prove useful if my dumpsys query fails to produce output.
The string after by
is the package name of the app that requested Bluetooth be enabled or disabled at the given time. To find the app name from the package name you can use my answer for the question "How to find app based on package name?"
One can also find out this information (package name) by filtering the logcat
adb logcat | grep -i 'bluetooth.*packageName'
Demo output:
01-05 13:32:22.305 1193 16018 E BluetoothManagerService: [CW] addActiveLog, reason: 1, packageName: com.arlosoft.macrodroid, enable: false
01-05 13:32:22.305 1193 16018 D BluetoothManagerService: [CW] Bluetooth Manager Service, enable: false, reason: 1, packageName: com.arlosoft.macrodroid
adb logcat
at the time Bluetooth gets enabled. May be the log contains something you can identify the cause.