Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
修复 首页统计显示问题;修复 超时重试失效问题;补全 保护地列表;
Browse files Browse the repository at this point in the history
  • Loading branch information
TKaxv-7S committed Jun 20, 2024
1 parent 1662775 commit bc30fff
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 70 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
//noinspection ExpiredTargetSdkVersion
targetSdk 31
versionCode 80
versionName "1.2.5-test19-TK"
versionName "1.2.5-test20-TK"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -654,32 +654,32 @@ public static String requestString(RpcEntity rpcEntity) {
return rpcBridge.requestString(rpcEntity, 3, -1);
}

public static String requestString(RpcEntity rpcEntity, int tryCount, int retryInterval) {
return rpcBridge.requestString(rpcEntity, tryCount, retryInterval);
public static String requestString(RpcEntity rpcEntity, int tryCount, int sleepTime) {
return rpcBridge.requestString(rpcEntity, tryCount, sleepTime);
}

public static String requestString(String method, String data) {
return rpcBridge.requestString(method, data);
}

public static String requestString(String method, String data, int tryCount, int retryInterval) {
return rpcBridge.requestString(method, data, tryCount, retryInterval);
public static String requestString(String method, String data, int tryCount, int sleepTime) {
return rpcBridge.requestString(method, data, tryCount, sleepTime);
}

public static RpcEntity requestObject(RpcEntity rpcEntity) {
return rpcBridge.requestObject(rpcEntity, 3, -1);
}

public static RpcEntity requestObject(RpcEntity rpcEntity, int tryCount, int retryInterval) {
return rpcBridge.requestObject(rpcEntity, tryCount, retryInterval);
public static RpcEntity requestObject(RpcEntity rpcEntity, int tryCount, int sleepTime) {
return rpcBridge.requestObject(rpcEntity, tryCount, sleepTime);
}

public static RpcEntity requestObject(String method, String data) {
return rpcBridge.requestObject(method, data);
}

public static RpcEntity requestObject(String method, String data, int tryCount, int retryInterval) {
return rpcBridge.requestObject(method, data, tryCount, retryInterval);
public static RpcEntity requestObject(String method, String data, int tryCount, int sleepTime) {
return rpcBridge.requestObject(method, data, tryCount, sleepTime);
}

public static void reLoginByBroadcast() {
Expand Down
52 changes: 34 additions & 18 deletions app/src/main/java/tkaxv7s/xposed/sesame/rpc/NewRpcBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,16 @@ public void unload() {
loader = null;
}

public String requestString(RpcEntity rpcEntity, int tryCount, int retryInterval) {
RpcEntity resRpcEntity = requestObject(rpcEntity, tryCount, retryInterval);
public String requestString(RpcEntity rpcEntity, int tryCount, int sleepTime) {
RpcEntity resRpcEntity = requestObject(rpcEntity, tryCount, sleepTime);
if (resRpcEntity != null) {
return resRpcEntity.getResponseString();
}
return null;
}

@Override
public RpcEntity requestObject(RpcEntity rpcEntity, int tryCount, int retryInterval) {
public RpcEntity requestObject(RpcEntity rpcEntity, int tryCount, int sleepTime) {
if (ApplicationHook.isOffline()) {
return null;
}
Expand Down Expand Up @@ -165,31 +165,31 @@ public Object invoke(Object proxy, Method method, Object[] args) {
Log.i(TAG, "new rpc response [" + method + "] get err:");
Log.printStackTrace(TAG, e);
}
if (retryInterval < 0) {
if (sleepTime < 0) {
try {
Thread.sleep(600 + RandomUtil.delay());
} catch (InterruptedException e) {
Log.printStackTrace(e);
}
} else {
} else if (sleepTime > 0) {
try {
Thread.sleep(retryInterval);
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
Log.printStackTrace(e);
}
}
} catch (Throwable t) {
Log.i(TAG, "new rpc request [" + method + "] err:");
Log.printStackTrace(TAG, t);
if (retryInterval < 0) {
if (sleepTime < 0) {
try {
Thread.sleep(600 + RandomUtil.delay());
} catch (InterruptedException e) {
Log.printStackTrace(e);
}
} else {
} else if (sleepTime > 0) {
try {
Thread.sleep(retryInterval);
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
Log.printStackTrace(e);
}
Expand All @@ -199,7 +199,7 @@ public Object invoke(Object proxy, Method method, Object[] args) {
return null;
}

public RpcEntity newAsyncRequest(RpcEntity rpcEntity, int tryCount) {
public RpcEntity newAsyncRequest(RpcEntity rpcEntity, int tryCount, int sleepTime) {
if (ApplicationHook.isOffline()) {
return null;
}
Expand Down Expand Up @@ -272,18 +272,34 @@ public Object invoke(Object proxy, Method method, Object[] args) {
Log.i(TAG, "new rpc response [" + method + "] get err:");
Log.printStackTrace(TAG, e);
}
try {
Thread.sleep(600 + RandomUtil.delay());
} catch (InterruptedException e) {
Log.printStackTrace(e);
if (sleepTime < 0) {
try {
Thread.sleep(600 + RandomUtil.delay());
} catch (InterruptedException e) {
Log.printStackTrace(e);
}
} else if (sleepTime > 0) {
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
Log.printStackTrace(e);
}
}
} catch (Throwable t) {
Log.i(TAG, "new rpc request [" + method + "] err:");
Log.printStackTrace(TAG, t);
try {
Thread.sleep(600 + RandomUtil.delay());
} catch (InterruptedException e) {
Log.printStackTrace(e);
if (sleepTime < 0) {
try {
Thread.sleep(600 + RandomUtil.delay());
} catch (InterruptedException e) {
Log.printStackTrace(e);
}
} else if (sleepTime > 0) {
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
Log.printStackTrace(e);
}
}
}
} while (count < tryCount);
Expand Down
18 changes: 9 additions & 9 deletions app/src/main/java/tkaxv7s/xposed/sesame/rpc/OldRpcBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ public void unload() {
loader = null;
}

public String requestString(RpcEntity rpcEntity, int tryCount, int retryInterval) {
RpcEntity resRpcEntity = requestObject(rpcEntity, tryCount, retryInterval);
public String requestString(RpcEntity rpcEntity, int tryCount, int sleepTime) {
RpcEntity resRpcEntity = requestObject(rpcEntity, tryCount, sleepTime);
if (resRpcEntity != null) {
return resRpcEntity.getResponseString();
}
return null;
}

@Override
public RpcEntity requestObject(RpcEntity rpcEntity, int tryCount, int retryInterval) {
public RpcEntity requestObject(RpcEntity rpcEntity, int tryCount, int sleepTime) {
if (ApplicationHook.isOffline()) {
return null;
}
Expand Down Expand Up @@ -119,15 +119,15 @@ public RpcEntity requestObject(RpcEntity rpcEntity, int tryCount, int retryInter
NotificationUtil.setContentText("触发异常,等待至" + DateFormat.getDateTimeInstance().format(waitTime));
Log.record("触发异常,等待至" + DateFormat.getDateTimeInstance().format(waitTime));
}
if (retryInterval < 0) {
if (sleepTime < 0) {
try {
Thread.sleep(600 + RandomUtil.delay());
} catch (InterruptedException e) {
Log.printStackTrace(e);
}
} else {
} else if (sleepTime > 0) {
try {
Thread.sleep(retryInterval);
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
Log.printStackTrace(e);
}
Expand All @@ -141,15 +141,15 @@ public RpcEntity requestObject(RpcEntity rpcEntity, int tryCount, int retryInter
} catch (JSONException e) {
Log.printStackTrace(e);
}
if (retryInterval < 0) {
if (sleepTime < 0) {
try {
Thread.sleep(600 + RandomUtil.delay());
} catch (InterruptedException e) {
Log.printStackTrace(e);
}
} else {
} else if (sleepTime > 0) {
try {
Thread.sleep(retryInterval);
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
Log.printStackTrace(e);
}
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/tkaxv7s/xposed/sesame/rpc/RpcBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public interface RpcBridge {

void unload();

String requestString(RpcEntity rpcEntity, int tryCount, int retryInterval);
String requestString(RpcEntity rpcEntity, int tryCount, int sleepTime);

default String requestString(RpcEntity rpcEntity) {
return requestString(rpcEntity, 3, -1);
Expand All @@ -18,11 +18,11 @@ default String requestString(String method, String data) {
return requestString(method, data, 3, -1);
}

default String requestString(String method, String data, int tryCount, int retryInterval) {
return requestString(new RpcEntity(method, data), tryCount, retryInterval);
default String requestString(String method, String data, int tryCount, int sleepTime) {
return requestString(new RpcEntity(method, data), tryCount, sleepTime);
}

RpcEntity requestObject(RpcEntity rpcEntity, int tryCount, int retryInterval);
RpcEntity requestObject(RpcEntity rpcEntity, int tryCount, int sleepTime);

default RpcEntity requestObject(RpcEntity rpcEntity) {
return requestObject(rpcEntity, 3, -1);
Expand All @@ -32,8 +32,8 @@ default RpcEntity requestObject(String method, String data) {
return requestObject(method, data, 3, -1);
}

default RpcEntity requestObject(String method, String data, int tryCount, int retryInterval) {
return requestObject(new RpcEntity(method, data), tryCount, retryInterval);
default RpcEntity requestObject(String method, String data, int tryCount, int sleepTime) {
return requestObject(new RpcEntity(method, data), tryCount, sleepTime);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public class TaskOrder {
, AntCooperate.class
, AntFarm.class
, Reserve.class
, AntOrchard.class
, AncientTree.class
, AntSports.class
, AntMember.class
, AntOcean.class
, AntOrchard.class
, AntStall.class
, GreenFinance.class
, KBMember.class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ public Runnable init() {
collectIntervalInt = Math.max(Integer.parseInt(collectIntervalStr), 500);
} catch (Exception ignored) {
collectIntervalMin = 500;
collectInterval.setValue(collectIntervalMin);
}
useCollectIntervalInt = true;
}
Expand Down Expand Up @@ -740,9 +741,11 @@ private void collectUserEnergy(String userId, long bubbleId, String bizNo) {
}
RpcEntity rpcEntity;
String doBizNo = bizNo;
int thisTryCount = 0;
do {
thisTryCount++;
rpcEntity = AntForestRpcCall.getCollectEnergyRpcEntity(null, userId, bubbleId);
ApplicationHook.requestObject(rpcEntity, tryCountInt, retryIntervalInt);
ApplicationHook.requestObject(rpcEntity, 0, retryIntervalInt);
if (rpcEntity.getHasError()) {
break;
}
Expand Down Expand Up @@ -787,7 +790,7 @@ private void collectUserEnergy(String userId, long bubbleId, String bizNo) {
}
NotificationUtil.setContentText(Log.getFormatTime() + " 收:" + totalCollected + ",帮:" + totalHelpCollected);
return;
} while (true);
} while (thisTryCount < tryCountInt);
String errorCode = (String) XposedHelpers.callMethod(rpcEntity.getResponseObject(), "getString", "error");
if ("1004".equals(errorCode)) {
if (ConfigV2.INSTANCE.getWaitWhenException() > 0) {
Expand Down Expand Up @@ -825,9 +828,11 @@ private void collectUserBatchEnergy(String userId, final List<Long> bubbleIdList
}
RpcEntity rpcEntity;
List<Long> doBubbleIdList = bubbleIdList;
int thisTryCount = 0;
do {
thisTryCount++;
rpcEntity = AntForestRpcCall.getCollectBatchEnergyRpcEntity(userId, doBubbleIdList);
ApplicationHook.requestObject(rpcEntity, tryCountInt, retryIntervalInt);
ApplicationHook.requestObject(rpcEntity, 0, retryIntervalInt);
if (rpcEntity.getHasError()) {
break;
}
Expand Down Expand Up @@ -863,7 +868,7 @@ private void collectUserBatchEnergy(String userId, final List<Long> bubbleIdList
}
NotificationUtil.setContentText(Log.getFormatTime() + " 收:" + totalCollected + ",帮:" + totalHelpCollected);
return;
} while (true);
} while (thisTryCount < tryCountInt);
String errorCode = (String) XposedHelpers.callMethod(rpcEntity.getResponseObject(), "getString", "error");
if ("1004".equals(errorCode)) {
if (ConfigV2.INSTANCE.getWaitWhenException() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import tkaxv7s.xposed.sesame.data.modelFieldExt.BooleanModelField;
import tkaxv7s.xposed.sesame.data.modelFieldExt.SelectModelField;
import tkaxv7s.xposed.sesame.entity.AlipayBeach;
import tkaxv7s.xposed.sesame.entity.AlipayReserve;
import tkaxv7s.xposed.sesame.entity.KVNode;
import tkaxv7s.xposed.sesame.task.common.ModelTask;
import tkaxv7s.xposed.sesame.task.common.TaskCommon;
Expand All @@ -31,13 +32,15 @@ public String setName() {
}

public static BooleanModelField enableReserve;
public static SelectModelField reserveList;
public static BooleanModelField beach;
public static SelectModelField beachList;

@Override
public ModelFields setFields() {
ModelFields modelFields = new ModelFields();
modelFields.addField(enableReserve = new BooleanModelField("enableReserve", "开启保护地", false));
modelFields.addField(reserveList = new SelectModelField("reserveList", "保护地列表", new KVNode<>(new LinkedHashMap<>(), true), AlipayReserve.getList()));
modelFields.addField(beach = new BooleanModelField("beach", "保护海洋", false));
modelFields.addField(beachList = new SelectModelField("beachList", "保护海洋列表", new KVNode<>(new LinkedHashMap<>(), true), AlipayBeach.getList()));
return modelFields;
Expand Down Expand Up @@ -101,7 +104,7 @@ private static void animalReserve() {
String itemName = jo.getString("itemName");
int energy = jo.getInt("energy");
ReserveIdMap.putIdMap(projectId, itemName + "(" + energy + "g)");
Map<String, Integer> map = beachList.getValue().getKey();
Map<String, Integer> map = reserveList.getValue().getKey();
for (Map.Entry<String, Integer> entry : map.entrySet()) {
if (Objects.equals(entry.getKey(), projectId)) {
Integer count = entry.getValue();
Expand Down
8 changes: 0 additions & 8 deletions app/src/main/java/tkaxv7s/xposed/sesame/ui/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,6 @@ protected void onResume() {
}
}
try {
if (Statistics.INSTANCE.resetByCalendar(Calendar.getInstance())) {
try {
sendBroadcast(new Intent("com.eg.android.AlipayGphone.sesame.execute"));
} catch (Throwable th) {
Log.i("view sendBroadcast execute err:");
Log.printStackTrace(th);
}
}
Statistics.load();
tvStatistics.setText(Statistics.getText());
} catch (Exception e) {
Expand Down
Loading

0 comments on commit bc30fff

Please sign in to comment.