How to auto-accept Wi-Fi Direct connection requests in Android

前端 未结 4 713
醉话见心
醉话见心 2020-12-08 05:57

I have 2 Android devices using WiFi Direct. On one device I can get information about the other device using the WifiP2pManager class, and request a connection

4条回答
  •  一整个雨季
    2020-12-08 06:29

    If you can modify the framework, you can ignore the accept window and direct send the "PEER_CONNECTION_USER_ACCEPT".

    Base on Android 5.0, "frameworks/opt/net/wifi/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java".

    You must find the "notifyInvitationReceived", and modify to ...

    private void notifyInvitationReceived() {
        /*Direct sends the accept message.*/
        sendMessage(PEER_CONNECTION_USER_ACCEPT);
    /*
    ... old code
    */
    }
    

提交回复
热议问题