开发站与公开站API接口调试完成
This commit is contained in:
		@@ -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) {
 | 
			
		||||
                        // 显示运行状态
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user