Skip to content

Commit

Permalink
更新V1.3.8
Browse files Browse the repository at this point in the history
- 优化体验
- 修复问题
  • Loading branch information
mingzhixian committed Jan 23, 2024
1 parent 0777006 commit 95cce47
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 26 deletions.
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 10307
versionName "1.3.7"
versionCode 10308
versionName "1.3.8"
ndk {
abiFilters "arm64-v8a", "armeabi-v7a", "x86", "x86_64"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package top.saymzx.easycontrol.app;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.widget.Toast;

Expand Down Expand Up @@ -35,8 +36,11 @@ private void setButtonListener() {
activeActivity.active.setOnClickListener(v -> {
String activeKey = String.valueOf(activeActivity.key.getText());
AppData.setting.setActiveKey(activeKey);
Dialog dialog = PublicTools.createClientLoading(AppData.main);
dialog.show();
new Thread(() -> {
boolean isOk = ActiveHelper.checkOk(activeKey);
dialog.cancel();
AppData.uiHandler.post(() -> {
if (isOk) {
finish();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ public static ByteBuffer generateSyncHeader(String id, int arg) {

private static int payloadChecksum(byte[] payload) {
int checksum = 0;
for (byte b : payload) {
checksum += (b & 0xFF);
}
for (byte b : payload) checksum += (b & 0xFF);
return checksum;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package top.saymzx.easycontrol.app.adb;

import android.util.Log;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand Down Expand Up @@ -45,6 +47,7 @@ public ByteBuffer read(int size) throws IOException {
@Override
public void close() {
try {
Log.e("aaa","channel close");
outputStream.close();
inputStream.close();
socket.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class UsbChannel implements AdbChannel {

public UsbChannel(UsbDevice usbDevice) throws IOException {
// 连接USB设备
if (AppData.usbManager == null) throw new IOException("not have usbManager");
usbConnection = AppData.usbManager.openDevice(usbDevice);
if (usbConnection == null) return;
// 查找ADB的接口
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public class Client {
public final ControlPacket controlPacket = new ControlPacket(this::write);
public final ClientView clientView;
public final String uuid;
private Thread startThread;
private Thread timeOutThread;

private static final String serverName = "/data/local/tmp/easycontrol_server_" + BuildConfig.VERSION_CODE + ".jar";
private static final boolean supportH265 = PublicTools.isDecoderSupport("hevc");
Expand All @@ -50,27 +52,28 @@ public Client(Device device) {

public Client(Device device, UsbDevice usbDevice) {
allClient.add(this);
// 初始化
Thread timeOutThread = new Thread(() -> {
uuid = device.uuid;
Dialog dialog = PublicTools.createClientLoading(AppData.main);
// 超时
timeOutThread = new Thread(() -> {
try {
Thread.sleep(10 * 1000);
if (startThread != null) startThread.interrupt();
if (dialog.isShowing()) dialog.cancel();
release(null);
} catch (InterruptedException ignored) {
}
});
timeOutThread.start();
uuid = device.uuid;
// 界面
clientView = new ClientView(device, controlPacket, () -> {
status = 1;
executeVideoStreamInThread.setPriority(Thread.MAX_PRIORITY);
executeVideoStreamInThread.start();
executeStreamInThread.start();
AppData.uiHandler.post(this::executeOtherService);
}, () -> release(null));
Dialog dialog = PublicTools.createClientLoading(AppData.main);
dialog.show();
// 连接
new Thread(() -> {
startThread = new Thread(() -> {
try {
adb = connectADB(device, usbDevice);
startServer(device);
Expand All @@ -83,9 +86,13 @@ public Client(Device device, UsbDevice usbDevice) {
release(e.toString());
} finally {
dialog.cancel();
timeOutThread.interrupt();
if (timeOutThread != null) timeOutThread.interrupt();
}
}).start();
});
// 启动
dialog.show();
timeOutThread.start();
startThread.start();
}

// 连接ADB
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package top.saymzx.easycontrol.app.entity;

import top.saymzx.easycontrol.app.helper.PublicTools;

public class Device {
public static final int TYPE_NORMAL = 1;
public static final int TYPE_LINK = 2;
Expand All @@ -21,7 +23,7 @@ public class Device {
public int small_y;
public static int SMALL_Y = 100;
public int small_length;
public static int SMALL_LENGTH = 1000;
public static int SMALL_LENGTH = 0;
public int mini_y;
public static int MINI_Y = 200;

Expand Down Expand Up @@ -60,6 +62,7 @@ public Device(String uuid,
}

public static Device getDefaultDevice(String uuid, int type) {
if (SMALL_LENGTH == 0) SMALL_LENGTH = PublicTools.dp2px(500f);
return new Device(uuid, type, uuid, "", AppData.setting.getDefaultIsAudio(), AppData.setting.getDefaultMaxSize(), AppData.setting.getDefaultMaxFps(), AppData.setting.getDefaultMaxVideoBit(), AppData.setting.getDefaultSetResolution(), AppData.setting.getDefaultFull(), AppData.setting.getDefaultUseH265(), AppData.setting.getDefaultUseOpus(), SMALL_X, SMALL_Y, SMALL_LENGTH, MINI_Y);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,13 @@ public void startDefault() {

// 检查已连接设备
public void checkConnectedUsb(Context context) {
if (AppData.usbManager==null)return;
for (Map.Entry<String, UsbDevice> entry : AppData.usbManager.getDeviceList().entrySet()) onConnectUsb(context, entry.getValue());
}

// 请求USB设备权限
private void onConnectUsb(Context context, UsbDevice usbDevice) {
if (AppData.usbManager==null)return;
PendingIntent permissionIntent = PendingIntent.getBroadcast(context, 0, new Intent(ACTION_USB_PERMISSION), PendingIntent.FLAG_MUTABLE);
AppData.usbManager.requestPermission(usbDevice, permissionIntent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static int dp2px(Float dp) {
// 创建弹窗
public static Dialog createDialog(Context context, boolean canCancel, View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setCancelable(true);
builder.setCancelable(canCancel);
ScrollView dialogView = ModuleDialogBinding.inflate(LayoutInflater.from(context)).getRoot();
dialogView.addView(view);
builder.setView(dialogView);
Expand Down Expand Up @@ -178,9 +178,7 @@ public static void createDeviceOptionSet(Context context, ViewGroup fatherLayout
}

// 创建Client加载框
public static Dialog createClientLoading(
Context context
) {
public static Dialog createClientLoading(Context context) {
ItemLoadingBinding loadingView = ItemLoadingBinding.inflate(LayoutInflater.from(context));
return createDialog(context, false, loadingView.getRoot());
}
Expand All @@ -192,7 +190,7 @@ public static ItemTextBinding createTextCard(
MyFunction function
) {
ItemTextBinding textView = ItemTextBinding.inflate(LayoutInflater.from(context));
textView.getRoot().setText(text);
textView.text.setText(text);
if (function != null) textView.getRoot().setOnClickListener(v -> function.run());
return textView;
}
Expand Down
27 changes: 21 additions & 6 deletions easycontrol/app/src/main/res/layout/item_text.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/cardBackground"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:text="前往官网"
android:textColor="@color/onCardBackground"
android:textSize="@dimen/smallFont"
tools:ignore="HardcodedText" />
android:paddingBottom="6dp">

<TextView
android:id="@+id/text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="前往官网"
android:textColor="@color/onCardBackground"
android:textSize="@dimen/smallFont"
tools:ignore="HardcodedText" />

<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
android:rotation="180"
android:src="@drawable/chevron_left"
android:tint="@color/onCardBackground" />
</LinearLayout>

0 comments on commit 95cce47

Please sign in to comment.