Skip to content

Commit

Permalink
Merge pull request #72 from ZhouYixun/scrcpy_dev
Browse files Browse the repository at this point in the history
Scrcpy dev
  • Loading branch information
ZhouYixun authored Dec 11, 2021
2 parents 247c14e + 285fefe commit 7508192
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 26 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
<p align="center">
<img src="https://raw.githubusercontent.com/ZhouYixun/sonic-server/main/logo.png">
<img src="https://raw.githubusercontent.com/SonicCloudOrg/sonic-server/main/logo.png">
</p>
<p align="center">🎉Agent of Sonic Cloud Real Machine Testing Platform</p>
<p align="center">
<span>English |</span>
<a href="https://github.com/ZhouYixun/sonic-agent/blob/main/README_CN.md">
<a href="https://github.com/SonicCloudOrg/sonic-agent/blob/main/README_CN.md">
简体中文
</a>
</p>
<p align="center">
<a href="#">
<img src="https://img.shields.io/badge/release-v1.1.0-orange">
<img src="https://img.shields.io/badge/release-v1.2.0-orange">
</a>
<a href="#">
<img src="https://img.shields.io/badge/platform-windows|macosx|linux-success">
</a>
</p>
<p align="center">
<a href="#">
<img src="https://img.shields.io/github/commit-activity/m/ZhouYixun/sonic-agent">
<img src="https://img.shields.io/github/commit-activity/m/SonicCloudOrg/sonic-agent">
</a>
<a href="#">
<img src="https://img.shields.io/github/downloads/ZhouYixun/sonic-agent/total">
<img src="https://img.shields.io/github/downloads/SonicCloudOrg/sonic-agent/total">
</a>
<a href="https://github.com/ZhouYixun/sonic-server/blob/main/LICENSE">
<img src="https://img.shields.io/github/license/ZhouYiXun/sonic-server?color=green&label=license&logo=license&logoColor=green">
<a href="https://github.com/SonicCloudOrg/sonic-server/blob/main/LICENSE">
<img src="https://img.shields.io/github/license/SonicCloudOrg/sonic-server?color=green&label=license&logo=license&logoColor=green">
</a>
</p>

