shell 使用ADB命令启用/禁用NFC

x7yiwoj4  于 2023-06-24  发布在  Shell
关注(0)|答案(7)|浏览(250)

有没有办法通过ADB shell命令禁用/启用NFC
我找到了一个答案here
我从上面的链接中尝试了:

# Enable NFC
service call nfc 5

# Disable NFC
service call nfc 4

但不管用
任何帮助感激不尽。谢谢

6rqinv9w

6rqinv9w1#

我不知道为什么没有人已经张贴这一点
svc nfc <enable|disable>
完美的工作
编辑:需要> Android 6.0

ezykj2lf

ezykj2lf2#

  • #关闭NFC*

服务呼叫nfc 7
已验证适用于Android 8.0
干杯!

6ljaweal

6ljaweal3#

在Eclipse的DDMS或使用logfilter或任何运行时日志捕获工具中,您需要获取NFCService的进程ID。然后,您可以通过提供进程ID来终止或停止该进程。

brjng4g3

brjng4g34#

系统服务的方法代码可能因Android版本而异。因此,在调用服务的方法之前,请浏览AOSP源。
下面是NFC的启用/禁用调用的摘要,最高可达Android 5. 1. 1。也要记住(在来源中)

int FIRST_CALL_TRANSACTION  = 0x00000001

,即等于1

    • 安卓4.4-安卓5.1.1**:
# Disable NFC
service call nfc 5
# Enable NFC
service call nfc 6
    • Android 4.0.1-Android 4.3.1**:
# Disable NFC
service call nfc 4
# Enable NFC
service call nfc 5
    • Android 2.3.4-Android 2.3.7**:
# Disable NFC
service call nfc 18
# Enable NFC
service call nfc 19
    • Android 2.3.3**:
# Disable NFC
service call nfc 20
# Enable NFC
service call nfc 21
    • Android 2.3.2**:
# Disable NFC
service call nfc 13
# Enable NFC
service call nfc 14

要检查NFC服务的状态,请使用dumpsys命令:

dumpsys nfc
ej83mcc0

ej83mcc05#

请尝尝这个

# Enable NFC
service call nfc 6
# Disable NFC
service call nfc 5

请检查第32张幻灯片中的here

zkure5ic

zkure5ic6#

对于Android版本> 7,请使用以下-

# Enable NFC
service call nfc 7
# Disable NFC
service call nfc 6

已在7.1.1上验证...应该至少适用于7.x

k10s72fa

k10s72fa7#

对于Android 12:

# Disable
service call nfc 8

# Enable
service call nfc 9

相关问题