Skip to content

Commit

Permalink
unpack
Browse files Browse the repository at this point in the history
  • Loading branch information
shijian committed Jan 25, 2018
1 parent f1ae8c9 commit bea1e4d
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 53 deletions.
61 changes: 22 additions & 39 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<afterSyncTasks>
Expand All @@ -23,7 +22,7 @@
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<exclude-output />
Expand All @@ -47,46 +46,39 @@
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-compat/25.1.0/jars" />
Expand All @@ -96,22 +88,14 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-media-compat/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.tencent.bugly/crashreport_upgrade/1.2.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.tencent.bugly/nativecrashreport/3.1.2/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.tencent.bugly/crashreport_upgrade/1.3.4/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.tencent.bugly/nativecrashreport/3.3.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-resources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard-rules" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
Expand All @@ -121,19 +105,18 @@
</content>
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-compat-25.1.0" level="project" />
<orderEntry type="library" exported="" name="support-fragment-25.1.0" level="project" />
<orderEntry type="library" exported="" name="animated-vector-drawable-25.1.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-25.1.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-25.1.0" level="project" />
<orderEntry type="library" exported="" name="nativecrashreport-3.1.2" level="project" />
<orderEntry type="library" exported="" name="crashreport_upgrade-1.2.2.0" level="project" />
<orderEntry type="library" exported="" name="support-core-ui-25.1.0" level="project" />
<orderEntry type="library" exported="" name="support-media-compat-25.1.0" level="project" />
<orderEntry type="library" exported="" name="support-vector-drawable-25.1.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-25.1.0" level="project" />
<orderEntry type="library" exported="" name="support-core-utils-25.1.0" level="project" />
<orderEntry type="library" exported="" name="android-android-25" level="project" />
<orderEntry type="library" exported="" name="com.android.support:support-compat-25.1.0" level="project" />
<orderEntry type="library" exported="" name="com.android.support:support-media-compat-25.1.0" level="project" />
<orderEntry type="library" exported="" name="com.tencent.bugly:crashreport_upgrade-1.3.4" level="project" />
<orderEntry type="library" exported="" name="com.android.support:support-core-utils-25.1.0" level="project" />
<orderEntry type="library" exported="" name="com.android.support:animated-vector-drawable-25.1.0" level="project" />
<orderEntry type="library" exported="" name="com.android.support:support-annotations:25.1.0@jar" level="project" />
<orderEntry type="library" exported="" name="com.android.support:appcompat-v7-25.1.0" level="project" />
<orderEntry type="library" exported="" name="com.android.support:support-v4-25.1.0" level="project" />
<orderEntry type="library" exported="" name="com.android.support:support-vector-drawable-25.1.0" level="project" />
<orderEntry type="library" exported="" name="com.android.support:support-core-ui-25.1.0" level="project" />
<orderEntry type="library" exported="" name="com.android.support:support-fragment-25.1.0" level="project" />
<orderEntry type="library" exported="" name="com.tencent.bugly:nativecrashreport-3.3.1" level="project" />
<orderEntry type="library" exported="" name="org.apache.http.legacy-android-25" level="project" />
</component>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,21 @@
import android.content.ComponentName;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Path;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Parcelable;
import android.graphics.Path;
import android.preference.PreferenceManager;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.util.DisplayMetrics;
import xyz.monkeytong.hongbao.utils.HongbaoSignature;
import xyz.monkeytong.hongbao.utils.PowerUtil;

import java.util.List;
import java.util.Random;

import xyz.monkeytong.hongbao.utils.HongbaoSignature;
import xyz.monkeytong.hongbao.utils.PowerUtil;