### Official Website
[Sonic Official Website](http://zhouyixun.gitee.io/sonic-official-website)
[Sonic Official Website](http://sonic-cloud.gitee.io)
## Background

#### What is sonic ?
Expand Down Expand Up @@ -62,7 +62,7 @@ mvn package -Pwindows-x86_64

> Can only be used on Linux or Mac!
>
> [Click Here!](https://hub.docker.com/repository/docker/zhouyixun/sonic-agent-linux)
> [Click Here!](https://hub.docker.com/repository/docker/sonicorg)
### jar Mode

Expand Down
18 changes: 9 additions & 9 deletions README_CN.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
<p align="center">
<img src="https://raw.githubusercontent.com/ZhouYixun/sonic-server/main/logo.png">
<img src="https://raw.githubusercontent.com/SonicCloudOrg/sonic-server/main/logo.png">
</p>
<p align="center">🎉Sonic云真机测试平台Agent端</p>
<p align="center">
<a href="https://github.com/ZhouYixun/sonic-agent/blob/main/README.md">
<a href="https://github.com/SonicCloudOrg/sonic-agent/blob/main/README.md">
English
</a>
<span>| 简体中文</span>
</p>
<p align="center">
<a href="#">
<img src="https://img.shields.io/badge/release-v1.1.0-orange">
<img src="https://img.shields.io/badge/release-v1.2.0-orange">
</a>
<a href="#">
<img src="https://img.shields.io/badge/platform-windows|macosx|linux-success">
</a>
</p>
<p align="center">
<a href="#">
<img src="https://img.shields.io/github/commit-activity/m/ZhouYixun/sonic-agent">
<img src="https://img.shields.io/github/commit-activity/m/SonicCloudOrg/sonic-agent">
</a>
<a href="#">
<img src="https://img.shields.io/github/downloads/ZhouYixun/sonic-agent/total">
<img src="https://img.shields.io/github/downloads/SonicCloudOrg/sonic-agent/total">
</a>
<a href="https://github.com/ZhouYixun/sonic-server/blob/main/LICENSE">
<img src="https://img.shields.io/github/license/ZhouYiXun/sonic-server?color=green&label=license&logo=license&logoColor=green">
<a href="https://github.com/SonicCloudOrg/sonic-server/blob/main/LICENSE">
<img src="https://img.shields.io/github/license/SonicCloudOrg/sonic-server?color=green&label=license&logo=license&logoColor=green">
</a>
</p>

### 官方网站
[Sonic Official Website](http://zhouyixun.gitee.io/sonic-official-website)
[Sonic Official Website](http://sonic-cloud.gitee.io)
## 背景

#### 什么是Sonic?
Expand Down Expand Up @@ -62,7 +62,7 @@ mvn package -Pwindows-x86_64

> 仅Linux和Mac可用!
>
> [点击这里!](https://hub.docker.com/repository/docker/zhouyixun/sonic-agent-linux)
> [点击这里!](https://hub.docker.com/repository/docker/sonicorg)
### jar模式

Expand Down
6 changes: 3 additions & 3 deletions config/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ modules:
android:
enable: true
# 是否开启远程adb调试功能
use-adbkit: false
use-adbkit: true
# iOS模块配置
ios:
enable: true
#替换为wda的bundleId,正常要添加.xctrunner后缀
wda-bundle-id: com.sonic.wda.xctrunner
#替换为你自己使用的wda的bundleId,正常要添加.xctrunner后缀,建议使用公司的开发者证书
wda-bundle-id: com.facebook.WebDriverAgentRunner.xctrunner
appium:
enable: true
# 在线webView调试模块配置
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/sonic/agent/automation/IOSStepHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.sonic.agent.tools.LogTool;
import com.sonic.agent.tools.UploadTools;
import io.appium.java_client.MobileBy;
import io.appium.java_client.Setting;
import io.appium.java_client.android.appmanagement.AndroidTerminateApplicationOptions;
import io.appium.java_client.android.nativekey.AndroidKey;
import io.appium.java_client.android.nativekey.KeyEvent;
Expand Down Expand Up @@ -68,6 +69,7 @@ public int startIOSDriver(String udId) throws InterruptedException, IOException
try {
iosDriver = new IOSDriver(AppiumServer.service.getUrl(), desiredCapabilities);
iosDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
iosDriver.setSetting(Setting.MJPEG_SERVER_FRAMERATE, 30);
log.sendStepLog(StepType.PASS, "连接设备驱动成功", "");
} catch (Exception e) {
log.sendStepLog(StepType.ERROR, "连接设备驱动失败!", "");
Expand Down Expand Up @@ -95,6 +97,7 @@ public void closeIOSDriver() {
List<Process> processList = IOSProcessMap.getMap().get(udId);
for (Process p : processList) {
if (p != null) {
p.children().forEach(ProcessHandle::destroy);
p.destroy();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ private void exit(Session session) {
try {
HandlerMap.getAndroidMap().get(session.getId()).closeAndroidDriver();
} catch (Exception e) {
e.printStackTrace();
logger.info("关闭driver异常!");
} finally {
HandlerMap.getAndroidMap().remove(session.getId());
}
Expand Down
16 changes: 12 additions & 4 deletions src/main/java/com/sonic/agent/websockets/IOSWSServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,25 @@
import java.util.concurrent.atomic.AtomicReference;

@Component
@ServerEndpoint(value = "/websockets/ios/{key}/{udId}", configurator = MyEndpointConfigure.class)
@ServerEndpoint(value = "/websockets/ios/{key}/{udId}/{token}", configurator = MyEndpointConfigure.class)
public class IOSWSServer {
private final Logger logger = LoggerFactory.getLogger(IOSWSServer.class);
private Map<Session, String> udIdMap = new ConcurrentHashMap<>();
@Value("${sonic.agent.key}")
private String key;

@OnOpen
public void onOpen(Session session, @PathParam("key") String secretKey, @PathParam("udId") String udId) throws Exception {
if (secretKey.length() == 0 || (!secretKey.equals(key))) {
public void onOpen(Session session, @PathParam("key") String secretKey,
@PathParam("udId") String udId, @PathParam("token") String token) throws Exception {
if (secretKey.length() == 0 || (!secretKey.equals(key)) || token.length() == 0) {
logger.info("拦截访问!");
return;
}
JSONObject jsonDebug = new JSONObject();
jsonDebug.put("msg", "debugUser");
jsonDebug.put("token", token);
jsonDebug.put("udId", udId);
NettyThreadPool.send(jsonDebug);
WebSocketSessionMap.getMap().put(session.getId(), session);
if (!TIDeviceTool.getDeviceList().contains(udId)) {
logger.info("设备未连接,请检查!");
Expand All @@ -72,6 +78,8 @@ public void onOpen(Session session, @PathParam("key") String secretKey, @PathPar
int imgPort = iosStepHandler.startIOSDriver(udId);
result.put("status", "success");
result.put("port", imgPort);
result.put("width", iosStepHandler.getDriver().manage().window().getSize().width);
result.put("height", iosStepHandler.getDriver().manage().window().getSize().height);
result.put("detail", "初始化Driver完成!");
HandlerMap.getIOSMap().put(session.getId(), iosStepHandler);
} catch (Exception e) {
Expand Down Expand Up @@ -252,7 +260,7 @@ private void exit(Session session) {
try {
HandlerMap.getIOSMap().get(session.getId()).closeIOSDriver();
} catch (Exception e) {
e.printStackTrace();
logger.info("关闭driver异常!");
} finally {
HandlerMap.getIOSMap().remove(session.getId());
}
Expand Down

0 comments on commit 7508192

Please sign in to comment.