Skip to content

Commit

Permalink
实装了新村赶人,增加了新的刷步方式
Browse files Browse the repository at this point in the history
  • Loading branch information
constanline committed Sep 1, 2023
1 parent 1cceba0 commit b82e712
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 88 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
minSdk 21
//noinspection ExpiredTargetSdkVersion
targetSdk 29
versionCode 59
versionName "1.1.7"
versionCode 60
versionName "1.1.8"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ private static class FarmTool {
bizKeyList.add("HIRE_LOW_ACTIVITY");
bizKeyList.add("HEART_DONATION_ADVANCED_FOOD_V2");
bizKeyList.add("YEB_PURCHASE");
bizKeyList.add("ONLINE_PAY");
bizKeyList.add("DIANTAOHUANDUAN");
}

Expand Down
15 changes: 4 additions & 11 deletions app/src/main/java/pansong291/xposed/quickenergy/AntForest.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ private static void checkCanCollectEnergy(JSONObject jo) throws JSONException {
&& jo.getLong("canCollectLaterTime") - System.currentTimeMillis() < Config.checkInterval());
String userId = jo.getString("userId");
if (Config.collectEnergy() && optBoolean && !userId.equals(selfId)) {
canCollectEnergy(userId, true);
canCollectEnergy(userId);
}
if (Config.helpFriendCollect() && jo.getBoolean("canProtectBubble") && restTimes > 0) {
restTimes = protectBubble(userId);
Expand Down Expand Up @@ -493,7 +493,7 @@ private static int getEnergyId(int waterEnergy) {
return 39;
}

private static void canCollectEnergy(String userId, boolean laterCollect) {
private static void canCollectEnergy(String userId) {
if (RuntimeInfo.getInstance().getLong(RuntimeInfo.RuntimeInfoKey.ForestPauseTime) > System
.currentTimeMillis()) {
Log.recordLog("异常等待中,暂不执行检测!", "");
Expand Down Expand Up @@ -545,7 +545,7 @@ private static void canCollectEnergy(String userId, boolean laterCollect) {
break;

case WAITING:
if (!laterCollect || Config.getDontCollectList().contains(userId))
if (!true || Config.getDontCollectList().contains(userId))
break;
long produceTime = bubble.getLong("produceTime");
if (produceTime - serverTime < Config.checkInterval())
Expand Down Expand Up @@ -1565,14 +1565,7 @@ public StepTask(ClassLoader cl) {

@Override
public void run() {
int step = Config.syncStepCount();
if (step == 0) {
return;
}
step = RandomUtils.nextInt(step, step + 2000);
if (step > 100000) {
step = 100000;
}
int step = Config.tmpStepCount();
try {
boolean booleanValue = (Boolean) XposedHelpers.callMethod(
XposedHelpers.callStaticMethod(
Expand Down
126 changes: 59 additions & 67 deletions app/src/main/java/pansong291/xposed/quickenergy/AntStall.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ private static void home() {
Log.farm("蚂蚁新村⛪请先开启蚂蚁新村");
return;
}
settle(jo);

JSONObject seatsMap = jo.getJSONObject("seatsMap");
settle(seatsMap);

sendBack(seatsMap);

// shopList();

Expand All @@ -74,9 +78,60 @@ private static void home() {
}
}

private static void settle(JSONObject stallHome) {
private static void sendBack(String billNo, String seatId, String shopId, String shopUserId) {
String s = AntStallRpcCall.shopSendBackPre(billNo, seatId, shopId, shopUserId);
try {
JSONObject jo = new JSONObject(s);
if ("SUCCESS".equals(jo.getString("resultCode"))) {
JSONObject astPreviewShopSettleVO = jo.getJSONObject("astPreviewShopSettleVO");
JSONObject income = astPreviewShopSettleVO.getJSONObject("income");
int amount = (int) income.getDouble("amount");
s = AntStallRpcCall.shopSendBack(seatId);
jo = new JSONObject(s);
if ("SUCCESS".equals(jo.getString("resultCode"))) {
Log.farm("蚂蚁新村⛪请走[" + FriendIdMap.getNameById(shopUserId) + "]的小摊" + (amount > 0 ? "获得金币" + amount : ""));
} else {
Log.recordLog("sendBack err:", s);
}
} else {
Log.recordLog("sendBackPre err:", s);
}
} catch (Throwable t) {
Log.i(TAG, "sendBack err:");
Log.printStackTrace(TAG, t);
}
}

private static void sendBack(JSONObject seatsMap) {
try {
for (int i = 1; i <= 2; i++) {
JSONObject seat = seatsMap.getJSONObject("GUEST_0" + i);
String rentLastUser = seat.getString("rentLastUser");
//白名单直接跳过
if (Config.stallWhiteList().contains(rentLastUser)) {
continue;
}
String rentLastBill = seat.getString("rentLastBill");
String seatId = seat.getString("seatId");
String rentLastShop = seat.getString("rentLastShop");
//黑名单直接赶走
if (Config.stallBlackList().contains(rentLastUser)) {
sendBack(rentLastBill, seatId, rentLastShop, rentLastUser);
continue;
}
long bizStartTime = seat.getLong("bizStartTime");
if ((System.currentTimeMillis() - bizStartTime) / 1000 / 60 > Config.stallAllowOpenTime()) {
sendBack(rentLastBill, seatId, rentLastShop, rentLastUser);
}
}
} catch (Throwable t) {
Log.i(TAG, "sendBack err:");
Log.printStackTrace(TAG, t);
}
}

private static void settle(JSONObject seatsMap) {
try {
JSONObject seatsMap = stallHome.getJSONObject("seatsMap");
JSONObject seat = seatsMap.getJSONObject("MASTER");
if (seat.has("coinsMap")) {
JSONObject coinsMap = seat.getJSONObject("coinsMap");
Expand Down Expand Up @@ -189,6 +244,7 @@ private static void openShop(String seatId, String userId, Queue<String> shopIds
try {
JSONObject jo = new JSONObject(s);
if ("SUCCESS".equals(jo.getString("resultCode"))) {
Log.farm("蚂蚁新村⛪在[" + FriendIdMap.getNameById(userId) + "]家摆摊");
shopIds.poll();
}
} catch (Throwable t) {
Expand Down Expand Up @@ -228,55 +284,6 @@ private static void friendHomeOpen(List<Seat> seats, Queue<String> shopIds) {
}
}

private static void shopList() {
String s = AntStallRpcCall.shopList();
try {
JSONObject jo = new JSONObject(s);
if ("SUCCESS".equals(jo.getString("resultCode"))) {
JSONArray astUserShopList = jo.getJSONArray("astUserShopList");
int openShop = 0;
for (int i = 0; i < astUserShopList.length(); i++) {
JSONObject shop = astUserShopList.getJSONObject(i);
if ("OPEN".equals(shop.getString("status"))) {
openShop++;
}
}
if (Config.stallAutoClose() && openShop > 0) {
shopOneKeyClose();
openShop = 0;
}
if (Config.stallAutoOpen() && openShop < 4) {
shopOneKeyOpen();
}
} else {
Log.recordLog("shopList err:", s);
}
} catch (Throwable t) {
Log.i(TAG, "shopList err:");
Log.printStackTrace(TAG, t);
}

}

private static void shopOneKeyClose() {
String s = AntStallRpcCall.preOneKeyClose();
try {
JSONObject jo = new JSONObject(s);
if ("SUCCESS".equals(jo.getString("resultCode"))) {
s = AntStallRpcCall.oneKeyClose();
jo = new JSONObject(s);
if ("SUCCESS".equals(jo.getString("resultCode"))) {
Log.farm("蚂蚁新村⛪[一键收摊]");
}
} else {
Log.recordLog("shopOneKeyClose err:", s);
}
} catch (Throwable t) {
Log.i(TAG, "shopOneKeyClose err:");
Log.printStackTrace(TAG, t);
}
}

private static void shopClose(String shopId, String billNo, String userId) {
String s = AntStallRpcCall.preShopClose(shopId, billNo);
try {
Expand All @@ -299,21 +306,6 @@ private static void shopClose(String shopId, String billNo, String userId) {
}
}

private static void shopOneKeyOpen() {
String s = AntStallRpcCall.oneKeyOpen();
try {
JSONObject jo = new JSONObject(s);
if ("SUCCESS".equals(jo.getString("resultCode"))) {
Log.farm("蚂蚁新村⛪[一键摆摊]");
} else {
Log.recordLog("shopOneKeyOpen err:", s);
}
} catch (Throwable t) {
Log.i(TAG, "shopOneKeyOpen err:");
Log.printStackTrace(TAG, t);
}
}

private static void taskList() {
String s = AntStallRpcCall.taskList();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,19 @@ public static String achieveBeShareP2P(String shareId) {
+ "\",\"source\":\"ANTSTALL\",\"systemType\":\"android\",\"version\":\""
+ VERSION + "\"}]");
}

public static String shopSendBackPre(String billNo, String seatId, String shopId, String shopUserId) {
return RpcUtil.request("com.alipay.antstall.friend.shop.sendback.pre",
"[{\"billNo\":\"" + billNo + "\",\"seatId\":\"" + seatId + "\",\"shopId\":\"" + shopId
+ "\",\"shopUserId\":\"" + shopUserId
+ "\",\"source\":\"ch_appcollect__chsub_my-recentlyUsed\",\"systemType\":\"android\",\"version\":\""
+ VERSION + "\"}]");
}

public static String shopSendBack(String seatId) {
return RpcUtil.request("com.alipay.antstall.friend.shop.sendback",
"[{\"seatId\":\"" + seatId
+ "\",\"source\":\"ch_appcollect__chsub_my-recentlyUsed\",\"systemType\":\"android\",\"version\":\""
+ VERSION + "\"}]");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import pansong291.xposed.quickenergy.ui.MainActivity;
import pansong291.xposed.quickenergy.util.*;

import java.util.Calendar;
import java.util.Map;

public class XposedHook implements IXposedHookLoadPackage {
Expand Down Expand Up @@ -62,7 +63,8 @@ protected void beforeHookedMethod(MethodHookParam param) {
isHooked = true;
Log.i(TAG, lpparam.packageName);
classLoader = lpparam.classLoader;
hookRpcCall(lpparam.classLoader);
hookRpcCall();
hookStep();
hookService(lpparam.classLoader);
PluginUtils.invoke(XposedHook.class, PluginUtils.PluginAction.INIT);
}
Expand Down Expand Up @@ -118,6 +120,7 @@ public void run() {
};
}
try {
AntForestToast.show(service.getString(R.string.app_name) + "加载成功");
handler.removeCallbacks(runnable);
AntForest.stop();
AntForestNotification.stop(service, false);
Expand Down Expand Up @@ -221,10 +224,10 @@ protected void afterHookedMethod(MethodHookParam param) {
}
}

private void hookRpcCall(ClassLoader loader) {
private void hookRpcCall() {
try {
Class<?> clazz = loader.loadClass(ClassMember.com_alipay_mobile_nebulaappproxy_api_rpc_H5AppRpcUpdate);
Class<?> H5PageClazz = loader.loadClass(ClassMember.com_alipay_mobile_h5container_api_H5Page);
Class<?> clazz = classLoader.loadClass(ClassMember.com_alipay_mobile_nebulaappproxy_api_rpc_H5AppRpcUpdate);
Class<?> H5PageClazz = classLoader.loadClass(ClassMember.com_alipay_mobile_h5container_api_H5Page);
XposedHelpers.findAndHookMethod(
clazz, ClassMember.matchVersion, H5PageClazz, Map.class, String.class,
XC_MethodReplacement.returnConstant(false));
Expand All @@ -235,6 +238,28 @@ private void hookRpcCall(ClassLoader loader) {
}
}

private void hookStep() {
try {
XposedHelpers.findAndHookMethod("com.alibaba.health.pedometer.core.datasource.PedometerAgent", classLoader,
"readDailyStep", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) {
int originStep = (Integer) param.getResult();
int step = Config.tmpStepCount();
if (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) < 6 || originStep >= step) {
return;
}
param.setResult(step);

}
});
} catch (Throwable t) {
Log.i(TAG, "hookStep err:");
Log.printStackTrace(TAG, t);
}

}

public static void restartHook(Context context, boolean force) {
try {
Intent intent;
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/pansong291/xposed/quickenergy/util/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,21 @@ public static int syncStepCount() {
return getConfig().syncStepCount;
}

private static int tmpStepCount = -1;
public static int tmpStepCount() {
if (tmpStepCount >= 0) {
return tmpStepCount;
}
tmpStepCount = Config.syncStepCount();
if (tmpStepCount > 0) {
tmpStepCount = RandomUtils.nextInt(tmpStepCount, tmpStepCount + 2000);
if (tmpStepCount > 100000) {
tmpStepCount = 100000;
}
}
return tmpStepCount;
}

public static void setKbSginIn(boolean b) {
getConfig().kbSignIn = b;
hasChanged = true;
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@
<string name="visit_friend_list">送麦子名单</string>
<string name="stall_open_type">摊位类型(打开:摆摊列表/关闭:不摆列表)</string>
<string name="stall_open_list">摊位列表</string>
<string name="stall_white_list">不请走列表(未实装)</string>
<string name="stall_allow_open_time">允许他人摆摊时长(未实装)</string>
<string name="stall_white_list">不请走列表</string>
<string name="stall_allow_open_time">允许他人摆摊时长</string>
<string name="stall_self_open_time">自己收摊时长</string>
<string name="stall_black_list">禁摆摊列表(未实装)</string>
<string name="stall_black_list">禁摆摊列表</string>
<string name="chicken_diary">小鸡日记</string>
<string name="stall_donate">新村自动捐赠</string>
<string name="collect_gift_box">领取礼盒</string>
Expand Down

0 comments on commit b82e712

Please sign in to comment.