代码之家  ›  专栏  ›  技术社区  ›  asdfghjklö

本机Android设备>使用ADB关闭/打开NFC[重复]

  •  1
  • asdfghjklö  · 技术社区  · 9 年前

    对于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

    1 回复  |  直到 9 年前
        1
  •  0
  •   Freshollie    8 年前

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

    安卓棉花糖(6.0.0或6.0.1)

    service call nfc 5

    使可能

    ~~服务呼叫nfc 6~~

    编辑:

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

    找到了真正的答案!

    svc nfc <enable|disable>

    推荐文章