Compare commits
17 Commits
aes-v15.0.
...
aes-v15.2.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de1b3657f8 | ||
|
|
6b70019208 | ||
|
|
641cc0d828 | ||
|
|
89ee16a69f | ||
|
|
4f44034b72 | ||
|
|
9d37de4bfc | ||
|
|
619fd39a92 | ||
|
|
d51ebbd550 | ||
|
|
d474eb6158 | ||
|
|
b1e2a018d8 | ||
|
|
81d538589f | ||
|
|
0735783811 | ||
|
|
156329707d | ||
|
|
3835800d24 | ||
|
|
5d796c4aba | ||
|
|
1891c24d4f | ||
|
|
892f9f0d6c |
@@ -29,7 +29,7 @@ android {
|
|||||||
// versionName 更新后需要手动设置
|
// versionName 更新后需要手动设置
|
||||||
// 项目模块目录的 build.gradle 文件的 stageCount=0
|
// 项目模块目录的 build.gradle 文件的 stageCount=0
|
||||||
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
|
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
|
||||||
versionName "15.0"
|
versionName "15.2"
|
||||||
if(true) {
|
if(true) {
|
||||||
versionName = genVersionName("${versionName}")
|
versionName = genVersionName("${versionName}")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Sat Mar 29 08:53:46 HKT 2025
|
#Mon Mar 31 02:04:35 HKT 2025
|
||||||
stageCount=10
|
stageCount=4
|
||||||
libraryProject=libaes
|
libraryProject=libaes
|
||||||
baseVersion=15.0
|
baseVersion=15.2
|
||||||
publishVersion=15.0.9
|
publishVersion=15.2.3
|
||||||
buildCount=0
|
buildCount=0
|
||||||
baseBetaVersion=15.0.10
|
baseBetaVersion=15.2.4
|
||||||
|
|||||||
@@ -10,7 +10,8 @@
|
|||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/MyAESTheme"
|
android:theme="@style/MyAESTheme"
|
||||||
android:requestLegacyExternalStorage="true"
|
android:requestLegacyExternalStorage="true"
|
||||||
android:supportsRtl="true">
|
android:supportsRtl="true"
|
||||||
|
android:networkSecurityConfig="@xml/network_security_config">
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
|
|||||||
@@ -5,23 +5,25 @@ package cc.winboll.studio.aes;
|
|||||||
* @Date 2025/03/24 23:52:29
|
* @Date 2025/03/24 23:52:29
|
||||||
* @Describe AES应用介绍窗口
|
* @Describe AES应用介绍窗口
|
||||||
*/
|
*/
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import cc.winboll.studio.libaes.winboll.APPInfo;
|
import cc.winboll.studio.libaes.winboll.APPInfo;
|
||||||
import cc.winboll.studio.libaes.winboll.AboutView;
|
import cc.winboll.studio.libaes.winboll.AboutView;
|
||||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||||
import cc.winboll.studio.libappbase.winboll.IWinBollActivity;
|
import cc.winboll.studio.libappbase.winboll.IWinBollActivity;
|
||||||
import android.app.Activity;
|
|
||||||
|
|
||||||
public class AboutActivity extends AppCompatActivity implements IWinBollActivity {
|
public class AboutActivity extends WinBollActivity implements IWinBollActivity {
|
||||||
|
|
||||||
public static final String TAG = "AboutActivity";
|
public static final String TAG = "AboutActivity";
|
||||||
|
|
||||||
Context mContext;
|
Context mContext;
|
||||||
|
Toolbar mToolbar;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Activity getActivity() {
|
public Activity getActivity() {
|
||||||
return this;
|
return this;
|
||||||
@@ -36,17 +38,31 @@ public class AboutActivity extends AppCompatActivity implements IWinBollActivity
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
mContext = this;
|
mContext = this;
|
||||||
|
setContentView(R.layout.activity_about);
|
||||||
|
|
||||||
|
mToolbar = findViewById(R.id.toolbar);
|
||||||
|
setSupportActionBar(mToolbar);
|
||||||
|
mToolbar.setSubtitle(TAG);
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
AboutView aboutView = CreateAboutView();
|
AboutView aboutView = CreateAboutView();
|
||||||
// 在 Activity 的 onCreate 或其他生命周期方法中调用
|
// 在 Activity 的 onCreate 或其他生命周期方法中调用
|
||||||
LinearLayout layout = new LinearLayout(this);
|
// LinearLayout layout = new LinearLayout(this);
|
||||||
layout.setOrientation(LinearLayout.VERTICAL);
|
// layout.setOrientation(LinearLayout.VERTICAL);
|
||||||
|
// // 创建布局参数(宽度和高度)
|
||||||
|
// ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
|
||||||
|
// ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
|
// ViewGroup.LayoutParams.MATCH_PARENT
|
||||||
|
// );
|
||||||
|
// addContentView(aboutView, params);
|
||||||
|
|
||||||
|
LinearLayout layout = findViewById(R.id.aboutviewroot_ll);
|
||||||
// 创建布局参数(宽度和高度)
|
// 创建布局参数(宽度和高度)
|
||||||
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
|
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT
|
ViewGroup.LayoutParams.MATCH_PARENT
|
||||||
);
|
);
|
||||||
addContentView(aboutView, params);
|
layout.addView(aboutView, params);
|
||||||
|
|
||||||
GlobalApplication.getWinBollActivityManager().add(this);
|
GlobalApplication.getWinBollActivityManager().add(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class App extends GlobalApplication {
|
|||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
ToastUtils.init(this);
|
ToastUtils.init(this);
|
||||||
ToastUtils.show("App onCreate");
|
//ToastUtils.show("App onCreate");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class MainActivity extends DrawerFragmentActivity implements IWinBollActi
|
|||||||
}
|
}
|
||||||
showFragment(mTestAButtonFragment);
|
showFragment(mTestAButtonFragment);
|
||||||
//setSubtitle(TAG);
|
//setSubtitle(TAG);
|
||||||
ToastUtils.show("onCreate");
|
//ToastUtils.show("onCreate");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
50
aes/src/main/java/cc/winboll/studio/aes/WinBollActivity.java
Normal file
50
aes/src/main/java/cc/winboll/studio/aes/WinBollActivity.java
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
package cc.winboll.studio.aes;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import cc.winboll.studio.libaes.beans.AESThemeBean;
|
||||||
|
import cc.winboll.studio.libaes.utils.AESThemeUtil;
|
||||||
|
import cc.winboll.studio.libappbase.winboll.IWinBollActivity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author ZhanGSKen@AliYun.Com
|
||||||
|
* @Date 2025/03/30 00:34:02
|
||||||
|
* @Describe WinBoll 活动窗口通用基类
|
||||||
|
*/
|
||||||
|
public class WinBollActivity extends AppCompatActivity implements IWinBollActivity {
|
||||||
|
|
||||||
|
public static final String TAG = "WinBollActivity";
|
||||||
|
|
||||||
|
protected volatile AESThemeBean.ThemeType mThemeType;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Activity getActivity() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTag() {
|
||||||
|
return TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
mThemeType = getThemeType();
|
||||||
|
setThemeStyle();
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
AESThemeBean.ThemeType getThemeType() {
|
||||||
|
/*SharedPreferences sharedPreferences = getSharedPreferences(
|
||||||
|
SHAREDPREFERENCES_NAME, MODE_PRIVATE);
|
||||||
|
return AESThemeBean.ThemeType.values()[((sharedPreferences.getInt(DRAWER_THEME_TYPE, AESThemeBean.ThemeType.DEFAULT.ordinal())))];
|
||||||
|
*/
|
||||||
|
return AESThemeBean.getThemeStyleType(AESThemeUtil.getThemeTypeID(getApplicationContext()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void setThemeStyle() {
|
||||||
|
//setTheme(AESThemeBean.getThemeStyle(getThemeType()));
|
||||||
|
setTheme(AESThemeUtil.getThemeTypeID(getApplicationContext()));
|
||||||
|
}
|
||||||
|
}
|
||||||
22
aes/src/main/res/layout/activity_about.xml
Normal file
22
aes/src/main/res/layout/activity_about.xml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<cc.winboll.studio.libaes.views.ASupportToolbar
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/toolbar"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1.0"
|
||||||
|
android:id="@+id/aboutviewroot_ll"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
6
aes/src/main/res/xml/network_security_config.xml
Normal file
6
aes/src/main/res/xml/network_security_config.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<network-security-config>
|
||||||
|
<domain-config cleartextTrafficPermitted="true">
|
||||||
|
<domain includeSubdomains="true">winboll.cc</domain>
|
||||||
|
</domain-config>
|
||||||
|
</network-security-config>
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Sat Mar 29 08:53:46 HKT 2025
|
#Mon Mar 31 02:04:35 HKT 2025
|
||||||
stageCount=10
|
stageCount=4
|
||||||
libraryProject=libaes
|
libraryProject=libaes
|
||||||
baseVersion=15.0
|
baseVersion=15.2
|
||||||
publishVersion=15.0.9
|
publishVersion=15.2.3
|
||||||
buildCount=0
|
buildCount=0
|
||||||
baseBetaVersion=15.0.10
|
baseBetaVersion=15.2.4
|
||||||
|
|||||||
@@ -5,19 +5,26 @@
|
|||||||
|
|
||||||
<application>
|
<application>
|
||||||
|
|
||||||
<activity android:name="cc.winboll.studio.libaes.unittests.SecondaryLibraryActivity"/>
|
<activity android:name="cc.winboll.studio.libaes.unittests.SecondaryLibraryActivity"
|
||||||
|
android:exported="true"/>
|
||||||
|
|
||||||
<activity android:name="cc.winboll.studio.libaes.unittests.TestDrawerFragmentActivity"/>
|
<activity android:name="cc.winboll.studio.libaes.unittests.TestDrawerFragmentActivity"
|
||||||
|
android:exported="true"/>
|
||||||
|
|
||||||
<activity android:name="cc.winboll.studio.libaes.unittests.TestAToolbarActivity"/>
|
<activity android:name="cc.winboll.studio.libaes.unittests.TestAToolbarActivity"
|
||||||
|
android:exported="true"/>
|
||||||
|
|
||||||
<activity android:name="cc.winboll.studio.libaes.unittests.TestASupportToolbarActivity"/>
|
<activity android:name="cc.winboll.studio.libaes.unittests.TestASupportToolbarActivity"
|
||||||
|
android:exported="true"/>
|
||||||
|
|
||||||
<service android:name="cc.winboll.studio.libaes.winboll.WinBollClientService"/>
|
<service android:name="cc.winboll.studio.libaes.winboll.WinBollClientService"
|
||||||
|
android:exported="true"/>
|
||||||
|
|
||||||
<service android:name="cc.winboll.studio.libaes.winboll.AssistantService"/>
|
<service android:name="cc.winboll.studio.libaes.winboll.AssistantService"
|
||||||
|
android:exported="true"/>
|
||||||
|
|
||||||
<service android:name="cc.winboll.studio.libaes.winboll.WinBollMail"/>
|
<service android:name="cc.winboll.studio.libaes.winboll.WinBollMail"
|
||||||
|
android:exported="true"/>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import cc.winboll.studio.libaes.beans.AESThemeBean;
|
|||||||
import cc.winboll.studio.libaes.beans.DrawerMenuBean;
|
import cc.winboll.studio.libaes.beans.DrawerMenuBean;
|
||||||
import cc.winboll.studio.libaes.utils.AESThemeUtil;
|
import cc.winboll.studio.libaes.utils.AESThemeUtil;
|
||||||
import cc.winboll.studio.libaes.views.ADrawerMenuListView;
|
import cc.winboll.studio.libaes.views.ADrawerMenuListView;
|
||||||
|
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
import cc.winboll.studio.libappbase.winboll.IWinBollActivity;
|
import cc.winboll.studio.libappbase.winboll.IWinBollActivity;
|
||||||
import com.baoyz.widget.PullRefreshLayout;
|
import com.baoyz.widget.PullRefreshLayout;
|
||||||
@@ -175,6 +176,8 @@ public abstract class DrawerFragmentActivity extends AppCompatActivity implement
|
|||||||
for (int i = Integer.MIN_VALUE; i < Integer.MAX_VALUE; i++) {
|
for (int i = Integer.MIN_VALUE; i < Integer.MAX_VALUE; i++) {
|
||||||
getString(i);
|
getString(i);
|
||||||
}
|
}
|
||||||
|
} else if (R.id.item_log == item.getItemId()) {
|
||||||
|
GlobalApplication.getWinBollActivityManager().startLogActivity(this);
|
||||||
} else if (R.id.item_about == item.getItemId()) {
|
} else if (R.id.item_about == item.getItemId()) {
|
||||||
LogUtils.d(TAG, "onAbout");
|
LogUtils.d(TAG, "onAbout");
|
||||||
} else if (android.R.id.home == item.getItemId()) {
|
} else if (android.R.id.home == item.getItemId()) {
|
||||||
|
|||||||
@@ -13,8 +13,10 @@ import android.content.ServiceConnection;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import cc.winboll.studio.libaes.winboll.AssistantService;
|
import cc.winboll.studio.libaes.winboll.AssistantService;
|
||||||
|
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
import cc.winboll.studio.libappbase.utils.ServiceUtils;
|
import cc.winboll.studio.libappbase.utils.ServiceUtils;
|
||||||
|
import cc.winboll.studio.libapputils.utils.PrefUtils;
|
||||||
import com.hjq.toast.ToastUtils;
|
import com.hjq.toast.ToastUtils;
|
||||||
|
|
||||||
public class WinBollClientService extends Service implements IWinBollClientServiceBinder {
|
public class WinBollClientService extends Service implements IWinBollClientServiceBinder {
|
||||||
@@ -25,7 +27,7 @@ public class WinBollClientService extends Service implements IWinBollClientServi
|
|||||||
MyServiceConnection mMyServiceConnection;
|
MyServiceConnection mMyServiceConnection;
|
||||||
volatile boolean mIsWinBollClientThreadRunning;
|
volatile boolean mIsWinBollClientThreadRunning;
|
||||||
volatile boolean mIsEnableService;
|
volatile boolean mIsEnableService;
|
||||||
WinBollClientThread mWinBollClientThread;
|
volatile WinBollClientThread mWinBollClientThread;
|
||||||
|
|
||||||
public boolean isWinBollClientThreadRunning() {
|
public boolean isWinBollClientThreadRunning() {
|
||||||
return mIsWinBollClientThreadRunning;
|
return mIsWinBollClientThreadRunning;
|
||||||
@@ -50,7 +52,7 @@ public class WinBollClientService extends Service implements IWinBollClientServi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
ToastUtils.show("onCreate");
|
//ToastUtils.show("onCreate");
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
mWinBollClientThread = null;
|
mWinBollClientThread = null;
|
||||||
mWinBollClientServiceBean = WinBollClientServiceBean.loadWinBollClientServiceBean(this);
|
mWinBollClientServiceBean = WinBollClientServiceBean.loadWinBollClientServiceBean(this);
|
||||||
@@ -66,7 +68,7 @@ public class WinBollClientService extends Service implements IWinBollClientServi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
ToastUtils.show("onStartCommand");
|
//ToastUtils.show("onStartCommand");
|
||||||
// 由应用 Intent 启动时,应用可以通过下面函数实例化实际服务进程。
|
// 由应用 Intent 启动时,应用可以通过下面函数实例化实际服务进程。
|
||||||
runMainThread();
|
runMainThread();
|
||||||
|
|
||||||
@@ -78,9 +80,9 @@ public class WinBollClientService extends Service implements IWinBollClientServi
|
|||||||
return mIsEnableService ? Service.START_STICKY: super.onStartCommand(intent, flags, startId);
|
return mIsEnableService ? Service.START_STICKY: super.onStartCommand(intent, flags, startId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void runMainThread() {
|
synchronized void runMainThread() {
|
||||||
if (mWinBollClientThread == null) {
|
if (mWinBollClientThread == null) {
|
||||||
ToastUtils.show("runMainThread()");
|
//ToastUtils.show("runMainThread()");
|
||||||
mWinBollClientThread = new WinBollClientThread();
|
mWinBollClientThread = new WinBollClientThread();
|
||||||
mWinBollClientThread.start();
|
mWinBollClientThread.start();
|
||||||
}
|
}
|
||||||
@@ -89,6 +91,7 @@ public class WinBollClientService extends Service implements IWinBollClientServi
|
|||||||
void syncWinBollClientThreadStatus() {
|
void syncWinBollClientThreadStatus() {
|
||||||
mWinBollClientServiceBean = WinBollClientServiceBean.loadWinBollClientServiceBean(this);
|
mWinBollClientServiceBean = WinBollClientServiceBean.loadWinBollClientServiceBean(this);
|
||||||
mIsEnableService = mWinBollClientServiceBean.isEnable();
|
mIsEnableService = mWinBollClientServiceBean.isEnable();
|
||||||
|
LogUtils.d(TAG, String.format("mIsEnableService %s", mIsEnableService));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -123,7 +126,7 @@ public class WinBollClientService extends Service implements IWinBollClientServi
|
|||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
ToastUtils.show("onDestroy");
|
//ToastUtils.show("onDestroy");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -153,34 +156,33 @@ public class WinBollClientService extends Service implements IWinBollClientServi
|
|||||||
class WinBollClientThread extends Thread {
|
class WinBollClientThread extends Thread {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
//ToastUtils.show("WinBollClientThread");
|
|
||||||
super.run();
|
super.run();
|
||||||
|
LogUtils.d(TAG, "run syncWinBollClientThreadStatus");
|
||||||
syncWinBollClientThreadStatus();
|
syncWinBollClientThreadStatus();
|
||||||
if (mIsEnableService) {
|
if (mIsEnableService) {
|
||||||
if (mIsWinBollClientThreadRunning == false) {
|
if (mIsWinBollClientThreadRunning == false) {
|
||||||
// 设置运行状态
|
// 设置运行状态
|
||||||
mIsWinBollClientThreadRunning = true;
|
mIsWinBollClientThreadRunning = true;
|
||||||
|
LogUtils.d(TAG, "WinBollClientThread run()");
|
||||||
//ToastUtils.show("run()");
|
|
||||||
|
|
||||||
// 唤醒守护进程
|
// 唤醒守护进程
|
||||||
//wakeupAndBindAssistant();
|
//wakeupAndBindAssistant();
|
||||||
|
|
||||||
while (mIsEnableService) {
|
while (mIsEnableService) {
|
||||||
// 显示运行状态
|
// 显示运行状态
|
||||||
ToastUtils.show(TAG + " is running.");
|
WinBollServiceStatusView.startConnection();
|
||||||
|
LogUtils.d(TAG, String.format("while mIsEnableService is %s", mIsEnableService));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(2 * 1000);
|
Thread.sleep(10 * 1000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||||
}
|
}
|
||||||
syncWinBollClientThreadStatus();
|
syncWinBollClientThreadStatus();
|
||||||
//ToastUtils.show("syncServiceThreadStatus OK.");
|
|
||||||
//ToastUtils.show("mIsExist : " + Boolean.toString(!mIsEnableService));
|
|
||||||
//break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 服务进程退出, 重置进程运行状态
|
// 服务进程退出, 重置进程运行状态
|
||||||
|
WinBollServiceStatusView.stopConnection();
|
||||||
mIsWinBollClientThreadRunning = false;
|
mIsWinBollClientThreadRunning = false;
|
||||||
mWinBollClientThread = null;
|
mWinBollClientThread = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,106 @@
|
|||||||
|
package cc.winboll.studio.libaes.winboll;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author ZhanGSKen@AliYun.Com
|
||||||
|
* @Date 2025/03/29 15:57:28
|
||||||
|
* @Describe WinBoll 服务器服务情况测试访问进程。
|
||||||
|
*/
|
||||||
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
|
import java.io.IOException;
|
||||||
|
import okhttp3.Call;
|
||||||
|
import okhttp3.Callback;
|
||||||
|
import okhttp3.Credentials;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
|
||||||
|
// 新增自定义回调接口
|
||||||
|
interface TextCallback {
|
||||||
|
void onSuccess(String text);
|
||||||
|
void onFailure(Exception e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WinBollServerConnectionThread extends Thread {
|
||||||
|
|
||||||
|
public static final String TAG = "WinBollClientService";
|
||||||
|
|
||||||
|
private final String url;
|
||||||
|
private final String username;
|
||||||
|
private final String password;
|
||||||
|
private final int connectTimeout;
|
||||||
|
private final int readTimeout;
|
||||||
|
private final int maxRetries;
|
||||||
|
private final TextCallback callback; // 新增回调成员变量
|
||||||
|
|
||||||
|
// 新增带回调的构造函数
|
||||||
|
public WinBollServerConnectionThread(String url, String username, String password, TextCallback callback) {
|
||||||
|
this(url, username, password, 10000, 10000, 5, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改原有构造函数,添加回调参数
|
||||||
|
public WinBollServerConnectionThread(String url, String username, String password,
|
||||||
|
int connectTimeout, int readTimeout, int maxRetries, TextCallback callback) {
|
||||||
|
this.url = url;
|
||||||
|
this.username = username;
|
||||||
|
this.password = password;
|
||||||
|
this.connectTimeout = connectTimeout;
|
||||||
|
this.readTimeout = readTimeout;
|
||||||
|
this.maxRetries = maxRetries;
|
||||||
|
this.callback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
LogUtils.d(TAG, String.format("run() url %s\nusername %s\npassword %s", url, username, password));
|
||||||
|
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")
|
||||||
|
.header("Authorization", credential)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Call call = client.newCall(request);
|
||||||
|
call.enqueue(new Callback() {
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call call, IOException e) {
|
||||||
|
// 优先调用自定义回调
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onFailure(e);
|
||||||
|
} else {
|
||||||
|
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call call, Response response) throws IOException {
|
||||||
|
if (!response.isSuccessful()) {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onFailure(new Exception("Unexpected code " + response));
|
||||||
|
} else {
|
||||||
|
LogUtils.d(TAG, "Unexpected code " + response, Thread.currentThread().getStackTrace());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
String text = response.body().string();
|
||||||
|
// 优先调用自定义回调
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onSuccess(text);
|
||||||
|
} else {
|
||||||
|
LogUtils.d(TAG, text);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onFailure(e);
|
||||||
|
} else {
|
||||||
|
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,9 +18,13 @@ import android.view.View;
|
|||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import cc.winboll.studio.libaes.winboll.WinBollClientService;
|
||||||
|
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
import com.hjq.toast.ToastUtils;
|
|
||||||
import cc.winboll.studio.libapputils.R;
|
import cc.winboll.studio.libapputils.R;
|
||||||
|
import cc.winboll.studio.libapputils.utils.PrefUtils;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
//import okhttp3.Authenticator;
|
//import okhttp3.Authenticator;
|
||||||
//import okhttp3.Credentials;
|
//import okhttp3.Credentials;
|
||||||
//import okhttp3.OkHttpClient;
|
//import okhttp3.OkHttpClient;
|
||||||
@@ -35,9 +39,10 @@ public class WinBollServiceStatusView extends LinearLayout {
|
|||||||
public static final int MSG_CONNECTION_INFO = 0;
|
public static final int MSG_CONNECTION_INFO = 0;
|
||||||
public static final int MSG_UPDATE_CONNECTION_STATUS = 1;
|
public static final int MSG_UPDATE_CONNECTION_STATUS = 1;
|
||||||
|
|
||||||
|
static WinBollServiceStatusView _WinBollServiceStatusView;
|
||||||
Context mContext;
|
Context mContext;
|
||||||
//boolean mIsConnected;
|
//boolean mIsConnected;
|
||||||
ConnectionThread mConnectionThread;
|
volatile ConnectionThread mConnectionThread;
|
||||||
|
|
||||||
String mszServerHost;
|
String mszServerHost;
|
||||||
WinBollClientService mWinBollService;
|
WinBollClientService mWinBollService;
|
||||||
@@ -105,6 +110,8 @@ public class WinBollServiceStatusView extends LinearLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void initView() {
|
void initView() {
|
||||||
|
_WinBollServiceStatusView = this;
|
||||||
|
|
||||||
mImageView = new ImageView(mContext);
|
mImageView = new ImageView(mContext);
|
||||||
setImageViewByConnection(mImageView, false);
|
setImageViewByConnection(mImageView, false);
|
||||||
mConnectionStatus = getConnectionStatus();
|
mConnectionStatus = getConnectionStatus();
|
||||||
@@ -115,56 +122,27 @@ public class WinBollServiceStatusView extends LinearLayout {
|
|||||||
mViewOnClickListener = new View.OnClickListener(){
|
mViewOnClickListener = new View.OnClickListener(){
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
//ToastUtils.show("onClick()");
|
LogUtils.d(TAG, "onClick()");
|
||||||
//ToastUtils.show("mWinBollServerHostConnectionStatus : " + mWinBollServerHostConnectionStatus);
|
|
||||||
//isConnected = !isConnected;
|
|
||||||
if (mConnectionStatus == ConnectionStatus.CONNECTED) {
|
if (mConnectionStatus == ConnectionStatus.CONNECTED) {
|
||||||
ToastUtils.show("Click to stop service.");
|
LogUtils.d(TAG, "Click to stop service.");
|
||||||
WinBollClientServiceBean bean = WinBollClientServiceBean.loadWinBollClientServiceBean(mContext);
|
WinBollClientServiceBean bean = WinBollClientServiceBean.loadWinBollClientServiceBean(mContext);
|
||||||
bean.setIsEnable(false);
|
bean.setIsEnable(false);
|
||||||
WinBollClientServiceBean.saveBean(mContext, bean);
|
WinBollClientServiceBean.saveBean(mContext, bean);
|
||||||
Intent intent = new Intent(mContext, WinBollClientService.class);
|
Intent intent = new Intent(mContext, WinBollClientService.class);
|
||||||
mContext.stopService(intent);
|
mContext.stopService(intent);
|
||||||
|
//stopConnectionThread();
|
||||||
|
mTextView.setText("");
|
||||||
|
setImageViewByConnection(mImageView, false);
|
||||||
mConnectionStatus = ConnectionStatus.DISCONNECTED;
|
mConnectionStatus = ConnectionStatus.DISCONNECTED;
|
||||||
//
|
|
||||||
/*//ToastUtils.show("CONNECTED");
|
|
||||||
setConnectionStatusView(false);
|
|
||||||
mWinBollServerHostConnectionStatusViewHandler.postMessageText("");
|
|
||||||
if (mConnectionThread != null) {
|
|
||||||
mConnectionThread.mIsExist = true;
|
|
||||||
mConnectionThread = null;
|
|
||||||
mWinBollServerHostConnectionStatus = WinBollServerHostConnectionStatus.DISCONNECTED;
|
|
||||||
ToastUtils.show("WinBoll Server Disconnected.");
|
|
||||||
}*/
|
|
||||||
} else if (mConnectionStatus == ConnectionStatus.DISCONNECTED) {
|
} else if (mConnectionStatus == ConnectionStatus.DISCONNECTED) {
|
||||||
ToastUtils.show("Click to start service.");
|
LogUtils.d(TAG, "Click to start service.");
|
||||||
WinBollClientServiceBean bean = WinBollClientServiceBean.loadWinBollClientServiceBean(mContext);
|
WinBollClientServiceBean bean = WinBollClientServiceBean.loadWinBollClientServiceBean(mContext);
|
||||||
bean.setIsEnable(true);
|
bean.setIsEnable(true);
|
||||||
WinBollClientServiceBean.saveBean(mContext, bean);
|
WinBollClientServiceBean.saveBean(mContext, bean);
|
||||||
Intent intent = new Intent(mContext, WinBollClientService.class);
|
Intent intent = new Intent(mContext, WinBollClientService.class);
|
||||||
mContext.startService(intent);
|
mContext.startService(intent);
|
||||||
mConnectionStatus = ConnectionStatus.CONNECTED;
|
//startConnectionThread();
|
||||||
ToastUtils.show("startService");
|
|
||||||
/*//ToastUtils.show("DISCONNECTED");
|
|
||||||
setConnectionStatusView(true);
|
|
||||||
|
|
||||||
if (mConnectionThread == null) {
|
|
||||||
ToastUtils.show("mConnectionThread == null");
|
|
||||||
mConnectionThread = new ConnectionThread();
|
|
||||||
mWinBollServerHostConnectionStatus = WinBollServerHostConnectionStatus.START_CONNECT;
|
|
||||||
mConnectionThread.start();
|
|
||||||
}*/
|
|
||||||
} else {
|
|
||||||
ToastUtils.show("Other Click condition.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (isConnected) {
|
|
||||||
mWebView.loadUrl("https://dev.winboll.cc");
|
|
||||||
} else {
|
|
||||||
mWebView.stopLoading();
|
|
||||||
}*/
|
|
||||||
//ToastUtils.show(mDevelopHostConnectionStatus);
|
|
||||||
//LogUtils.d(TAG, "mDevelopHostConnectionStatus : " + mWinBollServerHostConnectionStatus);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
setOnClickListener(mViewOnClickListener);
|
setOnClickListener(mViewOnClickListener);
|
||||||
@@ -210,56 +188,167 @@ public class WinBollServiceStatusView extends LinearLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void requestWithBasicAuth(WinBollServiceViewHandler textViewHandler, String targetUrl, final String username, final String password) {
|
TextCallback apiTextCallback = new TextCallback() {
|
||||||
// 用户名和密码,替换为实际的认证信息
|
@Override
|
||||||
//String username = "your_username";
|
public void onSuccess(String text) {
|
||||||
//String password = "your_password";
|
// 处理成功响应
|
||||||
|
LogUtils.d(TAG, text);
|
||||||
|
}
|
||||||
|
|
||||||
// OkHttpClient client = new OkHttpClient.Builder()
|
@Override
|
||||||
// .authenticator(new Authenticator() {
|
public void onFailure(Exception e) {
|
||||||
// @Override
|
// 处理失败情况
|
||||||
// public Request authenticate(Route route, Response response) throws IOException {
|
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||||
// String credential = Credentials.basic(username, password);
|
}
|
||||||
// return response.request().newBuilder()
|
};
|
||||||
// .header("Authorization", credential)
|
|
||||||
// .build();
|
TextCallback cipTextCallback = new TextCallback() {
|
||||||
// }
|
@Override
|
||||||
// })
|
public void onSuccess(String text) {
|
||||||
// .build();
|
// 处理成功响应
|
||||||
//
|
LogUtils.d(TAG, text);
|
||||||
// Request request = new Request.Builder()
|
LogUtils.d(TAG, "Develop Host Connection IP is : " + text);
|
||||||
// .url(targetUrl) // 替换为实际要请求的网页地址
|
mConnectionStatus = ConnectionStatus.CONNECTED;
|
||||||
// .build();
|
// 获取当前时间
|
||||||
//
|
LocalDateTime now = LocalDateTime.now();
|
||||||
// try {
|
// 定义时间格式
|
||||||
// Response response = client.newCall(request).execute();
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
|
||||||
// if (response.isSuccessful()) {
|
// 按照指定格式格式化时间并输出
|
||||||
// //System.out.println(response.body().string());
|
String formattedDateTime = now.format(formatter);
|
||||||
// //ToastUtils.show("Develop Host Connection IP is : " + response.body().string());
|
String msg = "ClientIP<" + formattedDateTime + ">: " + text;
|
||||||
// // 获取当前时间
|
mWinBollServiceViewHandler.postMessageText(msg);
|
||||||
// LocalDateTime now = LocalDateTime.now();
|
mWinBollServiceViewHandler.postMessageConnectionStatus(true);
|
||||||
//
|
|
||||||
// // 定义时间格式
|
}
|
||||||
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
|
|
||||||
// // 按照指定格式格式化时间并输出
|
@Override
|
||||||
// String formattedDateTime = now.format(formatter);
|
public void onFailure(Exception e) {
|
||||||
// //System.out.println(formattedDateTime);
|
// 处理失败情况
|
||||||
// textViewHandler.postMessageText("ClientIP<" + formattedDateTime + ">: " + response.body().string());
|
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||||
// textViewHandler.postMessageConnectionStatus(true);
|
// 处理网络请求失败
|
||||||
// } else {
|
setImageViewByConnection(mImageView, false);
|
||||||
// String sz = "请求失败,状态码: " + response.code();
|
mWinBollServiceViewHandler.postMessageText(e.getMessage());
|
||||||
// setImageViewByConnection(mImageView, false);
|
mWinBollServiceViewHandler.postMessageConnectionStatus(false);
|
||||||
// textViewHandler.postMessageText(sz);
|
}
|
||||||
// textViewHandler.postMessageConnectionStatus(false);
|
};
|
||||||
// LogUtils.d(TAG, sz);
|
|
||||||
// }
|
public void requestAPIWithBasicAuth() {
|
||||||
// } catch (IOException e) {
|
String targetUrl = "https://" + (GlobalApplication.isDebuging() ?"dev.winboll": "winboll") + ".cc/api/"; // 替换为实际测试的URL
|
||||||
// textViewHandler.postMessageText(e.getMessage());
|
requestWithBasicAuth(targetUrl, apiTextCallback);
|
||||||
// textViewHandler.postMessageConnectionStatus(false);
|
|
||||||
// LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void requestCIPWithBasicAuth() {
|
||||||
|
String targetUrl = mszServerHost + "/cip/?simple=true";
|
||||||
|
requestWithBasicAuth(targetUrl, cipTextCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void requestWithBasicAuth(String targetUrl, TextCallback callback) {
|
||||||
|
String username = "";
|
||||||
|
String password = "";
|
||||||
|
if (GlobalApplication.isDebuging()) {
|
||||||
|
username = PrefUtils.getString(mContext, "metDevUserName", "");
|
||||||
|
password = PrefUtils.getString(mContext, "metDevUserPassword", "");
|
||||||
|
} else {
|
||||||
|
username = "WinBoll";
|
||||||
|
password = "WinBollPowerByZhanGSKen";
|
||||||
|
}
|
||||||
|
LogUtils.d(TAG, String.format("Connection Start. targetUrl %s", targetUrl));
|
||||||
|
WinBollServerConnectionThread thread = new WinBollServerConnectionThread(
|
||||||
|
targetUrl,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
cipTextCallback
|
||||||
|
);
|
||||||
|
thread.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*void requestWithBasicAuth(final WinBollServiceViewHandler textViewHandler, String targetUrl, final String username, final String password) {
|
||||||
|
// 用户名和密码,替换为实际的认证信息
|
||||||
|
//String username = "your_username";
|
||||||
|
//String password = "your_password";
|
||||||
|
LogUtils.d(TAG, "requestWithBasicAuth(...)");
|
||||||
|
LogUtils.d(TAG, String.format("targetUrl %s", targetUrl));
|
||||||
|
|
||||||
|
// 构建包含认证信息的请求
|
||||||
|
String credential = Credentials.basic(username, password);
|
||||||
|
LogUtils.d(TAG, String.format("credential %s", credential));
|
||||||
|
|
||||||
|
OkHttpClient client = new OkHttpClient();
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(targetUrl)
|
||||||
|
.header("Accept", "text/plain") // 设置正确的Content-Type头
|
||||||
|
.header("Authorization", credential)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Call call = client.newCall(request);
|
||||||
|
call.enqueue(new Callback() {
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call call, IOException e) {
|
||||||
|
// 处理网络请求失败
|
||||||
|
setImageViewByConnection(mImageView, false);
|
||||||
|
textViewHandler.postMessageText(e.getMessage());
|
||||||
|
textViewHandler.postMessageConnectionStatus(false);
|
||||||
|
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||||
|
//String sz = "请求失败,状态码: " + response.code();
|
||||||
|
//setImageViewByConnection(mImageView, false);
|
||||||
|
//LogUtils.d(TAG, sz);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call call, Response response) throws IOException {
|
||||||
|
if (!response.isSuccessful()) {
|
||||||
|
setImageViewByConnection(mImageView, false);
|
||||||
|
textViewHandler.postMessageText("Unexpected code " + response);
|
||||||
|
textViewHandler.postMessageConnectionStatus(false);
|
||||||
|
LogUtils.d(TAG, "Unexpected code " + response, Thread.currentThread().getStackTrace());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 读取响应体作为字符串,注意这里可能需要解码
|
||||||
|
String text = response.body().string();
|
||||||
|
LogUtils.d(TAG, "Develop Host Connection IP is : " + text);
|
||||||
|
mConnectionStatus = ConnectionStatus.CONNECTED;
|
||||||
|
// 获取当前时间
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
// 定义时间格式
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
|
||||||
|
// 按照指定格式格式化时间并输出
|
||||||
|
String formattedDateTime = now.format(formatter);
|
||||||
|
textViewHandler.postMessageText("ClientIP<" + formattedDateTime + ">: " + text);
|
||||||
|
textViewHandler.postMessageConnectionStatus(true);
|
||||||
|
|
||||||
|
//org.jsoup.nodes.Document doc = org.jsoup.Jsoup.parse(text);
|
||||||
|
//LogUtils.d(TAG, doc.text());
|
||||||
|
|
||||||
|
// 使用id选择器找到具有特定id的元素
|
||||||
|
//org.jsoup.nodes.Element elementWithId = doc.select("#LastRelease").first(); // 获取第一个匹配的元素
|
||||||
|
|
||||||
|
// 提取并打印元素的文本内容
|
||||||
|
//mszNewestAppPackageName = elementWithId.text();
|
||||||
|
//ToastUtils.delayedShow(text + "\n" + mszNewestAppPackageName, 5000);
|
||||||
|
|
||||||
|
//mHandler.sendMessage(mHandler.obtainMessage(MSG_APPUPDATE_CHECKED));
|
||||||
|
//System.out.println(response.body().string());
|
||||||
|
// mConnectionStatus = ConnectionStatus.CONNECTED;
|
||||||
|
// // 获取当前时间
|
||||||
|
// LocalDateTime now = LocalDateTime.now();
|
||||||
|
//
|
||||||
|
// // 定义时间格式
|
||||||
|
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
|
||||||
|
// // 按照指定格式格式化时间并输出
|
||||||
|
// String formattedDateTime = now.format(formatter);
|
||||||
|
// //System.out.println(formattedDateTime);
|
||||||
|
// textViewHandler.postMessageText("ClientIP<" + formattedDateTime + ">: " + response.body().string());
|
||||||
|
// textViewHandler.postMessageConnectionStatus(true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}*/
|
||||||
|
|
||||||
class WinBollServiceViewHandler extends Handler {
|
class WinBollServiceViewHandler extends Handler {
|
||||||
WinBollServiceStatusView mDevelopHostConnectionStatusView;
|
WinBollServiceStatusView mDevelopHostConnectionStatusView;
|
||||||
|
|
||||||
@@ -293,6 +382,48 @@ public class WinBollServiceStatusView extends LinearLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void startConnection() {
|
||||||
|
if (_WinBollServiceStatusView != null) {
|
||||||
|
_WinBollServiceStatusView.startConnectionThread();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void stopConnection() {
|
||||||
|
if (_WinBollServiceStatusView != null) {
|
||||||
|
_WinBollServiceStatusView.stopConnectionThread();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void startConnectionThread() {
|
||||||
|
if (mConnectionStatus == ConnectionStatus.DISCONNECTED) {
|
||||||
|
mConnectionStatus = ConnectionStatus.START_CONNECT;
|
||||||
|
LogUtils.d(TAG, "startConnectionThread");
|
||||||
|
if (mConnectionThread != null) {
|
||||||
|
LogUtils.d(TAG, "mConnectionThread != null");
|
||||||
|
mConnectionThread.mIsExist = true;
|
||||||
|
}
|
||||||
|
mConnectionThread = new ConnectionThread();
|
||||||
|
mConnectionThread.start();
|
||||||
|
} else if (mConnectionStatus == ConnectionStatus.CONNECTING) {
|
||||||
|
//LogUtils.d(TAG, "mConnectionStatus == ConnectionStatus.CONNECTING");
|
||||||
|
} else if (mConnectionStatus == ConnectionStatus.CONNECTED) {
|
||||||
|
//LogUtils.d(TAG, "mConnectionStatus == ConnectionStatus.CONNECTED");
|
||||||
|
} else {
|
||||||
|
LogUtils.d(TAG, String.format("Unknow mConnectionStatus %s, can not start ConnectionThread.", mConnectionStatus));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void stopConnectionThread() {
|
||||||
|
LogUtils.d(TAG, "stopConnectionThread");
|
||||||
|
if (mConnectionThread != null) {
|
||||||
|
LogUtils.d(TAG, "mConnectionThread != null");
|
||||||
|
mConnectionThread.mIsExist = true;
|
||||||
|
mConnectionThread = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ConnectionThread extends Thread {
|
class ConnectionThread extends Thread {
|
||||||
|
|
||||||
public volatile boolean mIsExist;
|
public volatile boolean mIsExist;
|
||||||
@@ -312,13 +443,14 @@ public class WinBollServiceStatusView extends LinearLayout {
|
|||||||
while (mIsExist == false) {
|
while (mIsExist == false) {
|
||||||
if (mConnectionStatus == ConnectionStatus.START_CONNECT) {
|
if (mConnectionStatus == ConnectionStatus.START_CONNECT) {
|
||||||
mConnectionStatus = ConnectionStatus.CONNECTING;
|
mConnectionStatus = ConnectionStatus.CONNECTING;
|
||||||
ToastUtils.show("WinBoll Server Connection Start.");
|
//requestAPIWithBasicAuth();
|
||||||
//LogUtils.d(TAG, "Develop Host Connection Start.");
|
requestCIPWithBasicAuth();
|
||||||
String targetUrl = "https://" + mszServerHost + "/cip/?simple=true"; // 这里替换成你实际要访问的网址
|
|
||||||
requestWithBasicAuth(mWinBollServiceViewHandler, targetUrl, _mUserName, _mPassword);
|
|
||||||
} else if (mConnectionStatus == ConnectionStatus.CONNECTED
|
} else if (mConnectionStatus == ConnectionStatus.CONNECTED
|
||||||
&& mConnectionStatus == ConnectionStatus.DISCONNECTED) {
|
|| mConnectionStatus == ConnectionStatus.DISCONNECTED) {
|
||||||
ToastUtils.show("mWinBollServerHostConnectionStatus " + mConnectionStatus);
|
//ToastUtils.show("mWinBollServerHostConnectionStatus " + mConnectionStatus);
|
||||||
|
LogUtils.d(TAG, String.format("mConnectionStatus done %s", mConnectionStatus));
|
||||||
|
} else {
|
||||||
|
LogUtils.d(TAG, String.format("mConnectionStatus unknow %s", mConnectionStatus));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -9,6 +9,9 @@
|
|||||||
android:title="TestAppCrash"/>
|
android:title="TestAppCrash"/>
|
||||||
</menu>
|
</menu>
|
||||||
</item>
|
</item>
|
||||||
|
<item
|
||||||
|
android:id="@+id/item_log"
|
||||||
|
android:title="Log"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/item_about"
|
android:id="@+id/item_about"
|
||||||
android:title="About"/>
|
android:title="About"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user