zoukankan      html  css  js  c++  java
  • 老李推荐:第14章4节《MonkeyRunner源码剖析》 HierarchyViewer实现原理-装备ViewServer-端口转发 1

    老李推荐:第14章4节《MonkeyRunner源码剖析》 HierarchyViewer实现原理-装备ViewServer-端口转发

     

    在初始化HierarchyViewer的实例过程中,HierarchyViewer会调用自己的成员方法setupViewServer来把ViewServer装备好,那么我们这里先看下这个方法:

    39     private void setupViewServer() {  

    40         DeviceBridge.setupDeviceForward(mDevice);  

    41         if (!DeviceBridge.isViewServerRunning(mDevice)) {  

    42             if (!DeviceBridge.startViewServer(mDevice)) {  

    43                 // TODO: Get rid of this delay.  

    44                 try {  

    45                     Thread.sleep(2000);  

    46                 } catch (InterruptedException e) {  

    47                 }  

    48                 if (!DeviceBridge.startViewServer(mDevice)) {  

    49                     Log.e(TAG, "Unable to debug device " + mDevice);  

    50                     throw new RuntimeException("Could not connect to the view server");  

    51                 }  

    52                 return;  

    53             }  

    54         }  

    55         DeviceBridge.loadViewServerInfo(mDevice);  

    56     }  

    代码14-4-1 HierarchyViewer-setupViewServer

    从以上代码中我们可以看到该方法去装备ViewServer主要做的事情有如下几点:

    • 40行:设置本地端口到目标机器端ViewServer监听端口的端口转发
    • 41-54行:确定ViewServer线程是否已经启动,没有的话就启动它。
    • 55行:获取ViewServer的版本以及其支持的协议版本
  • 相关阅读:
    node.js
    js中文乱码问题
    238. Product of Array Except Self
    接下来要记得东西
    javascript 块内函数
    171. Excel Sheet Column Number
    Moore’s Voting Algorithm
    [ Python ] PIL
    [ Python ] KMP Algorithms
    房之事
  • 原文地址:https://www.cnblogs.com/poptest/p/5099757.html
Copyright © 2011-2022 走看看