public class HongbaoService extends AccessibilityService implements SharedPreferences.OnSharedPreferenceChangeListener {
private static final String WECHAT_DETAILS_EN = "Details";
Expand Down Expand Up @@ -55,15 +57,18 @@ public void onAccessibilityEvent(AccessibilityEvent event) {
if (sharedPreferences == null) return;

setCurrentActivityName(event);
Log.i("tone", "onAccessibilityEvent:检测到.. ");

/* 检测通知消息 */
if (!mMutex) {
Log.i("tone", "onAccessibilityEvent:检测到-》通知 ");
if (sharedPreferences.getBoolean("pref_watch_notification", false) && watchNotifications(event)) return;
if (sharedPreferences.getBoolean("pref_watch_list", false) && watchList(event)) return;
mListMutex = false;
}

if (!mChatMutex) {
Log.i("tone", "onAccessibilityEvent:检测到-》聊天 ");
mChatMutex = true;
if (sharedPreferences.getBoolean("pref_watch_chat", false)) watchChat(event);
mChatMutex = false;
Expand All @@ -79,18 +84,26 @@ private void watchChat(AccessibilityEvent event) {
mUnpackNode = null;

checkNodeInfo(event.getEventType());

/* 如果已经接收到红包并且还没有戳开 */
Log.i("tone", "watchChat: 查找控件1-" + mLuckyMoneyReceived + mLuckyMoneyPicked + mReceiveNode);
//Log.i("tone", "watchChat: 查找控件");
if (mLuckyMoneyReceived && !mLuckyMoneyPicked && (mReceiveNode != null)) {
mMutex = true;

Log.i("tone", "watchChat: 准备戳开红包");
mReceiveNode.getParent().performAction(AccessibilityNodeInfo.ACTION_CLICK);
mLuckyMoneyReceived = false;
mLuckyMoneyPicked = true;
}
Log.i("tone", "watchChat: 查找控件2-" + mUnpackCount + mUnpackNode);
/* 如果戳开但还未领取 */
if (mUnpackCount == 1 && (mUnpackNode != null)) {
int delayFlag = sharedPreferences.getInt("pref_open_delay", 0) * 1000;
//int delayFlag = sharedPreferences.getInt("pref_open_delay", 0) * 1000;
int max = 500;
int min = 10;
//int delayFlag = (int)(Math.random() * 1000);
Random random = new Random();
int delayFlag = random.nextInt(max) % (max - min + 1) + min;
Log.i("tone", "watchChat: 准备领取红包-" + delayFlag);
//Log.d("delay", "delay:" + delayFlag);
new android.os.Handler().postDelayed(
new Runnable() {
public void run() {
Expand All @@ -112,28 +125,30 @@ private void openPacket() {
float dpi = metrics.density;
if (android.os.Build.VERSION.SDK_INT <= 23) {
mUnpackNode.performAction(AccessibilityNodeInfo.ACTION_CLICK);
Log.i("tone", "watchChat: <=23");
} else {
if (android.os.Build.VERSION.SDK_INT > 23) {

Log.i("tone", "watchChat: >23");
Path path = new Path();
if (640 == dpi) {
path.moveTo(720, 1575);
} else {
path.moveTo(540, 1060);
}
GestureDescription.Builder builder = new GestureDescription.Builder();
GestureDescription gestureDescription = builder.addStroke(new GestureDescription.StrokeDescription(path, 450, 50)).build();
GestureDescription gestureDescription = builder.addStroke(new GestureDescription.StrokeDescription
(path, 450, 50)).build();
dispatchGesture(gestureDescription, new GestureResultCallback() {
@Override
public void onCompleted(GestureDescription gestureDescription) {
Log.d("test", "onCompleted");
Log.i("tone", "onCompleted");
mMutex = false;
super.onCompleted(gestureDescription);
}

@Override
public void onCancelled(GestureDescription gestureDescription) {
Log.d("test", "onCancelled");
Log.i("tone", "onCancelled");
mMutex = false;
super.onCancelled(gestureDescription);
}
Expand All @@ -159,6 +174,8 @@ private void setCurrentActivityName(AccessibilityEvent event) {
} catch (PackageManager.NameNotFoundException e) {
currentActivityName = WECHAT_LUCKMONEY_GENERAL_ACTIVITY;
}

Log.i("tone", "setCurrentActivityName: " + currentActivityName);
}

private boolean watchList(AccessibilityEvent event) {
Expand Down Expand Up @@ -246,7 +263,8 @@ private void checkNodeInfo(int eventType) {

/* 聊天会话窗口,遍历节点匹配“领取红包”和"查看红包" */
AccessibilityNodeInfo node1 = (sharedPreferences.getBoolean("pref_watch_self", false)) ?
this.getTheLastNode(WECHAT_VIEW_OTHERS_CH, WECHAT_VIEW_SELF_CH) : this.getTheLastNode(WECHAT_VIEW_OTHERS_CH);
this.getTheLastNode(WECHAT_VIEW_OTHERS_CH, WECHAT_VIEW_SELF_CH) : this.getTheLastNode
(WECHAT_VIEW_OTHERS_CH);
if (node1 != null &&
(currentActivityName.contains(WECHAT_LUCKMONEY_CHATTING_ACTIVITY)
|| currentActivityName.contains(WECHAT_LUCKMONEY_GENERAL_ACTIVITY))) {
Expand All @@ -261,7 +279,9 @@ private void checkNodeInfo(int eventType) {

/* 戳开红包,红包还没抢完,遍历节点匹配“拆红包” */
AccessibilityNodeInfo node2 = findOpenButton(this.rootNodeInfo);
if (node2 != null && "android.widget.Button".equals(node2.getClassName()) && currentActivityName.contains(WECHAT_LUCKMONEY_RECEIVE_ACTIVITY)) {

if (node2 != null && "android.widget.Button".equals(node2.getClassName()) && currentActivityName.contains
(WECHAT_LUCKMONEY_RECEIVE_ACTIVITY)) {
mUnpackNode = node2;
mUnpackCount += 1;
return;
Expand Down

0 comments on commit bea1e4d

Please sign in to comment.