From d474eb615897db189596b56987252f1d0efcaf5e Mon Sep 17 00:00:00 2001 From: ZhanGSKen Date: Sun, 30 Mar 2025 01:36:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=8F=91=E7=AB=99=E4=B8=8E=E5=85=AC?= =?UTF-8?q?=E5=BC=80=E7=AB=99API=E6=8E=A5=E5=8F=A3=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aes/build.properties | 4 ++-- .../main/res/xml/network_security_config.xml | 3 +-- libaes/build.properties | 4 ++-- .../libaes/winboll/WinBollClientService.java | 8 +++---- .../WinBollServerConnectionTestThread.java | 22 ++++++------------- 5 files changed, 16 insertions(+), 25 deletions(-) diff --git a/aes/build.properties b/aes/build.properties index f35b191..88a5bfc 100644 --- a/aes/build.properties +++ b/aes/build.properties @@ -1,8 +1,8 @@ #Created by .winboll/winboll_app_build.gradle -#Sat Mar 29 16:59:59 GMT 2025 +#Sat Mar 29 17:35:04 GMT 2025 stageCount=2 libraryProject=libaes baseVersion=15.2 publishVersion=15.2.1 -buildCount=25 +buildCount=38 baseBetaVersion=15.2.2 diff --git a/aes/src/main/res/xml/network_security_config.xml b/aes/src/main/res/xml/network_security_config.xml index 4555da5..ee39aa4 100644 --- a/aes/src/main/res/xml/network_security_config.xml +++ b/aes/src/main/res/xml/network_security_config.xml @@ -1,7 +1,6 @@ - www.winboll.cc - dev.winboll.cc + winboll.cc diff --git a/libaes/build.properties b/libaes/build.properties index f35b191..88a5bfc 100644 --- a/libaes/build.properties +++ b/libaes/build.properties @@ -1,8 +1,8 @@ #Created by .winboll/winboll_app_build.gradle -#Sat Mar 29 16:59:59 GMT 2025 +#Sat Mar 29 17:35:04 GMT 2025 stageCount=2 libraryProject=libaes baseVersion=15.2 publishVersion=15.2.1 -buildCount=25 +buildCount=38 baseBetaVersion=15.2.2 diff --git a/libaes/src/main/java/cc/winboll/studio/libaes/winboll/WinBollClientService.java b/libaes/src/main/java/cc/winboll/studio/libaes/winboll/WinBollClientService.java index edd8cf7..8766f81 100644 --- a/libaes/src/main/java/cc/winboll/studio/libaes/winboll/WinBollClientService.java +++ b/libaes/src/main/java/cc/winboll/studio/libaes/winboll/WinBollClientService.java @@ -27,7 +27,7 @@ public class WinBollClientService extends Service implements IWinBollClientServi MyServiceConnection mMyServiceConnection; volatile boolean mIsWinBollClientThreadRunning; volatile boolean mIsEnableService; - WinBollClientThread mWinBollClientThread; + volatile WinBollClientThread mWinBollClientThread; public boolean isWinBollClientThreadRunning() { return mIsWinBollClientThreadRunning; @@ -80,7 +80,7 @@ public class WinBollClientService extends Service implements IWinBollClientServi return mIsEnableService ? Service.START_STICKY: super.onStartCommand(intent, flags, startId); } - void runMainThread() { + synchronized void runMainThread() { if (mWinBollClientThread == null) { ToastUtils.show("runMainThread()"); mWinBollClientThread = new WinBollClientThread(); @@ -163,7 +163,7 @@ public class WinBollClientService extends Service implements IWinBollClientServi // 设置运行状态 mIsWinBollClientThreadRunning = true; - ToastUtils.show("run()"); + LogUtils.d(TAG, "WinBollClientThread run()"); // 唤醒守护进程 //wakeupAndBindAssistant(); @@ -178,7 +178,7 @@ public class WinBollClientService extends Service implements IWinBollClientServi username = "WinBoll"; password = "WinBollPowerByZhanGSKen"; } - targetUrl = "https://" + (GlobalApplication.isDebuging() ?"dev": "www") + ".winboll.cc/api"; // 替换为实际测试的URL + targetUrl = "https://" + (GlobalApplication.isDebuging() ?"dev.winboll": "winboll") + ".cc/api/"; // 替换为实际测试的URL while (mIsEnableService) { // 显示运行状态 diff --git a/libaes/src/main/java/cc/winboll/studio/libaes/winboll/WinBollServerConnectionTestThread.java b/libaes/src/main/java/cc/winboll/studio/libaes/winboll/WinBollServerConnectionTestThread.java index ba24017..65696be 100644 --- a/libaes/src/main/java/cc/winboll/studio/libaes/winboll/WinBollServerConnectionTestThread.java +++ b/libaes/src/main/java/cc/winboll/studio/libaes/winboll/WinBollServerConnectionTestThread.java @@ -7,14 +7,12 @@ package cc.winboll.studio.libaes.winboll; */ import cc.winboll.studio.libappbase.LogUtils; import java.io.IOException; -import okhttp3.Authenticator; import okhttp3.Call; import okhttp3.Callback; import okhttp3.Credentials; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; -import okhttp3.Route; public class WinBollServerConnectionTestThread extends Thread { @@ -45,23 +43,17 @@ public class WinBollServerConnectionTestThread extends Thread { @Override public void run() { LogUtils.d(TAG, String.format("run() url %s\nusername %s\npassword %s", url, username, password)); - OkHttpClient client = new OkHttpClient.Builder() - .connectTimeout(connectTimeout, java.util.concurrent.TimeUnit.MILLISECONDS) - .readTimeout(readTimeout, java.util.concurrent.TimeUnit.MILLISECONDS) - .authenticator(new Authenticator() { - @Override - public Request authenticate(Route route, Response response) throws IOException { - return response.request().newBuilder() - .header("Authorization", Credentials.basic(username, password)) - .build(); - } - }) - .build(); + // 构建包含认证信息的请求 + String credential = Credentials.basic(username, password); + LogUtils.d(TAG, String.format("credential %s", credential)); + OkHttpClient client = new OkHttpClient(); Request request = new Request.Builder() .url(url) + .header("Accept", "text/plain") // 设置正确的Content-Type头 + .header("Authorization", credential) .build(); - + Call call = client.newCall(request); call.enqueue(new Callback() { @Override