diff --git a/app/src/main/java/pansong291/xposed/quickenergy/AntForest.java b/app/src/main/java/pansong291/xposed/quickenergy/AntForest.java index b2e76dc4a..681a154a6 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/AntForest.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/AntForest.java @@ -1443,6 +1443,28 @@ private static void queryUserPatrol() { try { JSONObject jo = new JSONObject(AntForestRpcCall.queryUserPatrol()); if ("SUCCESS".equals(jo.getString("resultCode"))) { + JSONObject resData = new JSONObject(AntForestRpcCall.queryMyPatrolRecord()); + if (resData.optBoolean("canSwitch")) { + JSONArray records = resData.getJSONArray("records"); + for (int i = 0; i < records.length(); i++) { + JSONObject record = records.getJSONObject(i); + JSONObject userPatrol = record.getJSONObject("userPatrol"); + if (userPatrol.getInt("unreachedNodeCount") > 0) { + if ("silent".equals(userPatrol.getString("mode"))) { + JSONObject patrolConfig = record.getJSONObject("patrolConfig"); + String patrolId = patrolConfig.getString("patrolId"); + resData = new JSONObject(AntForestRpcCall.switchUserPatrol(patrolId)); + if ("SUCCESS".equals(resData.getString("resultCode"))) { + Log.forest("巡逻⚖️-切换地图至" + patrolId); + } + queryUserPatrol(); + return; + } + break; + } + } + } + JSONObject userPatrol = jo.getJSONObject("userPatrol"); int currentNode = userPatrol.getInt("currentNode"); String currentStatus = userPatrol.getString("currentStatus"); diff --git a/app/src/main/java/pansong291/xposed/quickenergy/hook/AntForestRpcCall.java b/app/src/main/java/pansong291/xposed/quickenergy/hook/AntForestRpcCall.java index 94b6973c4..ad44ec2d1 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/hook/AntForestRpcCall.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/hook/AntForestRpcCall.java @@ -245,6 +245,14 @@ public static String queryUserPatrol() { return RpcUtil.request("alipay.antforest.forest.h5.queryUserPatrol", "[{\"source\":\"ant_forest\",\"timezoneId\":\"Asia/Shanghai\"}]"); } + public static String queryMyPatrolRecord() { + return RpcUtil.request("alipay.antforest.forest.h5.queryMyPatrolRecord", + "[{\"source\":\"ant_forest\",\"timezoneId\":\"Asia/Shanghai\"}]"); + } + public static String switchUserPatrol(String targetPatrolId) { + return RpcUtil.request("alipay.antforest.forest.h5.switchUserPatrol", + "[{\"source\":\"ant_forest\",\"targetPatrolId\":" + targetPatrolId + ",\"timezoneId\":\"Asia/Shanghai\"}]"); + } public static String patrolGo(int nodeIndex, int patrolId) { return RpcUtil.request("alipay.antforest.forest.h5.patrolGo",