对于V6.0.1或更高版本的非根安卓设备,是否可以使用ADB关闭/打开(禁用/启用)NFC?
我试了很多东西,但都不管用。
我试过的东西是:
通过亚洲开发银行:
adb shell settings put global airplane_mode_toggleable_radios bluetooth,cell,wimax,nfc
adb shell am broadcast -a android.intent.action.airplane_mode_toggleable_radios
adb shell settings put global airplane_mode_on 1
adb shell am broadcast -a android.intent.action.AIRPLANE_MODE
adb shell settings put global radio_nfc 0
adb shell am broadcast -a android.intent.action.radio_nfc
adb shell settings put global AIRPLANE_MODE_RADIOS 0
adb shell am broadcast -a android.intent.action.AIRPLANE_MODE_RADIOS
adb shell settings put global NfcAdapter 0
adb shell am broadcast -a android.intent.action.NFC_adapter
adb shell settings put global airplane_mode_radios cell,bluetooth,nfc,wimax
adb shell content update --uri content://settings/global --bind value:s:'bluetooth,nfc,wimax' --where "name='airplane_mode_radios'"
也:
adb shell settings get global airplane_mode_radios
adb shell content query --uri content://settings/global --projection name:value --where "name='airplane_mode_radios'"
adb shell settings put global airplane_mode_radios "cell,nfc,wimax"
adb shell content update --uri content://settings/global --bind value:s:'cell,nfc,wimax' --where "name='airplane_mode_radios'"
adb shell settings put global airplane_mode_radios "cell,bluetooth,wifi,nfc,wimax"
adb shell content update --uri content://settings/global --bind value:s:'cell,bluetooth,wifi,nfc,wimax' --where "name='airplane_mode_radios'"
重启设备后,我可以用ADB打开飞行模式,但nfc不会关闭。
我试过的另一个例子是:
列出正在运行的服务:
adb shell service list
在那里你可以看到nfc运行在第9位“nfc:[android.nfc.INfcAdapter]”
尝试使用禁用
adb shell pm hide com.android.nfc
不工作并抛出:
错误:java。lang.SecurityException:user 2000和current process都没有android。准许管理用户。
或:
adb shell pm grant EXAMPLE.android.services android.permission.WRITE_SECURE_SETTINGS
adb shell pm grant EXAMPLE.android.services android.permission.CHANGE_CONFIGURATION
-
以下是Android 5x之前的设备:
Enable/Disable NFC with ADB command