Compare commits

...

5 Commits

Author SHA1 Message Date
ZhanGSKen
53eced104e <contacts>APK 1.0.8 release Publish. 2025-03-04 01:25:27 +08:00
ZhanGSKen
b45119b487 添加调试信息 2025-03-04 01:24:16 +08:00
ZhanGSKen
fdddde33b5 <contacts>APK 1.0.7 release Publish. 2025-03-03 20:51:18 +08:00
ZhanGSKen
f263733609 UI界面优化 2025-03-03 20:42:00 +08:00
ZhanGSKen
51a1cf1e26 重构为Java7语法 2025-03-03 20:23:00 +08:00
4 changed files with 43 additions and 21 deletions

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Mon Mar 03 17:39:16 HKT 2025
stageCount=7
#Tue Mar 04 01:25:27 HKT 2025
stageCount=9
libraryProject=
baseVersion=1.0
publishVersion=1.0.6
publishVersion=1.0.8
buildCount=0
baseBetaVersion=1.0.7
baseBetaVersion=1.0.9

View File

@@ -48,24 +48,29 @@ public class TomCat {
.url(zipUrl)
.build();
try (Response response = client.newCall(request).execute()) {
try {
Response response = client.newCall(request).execute();
if (!response.isSuccessful()) {
throw new IOException("Unexpected code " + response);
}
// 下载 ZIP 文件到临时位置
File tempZipFile = File.createTempFile("temp", ".zip");
try (InputStream inputStream = response.body().byteStream();
FileOutputStream outputStream = new FileOutputStream(tempZipFile)) {
try {
InputStream inputStream = response.body().byteStream();
FileOutputStream outputStream = new FileOutputStream(tempZipFile);
byte[] buffer = new byte[1024];
int length;
while ((length = inputStream.read(buffer)) > 0) {
outputStream.write(buffer, 0, length);
}
} catch (Exception e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
// 解压 ZIP 文件到指定文件夹
try (ZipInputStream zipInputStream = new ZipInputStream(Files.newInputStream(tempZipFile.toPath()))) {
try {
ZipInputStream zipInputStream = new ZipInputStream(Files.newInputStream(tempZipFile.toPath()));
ZipEntry zipEntry;
while ((zipEntry = zipInputStream.getNextEntry()) != null) {
Path targetFilePath = Paths.get(destinationFolder, zipEntry.getName());
@@ -83,11 +88,15 @@ public class TomCat {
}
zipInputStream.closeEntry();
}
} catch (Exception e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
// 删除临时 ZIP 文件
tempZipFile.delete();
LogUtils.d(TAG, "已更新 BoBullToon 数据");
} catch (Exception e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
}
@@ -97,12 +106,12 @@ public class TomCat {
try {
// 删除旧文件
File fOldFolder = new File(destinationFolder);
if(fOldFolder.exists()) {
if (fOldFolder.exists()) {
deleteFolderRecursive(fOldFolder);
fOldFolder.mkdirs();
LogUtils.d(TAG, "已清空 BoBullToon 数据");
}
// 更新新文件
downloadAndExtractZip(zipUrl, destinationFolder);
LogUtils.d(TAG, "ZIP 文件下载并解压成功。");
@@ -112,14 +121,14 @@ public class TomCat {
}
return false;
}
// 递归删除文件夹及其内容的方法
public static void deleteFolderRecursive(File file) {
// 判断是否为文件夹
if (file.isDirectory()) {
// 列出文件夹中的所有文件和子文件夹
File[] files = file.listFiles();
if (files!= null) {
if (files != null) {
// 遍历并递归删除每个文件和子文件夹
for (File f : files) {
deleteFolderRecursive(f);

View File

@@ -43,6 +43,7 @@ public class Rules {
}
public void reload() {
LogUtils.d(TAG, "reload()");
loadRules();
loadDun();
setDunResumTimer();
@@ -59,10 +60,12 @@ public class Rules {
@Override
public void run() {
if (mSettingsModel.getDunCurrentCount() != mSettingsModel.getDunTotalCount()) {
LogUtils.d(TAG, String.format("当前防御值为%d最大防御值为%d", mSettingsModel.getDunCurrentCount(), mSettingsModel.getDunTotalCount()));
int newDunCount = mSettingsModel.getDunCurrentCount() + mSettingsModel.getDunResumeCount();
// 保证盾值在[0DunTotalCount]之内其他值一律重置为 DunTotalCount。
// 设置盾值在[0DunTotalCount]之内其他值一律重置为 DunTotalCount。
newDunCount = (newDunCount > mSettingsModel.getDunTotalCount()) ?mSettingsModel.getDunTotalCount(): newDunCount;
mSettingsModel.setDunCurrentCount(newDunCount);
LogUtils.d(TAG, String.format("设置防御值为%d", newDunCount));
saveDun();
SettingsActivity.notifyDunInfoUpdate();
}
@@ -76,6 +79,7 @@ public class Rules {
}
public void saveRules() {
LogUtils.d(TAG, String.format("saveRules()"));
PhoneConnectRuleModel.saveBeanList(mContext, _PhoneConnectRuleModelList, PhoneConnectRuleModel.class);
}
@@ -88,14 +92,14 @@ public class Rules {
}
public void saveDun() {
LogUtils.d(TAG, String.format("saveDun() isEnableDun : %s", mSettingsModel.isEnableDun()));
LogUtils.d(TAG, String.format("saveDun()"));
SettingsModel.saveBean(mContext, mSettingsModel);
}
public boolean isAllowed(String phoneNumber) {
// 没有启用云盾,默认允许接通任何电话
if (!mSettingsModel.isEnableDun()) {
LogUtils.d(TAG, "没有启用云盾,默认允许接通任何电话");
LogUtils.d(TAG, String.format("没有启用云盾默认允许接通任何电话。isAllowed(...) return true"));
return true;
}
@@ -110,13 +114,15 @@ public class Rules {
LogUtils.d(TAG, "盾层为1以下防御解除");
isDefend = true;
isConnect = true;
LogUtils.d(TAG, String.format("isDefend == %s\nisConnect == %s", isDefend, isConnect));
}
// 正则运算预防针
if (!isDefend && !RegexPPiUtils.isPPiOK(phoneNumber)) {
LogUtils.d(TAG, "RegexPPiUtils.isPPiOK return false.");
LogUtils.d(TAG, "正则运算预防针生效。");
isDefend = true;
isConnect = false;
LogUtils.d(TAG, String.format("isDefend == %s\nisConnect == %s", isDefend, isConnect));
}
// 检验拨不通号码群
@@ -124,6 +130,7 @@ public class Rules {
LogUtils.d(TAG, String.format("PhoneNumber %s\n Is In BoBullToon", phoneNumber));
isDefend = true;
isConnect = false;
LogUtils.d(TAG, String.format("isDefend == %s\nisConnect == %s", isDefend, isConnect));
}
// 正则匹配规则名单校验
@@ -132,9 +139,10 @@ public class Rules {
if (_PhoneConnectRuleModelList.get(i).isEnable()) {
String regex = _PhoneConnectRuleModelList.get(i).getRuleText();
if (Pattern.matches(regex, phoneNumber)) {
LogUtils.d(TAG, String.format("phoneNumber :%s \nisAllowConnection %s By Rule : %s", phoneNumber, _PhoneConnectRuleModelList.get(i).isAllowConnection(), _PhoneConnectRuleModelList.get(i)));
LogUtils.d(TAG, String.format("Phone Number [%s] is matched by rule : %s", phoneNumber, _PhoneConnectRuleModelList.get(i)));
isDefend = true;
isConnect = _PhoneConnectRuleModelList.get(i).isAllowConnection();
LogUtils.d(TAG, String.format("isDefend == %s\nisConnect == %s", isDefend, isConnect));
break;
}
}
@@ -144,6 +152,7 @@ public class Rules {
if (isConnect) {
// 如果防御结果为连接,则恢复防御盾牌最大值层数
mSettingsModel.setDunCurrentCount(mSettingsModel.getDunTotalCount());
LogUtils.d(TAG, String.format("防御结果为连接,恢复防御盾牌最大值层数 %d", mSettingsModel.getDunTotalCount()));
saveDun();
SettingsActivity.notifyDunInfoUpdate();
} else if (isDefend) {
@@ -152,12 +161,15 @@ public class Rules {
// 每校验一次规则云盾防御层数减1
// 当云盾防御层数为0时再次进行以下程序段则恢复满值防御。
int newDunCount = mSettingsModel.getDunCurrentCount() - 1;
LogUtils.d(TAG, String.format("新的防御层数预计为 %d", newDunCount));
// 保证盾值在[0DunTotalCount]之内其他值一律重置为 DunTotalCount。
if (newDunCount < 0 || newDunCount > mSettingsModel.getDunTotalCount()) {
mSettingsModel.setDunCurrentCount(mSettingsModel.getDunTotalCount());
LogUtils.d(TAG, String.format("盾值不在[0%d]区间,恢复防御最大值%d", mSettingsModel.getDunTotalCount(), mSettingsModel.getDunTotalCount()));
} else {
mSettingsModel.setDunCurrentCount(newDunCount);
LogUtils.d(TAG, String.format("设置防御层数为 %d", newDunCount));
}
saveDun();
@@ -165,6 +177,7 @@ public class Rules {
}
// 返回校验结果
LogUtils.d(TAG, String.format("返回校验结果 isConnect == %s", isConnect));
return isConnect;
}

View File

@@ -62,7 +62,7 @@
<Switch
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="是否启用云盾"
android:text="是否启用云盾防御"
android:layout_margin="5dp"
android:id="@+id/sw_IsEnableDun"
android:onClick="onSW_IsEnableDun"/>
@@ -78,7 +78,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="初始防御层数量:"/>
android:text="初始防御层的叠加数量:"/>
<EditText
android:layout_width="0dp"
@@ -99,7 +99,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="恢复防御时间间隔(秒钟)"/>
android:text="防御层每次恢复的时间间隔(秒钟)"/>
<EditText
android:layout_width="0dp"
@@ -120,7 +120,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="每小时回复防御数量:"/>
android:text="防御层每次恢复的叠加数量:"/>
<EditText
android:layout_width="0dp"