version:1.5.2
fix: update:增加通话白名单,整点报时选项
This commit is contained in:
@@ -49,6 +49,9 @@ public class WeAccessibilityService extends AccessibilityService {
|
||||
private static final String CALL_TEXT = "语音通话";
|
||||
|
||||
private static final String RECEIVE_DESCRIPTION = "接听";
|
||||
private static final String HANDS_FREE_TEXT = "扬声器已关";
|
||||
private static final String DIALER_HANDS_FREE_TEXT = "免提";
|
||||
private static final String DIALER_HANDS_FREE_CLOSE_TEXT = "免提,已关闭";
|
||||
|
||||
public static final int TYPE_VOICE = 0;
|
||||
public static final int TYPE_VIDEO = 1;
|
||||
@@ -138,6 +141,10 @@ public class WeAccessibilityService extends AccessibilityService {
|
||||
Log.e(TAG, "_onAccessibilityEvent: " + mCurrentStep);
|
||||
switch (mCurrentStep) {
|
||||
case WAITING:
|
||||
if (!TextUtils.isEmpty(event.getPackageName()) && "com.android.dialer".equals(event.getPackageName())) {
|
||||
Log.e(TAG, "_onAccessibilityEvent: to dialer hands free");
|
||||
mCurrentStep = Step.DIALER_HANDS_FREE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (!TextUtils.isEmpty(event.getClassName())) {
|
||||
@@ -158,12 +165,22 @@ public class WeAccessibilityService extends AccessibilityService {
|
||||
return;
|
||||
}
|
||||
if (stepAnswer(Property.DESCRIPTION, RECEIVE_DESCRIPTION)) {
|
||||
mCurrentStep = Step.WAITING;
|
||||
mCurrentStep = Step.WECHAT_HANDS_FREE;
|
||||
Toast.makeText(this, "已自动接听视频/语音", Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
// clickAnswer();
|
||||
}
|
||||
break;
|
||||
case WECHAT_HANDS_FREE:
|
||||
handsFree(Property.DESCRIPTION, HANDS_FREE_TEXT);
|
||||
break;
|
||||
case DIALER_HANDS_FREE:
|
||||
if (findHandsFree(Property.DESCRIPTION, DIALER_HANDS_FREE_CLOSE_TEXT)) {
|
||||
dialerHandsFree(Property.TEXT, DIALER_HANDS_FREE_TEXT);
|
||||
} else {
|
||||
mCurrentStep = Step.WAITING;
|
||||
}
|
||||
break;
|
||||
case CLICK_HOME://主页能找到直接点击进去更多
|
||||
stepHome(Property.TEXT, mName);
|
||||
break;
|
||||
@@ -524,6 +541,51 @@ public class WeAccessibilityService extends AccessibilityService {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean dialerHandsFree(Property type, String text) {
|
||||
AccessibilityNodeInfo node = findNode(getWindows(), type, text);
|
||||
if (node != null) {
|
||||
Rect rect = new Rect();
|
||||
node.getBoundsInScreen(rect);
|
||||
Log.e(TAG, "dialerHandsFree: rect = " + rect);
|
||||
clickNode(node);
|
||||
Log.e(TAG, "dialerHandsFree: mCurrentStep: " + mCurrentStep + " done");
|
||||
mCurrentStep = Step.WAITING;
|
||||
Log.e(TAG, "dialerHandsFree: next: " + mCurrentStep);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean findHandsFree(Property type, String text) {
|
||||
AccessibilityNodeInfo node = findNode(getWindows(), type, text);
|
||||
if (node != null) {
|
||||
Log.e(TAG, "findHandsFree: true");
|
||||
return true;
|
||||
} else {
|
||||
Log.e(TAG, "findHandsFree: false");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean handsFree(Property type, String text) {
|
||||
AccessibilityNodeInfo node = findNode(getWindows(), type, text);
|
||||
if (node != null) {
|
||||
Point point = getPointtByNode(node);
|
||||
Log.e(TAG, "handsFree: " + point);
|
||||
clickByPoint(point.x, point.y - 50);
|
||||
clickByPoint(point.x, point.y);
|
||||
// clickNode(node);
|
||||
Log.e(TAG, "handsFree: mCurrentStep " + mCurrentStep + " done");
|
||||
mCurrentStep = Step.WAITING;
|
||||
Log.e(TAG, "handsFree: next " + mCurrentStep);
|
||||
return true;
|
||||
} else {
|
||||
Log.e(TAG, "handsFree: not found");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//根据节点信息可获得对应的x,y坐标
|
||||
static Point getPointtByNode(AccessibilityNodeInfo node) {
|
||||
if (node == null) {
|
||||
@@ -609,6 +671,8 @@ public class WeAccessibilityService extends AccessibilityService {
|
||||
|
||||
private enum Step {
|
||||
WAITING,
|
||||
WECHAT_HANDS_FREE,
|
||||
DIALER_HANDS_FREE,
|
||||
CLICK_HOME,
|
||||
CLICK_QUICK_WECHAT_CALL,
|
||||
CLICK_TARGET,
|
||||
|
||||
Reference in New Issue
Block a user