Skip to content

Commit

Permalink
更新V1.3.72
Browse files Browse the repository at this point in the history
- 完善英文翻译,感谢群友 @λ 提供的翻译
- 修复部分设备因不包含服务器证书而无法激活的问题
- 修复部分设备USB连接传输长度限制的问题
- 优化无用操作
- 提高兼容性
  • Loading branch information
mingzhixian committed Feb 14, 2024
1 parent b2b9512 commit d1c134f
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 31 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
<img src="https://gitee.com/mingzhixianweb/easycontrol/raw/master/pic/screenshot/mini.webp" width="200px">
<img src="https://gitee.com/mingzhixianweb/easycontrol/raw/master/pic/screenshot/full.webp" width="200px">

## 构建
如果您想要自己构建,请注意以下几项
- 请遵循本项目的开源协议
- 我去除了官方打包加入的激活模块相关的代码文件,所以会有报错,请自行注释掉报错代码即可

## 反馈

请在Github或Gitee提出Issue,或进入易控反馈群反馈BUG或建议。
Expand Down
4 changes: 2 additions & 2 deletions easycontrol/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "top.saymzx.easycontrol.app"
minSdk 21
targetSdk 34
versionCode 10371
versionName "1.3.71"
versionCode 10372
versionName "1.3.72"
ndk {
abiFilters "arm64-v8a", "armeabi-v7a", "x86", "x86_64"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ public class AdbProtocol {
public static final int CMD_WRTE = 0x45545257;

public static final int CONNECT_VERSION = 0x01000000;
// 旧版本的adb服务端硬编码maxdata=4096,因此这里设置为4096,若你的设备较新,可将此值设置为1024*1024以提高效率
public static final int CONNECT_MAXDATA = 1024 * 1024;
// 最大数据大小一般为1024*1024,此处设置为15*1024,是因为有些设备USB仅支持最大16*1024,所以如果ADB使用了过大的数据,会导致USB无法传输,丢失数据,所以限制ADB协议最大为15k
// 旧版本的adb服务端硬编码maxdata=4096,若设备实在太老,可尝试将此处修改为4096
public static final int CONNECT_MAXDATA = 15 * 1024;

public static final byte[] CONNECT_PAYLOAD = "host::\0".getBytes();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,13 @@ private static void handleAction(ClientController clientController, String actio
else if (action.equals("buttonRotate")) clientController.clientStream.writeToMain(ControlPacket.createRotateEvent());
else if (action.equals("keepAlive")) clientController.clientStream.writeToMain(ControlPacket.createKeepAlive());
else if (action.equals("checkSizeAndSite")) clientController.checkSizeAndSite();
else if (action.equals("checkClipBoard")) clientController.checkClipBoard();
else if (byteBuffer == null) return;
else if (action.equals("writeByteBuffer")) clientController.clientStream.writeToMain(byteBuffer);
else if (action.equals("updateMaxSize")) clientController.updateMaxSize(byteBuffer);
else if (action.equals("updateVideoSize")) clientController.updateVideoSize(byteBuffer);
else if (action.equals("runShell")) clientController.runShell(byteBuffer);
else if (action.equals("setClipBoard")) clientController.setClipBoard(byteBuffer);
} catch (Exception ignored) {
clientController.close(AppData.applicationContext.getString(R.string.error_stream_closed));
}
Expand Down Expand Up @@ -171,7 +173,7 @@ private void close(String error) {
else if (AppData.setting.getLightOnClose()) handleControllNow(device.uuid, "buttonLight", null);
if (error != null && device.isNormalDevice() && AppData.setting.getReconnectOnClose()) new Client(device);
// 打印日志
if (error != null) PublicTools.logToast(error);
if (error != null) PublicTools.logToast("controller", error, true);
allController.remove(device.uuid);
if (surfaceTexture != null) surfaceTexture.release();
handle.run(false);
Expand Down Expand Up @@ -256,7 +258,7 @@ private void createTouchPacket(MotionEvent event, int action, int i) {
// 剪切板
private String nowClipboardText = "";

public void checkClipBoard() {
private void checkClipBoard() {
ClipData clipBoard = AppData.clipBoard.getPrimaryClip();
if (clipBoard != null && clipBoard.getItemCount() > 0) {
String newClipBoardText = String.valueOf(clipBoard.getItemAt(0).getText());
Expand All @@ -267,9 +269,9 @@ public void checkClipBoard() {
}
}

public void setClipBoard(String text) {
nowClipboardText = text;
AppData.clipBoard.setPrimaryClip(ClipData.newPlainText(MIMETYPE_TEXT_PLAIN, text));
private void setClipBoard(ByteBuffer byteBuffer) {
nowClipboardText = new String(byteBuffer.array());
AppData.clipBoard.setPrimaryClip(ClipData.newPlainText(MIMETYPE_TEXT_PLAIN, nowClipboardText));
}

private void runShell(ByteBuffer byteBuffer) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,16 @@ private void mainStreamIn() {
else audioDecode = new AudioDecode(useOpus, audioFrame, playHandler);
break;
case CLIPBOARD_EVENT:
clientController.setClipBoard(new String(clientStream.readByteArrayFromMain(clientStream.readIntFromMain()).array()));
ClientController.handleControll(device.uuid, "setClipBoard", clientStream.readByteArrayFromMain(clientStream.readIntFromMain()));
break;
case CHANGE_SIZE_EVENT:
ByteBuffer byteBuffer = clientStream.readByteArrayFromMain(8);
ClientController.handleControll(device.uuid, "updateVideoSize", byteBuffer);
ClientController.handleControll(device.uuid, "updateVideoSize", clientStream.readByteArrayFromMain(8));
break;
}
}
} catch (InterruptedException ignored) {
} catch (Exception e) {
PublicTools.logToast(e.toString());
PublicTools.logToast("player", e.toString(), false);
} finally {
if (audioDecode != null) audioDecode.release();
}
Expand All @@ -84,7 +83,7 @@ private void videoStreamIn() {

private void otherService() {
if (!isClose) {
clientController.checkClipBoard();
ClientController.handleControll(device.uuid, "checkClipBoard", null);
ClientController.handleControll(device.uuid, "keepAlive", null);
ClientController.handleControll(device.uuid, "checkSizeAndSite", null);
AppData.uiHandler.postDelayed(this::otherService, 2000);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package top.saymzx.easycontrol.app.client;

import android.hardware.usb.UsbDevice;
import android.util.Log;
import android.util.Pair;

import java.io.DataInputStream;
Expand All @@ -23,6 +22,7 @@
public class ClientStream {
private boolean isClose = false;
private boolean connectDirect = false;
private final boolean connectByUsb;
private Adb adb;
private Socket mainSocket;
private Socket videoSocket;
Expand All @@ -38,11 +38,12 @@ public class ClientStream {
private static final boolean supportOpus = DecodecTools.isSupportOpus();

public ClientStream(Device device, UsbDevice usbDevice, MyInterface.MyFunctionBoolean handle) {
connectByUsb = usbDevice != null;
// 超时
Thread timeOutThread = new Thread(() -> {
try {
Thread.sleep(10 * 1000);
PublicTools.logToast(AppData.applicationContext.getString(R.string.error_timeout));
PublicTools.logToast("stream", AppData.applicationContext.getString(R.string.error_timeout), true);
handle.run(false);
if (connectThread != null) connectThread.interrupt();
} catch (InterruptedException ignored) {
Expand All @@ -52,13 +53,13 @@ public ClientStream(Device device, UsbDevice usbDevice, MyInterface.MyFunctionBo
connectThread = new Thread(() -> {
try {
Pair<String, Integer> address = null;
if (usbDevice == null) address = PublicTools.getIpAndPort(device.address);
if (!connectByUsb) address = PublicTools.getIpAndPort(device.address);
adb = connectADB(address, usbDevice);
startServer(device);
connectServer(address);
handle.run(true);
} catch (Exception e) {
PublicTools.logToast(e.toString());
PublicTools.logToast("stream", e.toString(), true);
handle.run(false);
} finally {
timeOutThread.interrupt();
Expand Down Expand Up @@ -166,13 +167,14 @@ public ByteBuffer readByteArrayFromVideo(int size) throws IOException, Interrupt
}

public ByteBuffer readFrameFromMain() throws Exception {
if (!connectDirect) mainBufferStream.flush();
if (!connectByUsb && !connectDirect) mainBufferStream.flush();
return readByteArrayFromMain(readIntFromMain());
}

public ByteBuffer readFrameFromVideo() throws Exception {
if (!connectDirect) videoBufferStream.flush();
return readByteArrayFromVideo(readIntFromVideo());
if (!connectByUsb && !connectDirect) videoBufferStream.flush();
int size = readIntFromVideo();
return readByteArrayFromVideo(size);
}

public void writeToMain(ByteBuffer byteBuffer) throws Exception {
Expand All @@ -183,7 +185,7 @@ public void writeToMain(ByteBuffer byteBuffer) throws Exception {
public void close() {
if (isClose) return;
isClose = true;
if (shell != null) Log.e("Easycontrol_server", new String(shell.readByteArrayBeforeClose().array()));
if (shell != null) PublicTools.logToast("server", new String(shell.readByteArrayBeforeClose().array()), false);
if (connectDirect) {
try {
mainOutputStream.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import android.hardware.usb.UsbInterface;
import android.hardware.usb.UsbManager;
import android.os.Build;
import android.view.KeyEvent;

import java.nio.ByteBuffer;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ public static void startUrl(Context context, String url) {
}

// 日志
public static void logToast(String str) {
Log.e("Easycontrol", str);
AppData.uiHandler.post(() -> Toast.makeText(AppData.applicationContext, str, Toast.LENGTH_SHORT).show());
public static void logToast(String type, String msg, boolean showToast) {
Log.e("Easycontrol_" + type, msg);
if (showToast) AppData.uiHandler.post(() -> Toast.makeText(AppData.applicationContext, type + ":" + msg, Toast.LENGTH_SHORT).show());
}

// 获取密钥文件
Expand Down
12 changes: 6 additions & 6 deletions easycontrol/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

<!-- 激活页面 -->
<string name="active_url">前往捐赠地址</string>
<string name="active_key">捐赠订单号: 35元及以上 \n * 2024.2.1-2024.2.15 期间30元</string>
<string name="active_key">捐赠订单号: 35元及以上</string>
<string name="active_button">激活</string>
<string name="active_key_hint">
* 捐赠后将于24小时内录入系统,请耐心等待 \n
Expand Down Expand Up @@ -112,16 +112,16 @@
<string name="error_stream_closed">连接断开</string>

<!-- 设备参数设置及注释说明 -->
<string name="option_is_audio">使能音频</string>
<string name="option_is_audio_detail">开启后将尝试传输音频,被控端需要安卓12之上</string>
<string name="option_is_audio">音频</string>
<string name="option_is_audio_detail">被控端需要安卓12之上</string>
<string name="option_max_size">最大大小</string>
<string name="option_max_size_detail">设置画面长和宽的最大大小</string>
<string name="option_max_size_detail">设置画面的最大大小</string>
<string name="option_max_fps">最大帧率</string>
<string name="option_max_fps_detail">最大帧率限制,值越低画面越卡顿,但流量也越小,延迟也会降低</string>
<string name="option_max_fps_detail">最大帧率限制,值越低画面越卡顿</string>
<string name="option_max_video_bit">最大码率</string>
<string name="option_max_video_bit_detail">码率越大视频损失越小体积越大,建议设置为4,过高会导致延迟增加</string>
<string name="option_use_h265">优先H265</string>
<string name="option_use_h265_detail">优先使用H265,视频体积小延迟低,实际以支持情况为主,若视频异常可尝试关闭</string>
<string name="option_use_h265_detail">优先使用H265,视频体积小延迟低,若画面异常可尝试关闭</string>
<string name="option_set_resolution">修改分辨率</string>
<string name="option_set_resolution_detail">开启后会自动修改被控端分辨率,可能会无法自动恢复(可手动恢复),慎重考虑</string>

Expand Down

0 comments on commit d1c134f

Please sign in to comment.