【问题标题】:Native Android Device > turn off/on NFC with ADB [duplicate]原生 Android 设备 > 使用 ADB 关闭/打开 NFC [重复]
【发布时间】:2017-11-14 10:29:12
【问题描述】:

是否可以为具有 v 6.0.1 或更高版本的无根 Android 设备使用 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:用户 2000 和当前进程都没有 android.permission.MANAGE_USERS。

或:

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

【问题讨论】:

  • 这不是重复的。

标签: android adb nfc android-6.0-marshmallow


【解决方案1】:

在玩了Enable/Disable NFC with ADB command之后

在 android Marshmallow(6.0.0 或 6.0.1)上

禁用

service call nfc 5

启用

~~服务调用 nfc 6~~

编辑:

这似乎不会永久禁用,重新启动会重新启用服务

找到真正的答案!

svc nfc <enable|disable>

【讨论】:

  • 你好@Freshollie,这行得通!谢谢你
猜你喜欢
  • 2015-08-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-07
  • 1970-01-01
相关资源
最近更新 更多