解决部分Termux:api命令运行无反应以及MacroDroid或Tasker不能调用Termux:tasker
1. 问题
- 通过Tasker使用Termux:tasker的时候提示错误:接收器丢失、被禁用、未导出、过多或无权限
- 在Termux中运行部分Termux:api的脚本无反应,例如使用
termux-wifi-enable true
的时候不能成功打开wifi。
2. 解决
2.1 使用termux:tasker报错
- 需要使用adb给权限调用Termux的权限
adb shell pm grant <要调用的应用的包名> com.termux.permission.RUN_COMMAND
例如tasker就使用
adb shell pm grant net.dinglisch.android.taskerm com.termux.permission.RUN_COMMAND
macrodroid就使用
adb shell pm grant com.arlosoft.macrodroid com.termux.permission.RUN_COMMAND
注意,使用的时候可能需要在开发者选项中打开“禁止权限监控”的选项
- 其次是检查有无设置了后台运行、自启动、忽略电池优化等等应用权限
- 还有就是脚本要放在目录
~/.termux/tasker/
下
2.2 运行termux:api的部分脚本无效
解决方法:同样是使用adb授予权限
adb shell pm grant com.termux android.permission.WRITE_SECURE_SETTINGS
应该是这个权限,当时我是全都给了,不确定是不是这个起的作用。
- 这是使用
adb shell dumpsys package com.termux
获取的权限中能通过adb授予的部分。可以全都使用adb授予一下
adb shell pm grant com.termux android.permission.WRITE_EXTERNAL_STORAGE
adb shell pm grant com.termux android.permission.SYSTEM_ALERT_WINDOW
adb shell pm grant com.termux android.permission.READ_LOGS
adb shell pm grant com.termux android.permission.DUMP
adb shell pm grant com.termux android.permission.WRITE_SECURE_SETTINGS
adb shell pm grant com.termux android.permission.PACKAGE_USAGE_STATS
adb shell pm grant com.termux android.permission.POST_NOTIFICATIONS
adb shell pm grant com.termux android.permission.READ_EXTERNAL_STORAGE
adb shell pm grant com.termux android.permission.ACCESS_MEDIA_LOCATION
adb shell pm grant com.termux android.permission.READ_MEDIA_AUDIO
adb shell pm grant com.termux android.permission.READ_MEDIA_VIDEO
adb shell pm grant com.termux android.permission.READ_MEDIA_IMAGES
adb shell pm grant com.termux android.permission.READ_MEDIA_VISUAL_USER_SELECTED
adb shell pm grant com.termux android.permission.READ_SMS
adb shell pm grant com.termux android.permission.READ_CALL_LOG
adb shell pm grant com.termux android.permission.ACCESS_FINE_LOCATION
adb shell pm grant com.termux android.permission.BODY_SENSORS
adb shell pm grant com.termux android.permission.ACCESS_COARSE_LOCATION
adb shell pm grant com.termux android.permission.READ_PHONE_STATE
adb shell pm grant com.termux android.permission.SEND_SMS
adb shell pm grant com.termux android.permission.CALL_PHONE
adb shell pm grant com.termux android.permission.BODY_SENSORS_BACKGROUND
adb shell pm grant com.termux android.permission.CAMERA
adb shell pm grant com.termux android.permission.RECORD_AUDIO
adb shell pm grant com.termux android.permission.READ_CONTACTS
adb shell pm grant com.termux android.permission.ACCESS_BACKGROUND_LOCATION