humble_programmer
2018-03-06 02:01
采纳率: 33.3%
浏览 1.0k
已采纳

ADB的server源码中处理devices命令的部分在哪里?

我查看ADB源码关于处理adb devices命令的流程。发现是client给server发了条消息,内容类似于host:devices。然后接听回来的消息。但是我没找到server中处理devices命令的代码。你知道这段代码在哪里吗?不胜感谢!对了,我说的是Linux版,不是Windows版。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • nust20 2018-03-08 10:12
    已采纳

    在函数里面:
    int handle_host_request(char service, transport_type ttype, char serial, int reply_fd, asocket *s)
    处理devices命令的代码:
    // return a list of all connected devices
    if (!strncmp(service, "devices", 7)) {
    bool long_listing = (strcmp(service+7, "-l") == 0);
    if (long_listing || service[7] == 0) {
    D("Getting device list...\n");
    std::string device_list = list_transports(long_listing);
    D("Sending device list...\n");
    SendOkay(reply_fd);
    SendProtocolString(reply_fd, device_list);
    return 0;
    }
    return 1;
    }

    给你打个调用栈:

    #0 handle_host_request (service=0x5555556b8389 "devices", ttype=kTransportAny, serial=0x0, reply_fd=9, s=0x5555556b8020) at system/core/adb/adb.cpp:801
    #1 0x000055555558598c in smart_socket_enqueue (s=0x5555556b8020, p=) at system/core/adb/sockets.cpp:771
    #2 0x000055555558411f in local_socket_event_func (fd=, ev=1, _s=0x5555556b7f80) at system/core/adb/sockets.cpp:362
    #3 0x000055555558c1d4 in fdevent_call_fdfunc (fde=) at system/core/adb/fdevent.cpp:510
    #4 fdevent_loop () at system/core/adb/fdevent.cpp:692
    #5 0x0000555555574225 in adb_main (is_daemon=, server_port=) at system/core/adb/adb_main.cpp:343
    #6 0x0000555555574e35 in adb_commandline (argc=, argv=) at system/core/adb/commandline.cpp:1076
    #7 0x00007ffff6ee6830 in __libc_start_main (main=0x555555574320 , argc=5, argv=0x7fffffffd838, init=, fini=,
    rtld_fini=, stack_end=0x7fffffffd828) at ../csu/libc-start.c:291
    #8 0x0000555555573c59 in _start ()

    !!!!望采纳!!!!

    点赞 打赏 评论

相关推荐 更多相似问题