686 lines
35 KiB
Java
686 lines
35 KiB
Java
package com.fisherbone.fuzhu.step;
|
|
|
|
import android.accessibilityservice.AccessibilityService;
|
|
import android.graphics.Rect;
|
|
import android.os.Build;
|
|
import android.os.Message;
|
|
import android.util.Log;
|
|
import android.view.accessibility.AccessibilityNodeInfo;
|
|
|
|
import androidx.annotation.RequiresApi;
|
|
|
|
import com.fisherbone.fuzhu.ChangLiang;
|
|
import com.fisherbone.fuzhu.abllib.AblService;
|
|
import com.fisherbone.fuzhu.abllib.AblStepHandler;
|
|
import com.fisherbone.fuzhu.abllib.AblSteps;
|
|
import com.fisherbone.fuzhu.abllib.BaseAblStep;
|
|
import com.fisherbone.fuzhu.abllib.utils.AblViewUtil;
|
|
import com.fisherbone.fuzhu.db.CommentBeanData;
|
|
import com.fisherbone.fuzhu.entity.FensiBean;
|
|
import com.fisherbone.fuzhu.utils.ProfileSpUtils;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Random;
|
|
|
|
/**
|
|
* Time: 2021/5/21
|
|
* Author: jianbo
|
|
* Description:
|
|
*/
|
|
class NoticeBase extends BaseAblStep {
|
|
public String SHEBEITIPE_VILUEONE="0";
|
|
public String SHEBEITIPE_VILUETHREE="3";
|
|
public String SHEBEITIPE_VILUETWO="2";
|
|
public String IFCONTIAN="x";
|
|
private static final String TAG = "Conmon";
|
|
private String conment;
|
|
@Override
|
|
public void onStep(int step, Message msg) {
|
|
|
|
}
|
|
|
|
/**
|
|
* 获取一条随机字符串
|
|
* @param length
|
|
* @return
|
|
*/
|
|
public String getRandomString(int length) { //length表示生成字符串的长度
|
|
String base = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
Random random = new Random();
|
|
StringBuffer sb = new StringBuffer();
|
|
for (int i = 0; i < length; i++) {
|
|
int number = random.nextInt(base.length());
|
|
sb.append(base.charAt(number));
|
|
}
|
|
Log.e("提交的字符串s", "getRandomString: " + sb.toString());
|
|
return sb.toString();
|
|
}
|
|
|
|
public boolean allowed() {
|
|
boolean ifOpen = false;
|
|
AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow();
|
|
for (int i = 0; i < root.getChildCount(); i++) {
|
|
AccessibilityNodeInfo child = root.getChild(i);
|
|
Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription());
|
|
if ("android.widget.TextView".equals(child.getClassName())) {
|
|
if(child.getText()!=null) {
|
|
if (child.getText().toString().contains("正在尝试开启") || child.getText().toString().contains("是否允许")) {
|
|
int childCount = root.getChildCount();
|
|
AccessibilityNodeInfo child1 = root.getChild(childCount - 1);
|
|
clickNodeInfo(child1, "点击了允许");
|
|
}
|
|
}
|
|
ifOpen = true;
|
|
}
|
|
}
|
|
return ifOpen;
|
|
}
|
|
|
|
|
|
|
|
public void scroll2PositionClick(AccessibilityService service, String text, AccessibilityNodeInfo chilrecy) {
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { //必须android4.3以上的版本
|
|
AccessibilityNodeInfo rootInActiveWindow = service.getRootInActiveWindow(); //获取当前展示的窗口
|
|
if (rootInActiveWindow != null) {
|
|
List<AccessibilityNodeInfo> item = rootInActiveWindow.findAccessibilityNodeInfosByText(text); //根据关键字查找某控件元素
|
|
if (item == null || item.size() == 0) { // 关键字元素不存在,则滚动容器元素
|
|
Log.d(TAG, "不存在 " + text);
|
|
try {
|
|
Thread.sleep(300); //隔200 ms 滚动一次
|
|
} catch (InterruptedException e) {
|
|
e.printStackTrace();
|
|
}
|
|
chilrecy.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); //触发容器元素的滚动事件
|
|
Log.d(TAG, "---- [ " + text + " ] 滚动查找中 ----");
|
|
FensiBean fensi = ProfileSpUtils.getInstance().getFensi();
|
|
String nikename = fensi.getNikename();
|
|
scroll2PositionClick(AblService.getInstance(), nikename, chilrecy);
|
|
} else {
|
|
Log.d(TAG, "存在 " + text);
|
|
try {
|
|
Thread.sleep(3000); //隔200 ms 滚动一次
|
|
} catch (InterruptedException e) {
|
|
e.printStackTrace();
|
|
}
|
|
// chilrecy.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); //触发容器元素的滚动事件
|
|
AblViewUtil.mySleep(1);
|
|
getdouyin();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
public void getdouyin() {
|
|
AccessibilityNodeInfo chilrecy = getguanjian();
|
|
AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow();
|
|
for (int i = 0; i < root.getChildCount(); i++) {
|
|
AccessibilityNodeInfo child = root.getChild(i);
|
|
// Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription());
|
|
// if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) {
|
|
for (int y = 0; y < child.getChildCount(); y++) {
|
|
AccessibilityNodeInfo child1 = child.getChild(y);
|
|
// Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription());
|
|
// if ("androidx.recyclerview.widget.RecyclerView".equals(child1.getClassName())) {
|
|
for (int j = 0; j < child1.getChildCount(); j++) {
|
|
AccessibilityNodeInfo child2 = child1.getChild(j);
|
|
// Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription());
|
|
for (int x = 0; x < child2.getChildCount(); x++) {
|
|
AccessibilityNodeInfo child3 = child2.getChild(x);
|
|
// Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription());
|
|
if ("android.widget.ImageView".equals(child3.getClassName())) {
|
|
//设置recy每次操作的区间0,411 0,1020
|
|
//点击屏幕内的节点元素
|
|
Rect imgBtnOutBound = new Rect();
|
|
child3.getBoundsInScreen(imgBtnOutBound);
|
|
if (imgBtnOutBound.top >= 390 && imgBtnOutBound.bottom <= 1020 && imgBtnOutBound.right <= 72) {
|
|
// Log.e("TIAOSHI###", "----点击了" + child3.getClassName());
|
|
clickcommonthree(child3, "选择框");
|
|
AblViewUtil.mySleep(1);
|
|
} else {
|
|
Log.e("TIAOSHI###", "不在区间内");
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
chilrecy.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); //触发容器元素的滚动事件
|
|
AblViewUtil.mySleep(2);
|
|
AccessibilityNodeInfo roott = AblService.getInstance().getRootInActiveWindow();
|
|
for (int i = 0; i < roott.getChildCount(); i++) {
|
|
AccessibilityNodeInfo child = roott.getChild(i);
|
|
// Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription());
|
|
// if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) {
|
|
for (int y = 0; y < child.getChildCount(); y++) {
|
|
AccessibilityNodeInfo child1 = child.getChild(y);
|
|
// Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription());
|
|
// if ("androidx.recyclerview.widget.RecyclerView".equals(child1.getClassName())) {
|
|
for (int j = 0; j < child1.getChildCount(); j++) {
|
|
AccessibilityNodeInfo child2 = child1.getChild(j);
|
|
// Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription());
|
|
for (int x = 0; x < child2.getChildCount(); x++) {
|
|
AccessibilityNodeInfo child3 = child2.getChild(x);
|
|
// Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription());
|
|
if ("android.widget.ImageView".equals(child3.getClassName())) {
|
|
//设置recy每次操作的区间0,411 0,1020
|
|
//点击屏幕内的节点元素
|
|
Rect imgBtnOutBound = new Rect();
|
|
child3.getBoundsInScreen(imgBtnOutBound);
|
|
if (imgBtnOutBound.top >= 390 && imgBtnOutBound.bottom <= 1020 && imgBtnOutBound.right <= 72) {
|
|
// Log.e("TIAOSHI###", "----点击了" + child3.getClassName());
|
|
clickcommonthree(child3, "选择框");
|
|
FensiBean fensiBean = new FensiBean();
|
|
AccessibilityNodeInfo child4 = child3.getParent().getChild(2);
|
|
if(child4!=null) {
|
|
fensiBean.setNikename(child4.getText().toString());
|
|
ProfileSpUtils.getInstance().saveFensi(fensiBean);
|
|
}
|
|
AblViewUtil.mySleep(2);
|
|
} else {
|
|
Log.e("TIAOSHI###", "不在区间内");
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
public void clickcommonthree(AccessibilityNodeInfo accessibilityNodeInfo, String s) {
|
|
if (accessibilityNodeInfo != null) {
|
|
Rect rect = new Rect();
|
|
accessibilityNodeInfo.getBoundsInScreen(rect);
|
|
AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300);
|
|
Log.e("TIAOSHI###", "点击" + s + "按钮");
|
|
Log.e("TIAOSHI###", "点击" + s + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")");
|
|
} else {
|
|
Log.e("TIAOSHI###", "没有找到" + s + "按钮");
|
|
}
|
|
}
|
|
|
|
public AccessibilityNodeInfo getguanjian() {
|
|
AccessibilityNodeInfo chilrecy = null;
|
|
AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow();
|
|
for (int i = 0; i < root.getChildCount(); i++) {
|
|
AccessibilityNodeInfo child = root.getChild(i);
|
|
// Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription());
|
|
if ("androidx.recyclerview.widget.RecyclerView".equals(child.getClassName())) {
|
|
chilrecy = root.getChild(i);
|
|
// Log.e("TIAOSHI###", "----thrxxxxNode:" + chilrecy.getClassName() + ":" + chilrecy.getText() + ":" + chilrecy.getContentDescription());
|
|
|
|
}
|
|
}
|
|
return chilrecy;
|
|
}
|
|
|
|
|
|
public void fasongsixin(AblService instance) {
|
|
AblViewUtil.mySleep(2);
|
|
//寻找编辑控件
|
|
AccessibilityNodeInfo findcomentt = getEdit();
|
|
List<CommentBeanData> commentBeanDataList = ProfileSpUtils.getInstance().getFensiNotice().getCommentBeanDataList();
|
|
if(commentBeanDataList.size()>0){
|
|
CommentBeanData commentBeanData = commentBeanDataList.get(new Random().nextInt(commentBeanDataList.size()));
|
|
conment = commentBeanData.getComment()+""+getRandomString(2);
|
|
}
|
|
// String conment = getRandomString(2)+"=="+"汉中绿茶,炒青仙豪有需要的联系。品质保障,价格实惠!"+"=="+getRandomString(2);
|
|
Log.e("TIAOSHI###", "获得的信息内容" + conment);
|
|
AblViewUtil.mySleep(1);
|
|
Log.e("TIAOSHI###", "获得的信息内容" + conment);
|
|
if (ChangLiang.phonetype.equals("0")) {
|
|
Log.e("TIAOSHI###", "获得手机类型" + ChangLiang.phonetype);
|
|
//郝总的手机用第一个评论不上去
|
|
// AblViewUtil.paste(findcomentt, conment);//红米7a
|
|
AblViewUtil.sayInput(conment, findcomentt);
|
|
} else {
|
|
Log.e("TIAOSHI###", "获得手机类型" + ChangLiang.phonetype);
|
|
AblViewUtil.sayInput(conment, findcomentt);//华为畅享20
|
|
}
|
|
//发送
|
|
AblViewUtil.mySleep(2+new Random().nextInt(5)+1);
|
|
|
|
// 点击分别发送
|
|
List<AccessibilityNodeInfo> list = AblViewUtil.findByText("分别发送");
|
|
for (AccessibilityNodeInfo item : list) {
|
|
clickcommonthree(item, "发私信");
|
|
}
|
|
AblViewUtil.mySleep(6+new Random().nextInt(5)+1);
|
|
AblStepHandler.sendMsg(AblSteps.STEP_122);
|
|
}
|
|
public void fasongsixintwo(AblService instance) {
|
|
AblViewUtil.mySleep(2);
|
|
//寻找编辑控件
|
|
AccessibilityNodeInfo findcomentt = getEdit();
|
|
List<CommentBeanData> commentBeanDataList = ProfileSpUtils.getInstance().getFensiNotice().getCommentBeanDataList();
|
|
if(commentBeanDataList.size()>0){
|
|
CommentBeanData commentBeanData = commentBeanDataList.get(new Random().nextInt(commentBeanDataList.size()));
|
|
conment = commentBeanData.getComment()+""+getRandomString(2);
|
|
}
|
|
// String conment = getRandomString(2)+"=="+"汉中绿茶,炒青仙豪有需要的联系。品质保障,价格实惠!"+"=="+getRandomString(2);
|
|
Log.e("TIAOSHI###", "获得的信息内容" + conment);
|
|
AblViewUtil.mySleep(1);
|
|
Log.e("TIAOSHI###", "获得的信息内容" + conment);
|
|
if (ChangLiang.phonetype.equals("0")) {
|
|
Log.e("TIAOSHI###", "获得手机类型" + ChangLiang.phonetype);
|
|
//郝总的手机用第一个评论不上去
|
|
// AblViewUtil.paste(findcomentt, conment);//红米7a
|
|
AblViewUtil.sayInput(conment, findcomentt);
|
|
} else {
|
|
Log.e("TIAOSHI###", "获得手机类型" + ChangLiang.phonetype);
|
|
AblViewUtil.sayInput(conment, findcomentt);//华为畅享20
|
|
}
|
|
//发送
|
|
AblViewUtil.mySleep(2+new Random().nextInt(5)+1);
|
|
|
|
// 点击分别发送
|
|
List<AccessibilityNodeInfo> list = AblViewUtil.findByText("分别发送");
|
|
for (AccessibilityNodeInfo item : list) {
|
|
clickcommonthree(item, "发私信");
|
|
}
|
|
AblViewUtil.mySleep(6+new Random().nextInt(5)+1);
|
|
AblStepHandler.sendMsg(AblSteps.STEP_83);
|
|
}
|
|
|
|
public void fasongsixinthree(AblService instance) {
|
|
AblViewUtil.mySleep(2);
|
|
//寻找编辑控件
|
|
AccessibilityNodeInfo findcomentt = getEdit();
|
|
List<CommentBeanData> commentBeanDataList = ProfileSpUtils.getInstance().getFensiNotice().getCommentBeanDataList();
|
|
if(commentBeanDataList.size()>0){
|
|
CommentBeanData commentBeanData = commentBeanDataList.get(new Random().nextInt(commentBeanDataList.size()));
|
|
conment = commentBeanData.getComment()+""+getRandomString(2);
|
|
}
|
|
// String conment = getRandomString(2)+"=="+"汉中绿茶,炒青仙豪有需要的联系。品质保障,价格实惠!"+"=="+getRandomString(2);
|
|
AblViewUtil.mySleep(1);
|
|
Log.e("TIAOSHI###", "获得的信息内容" + conment);
|
|
if (ChangLiang.phonetype.equals("0")) {
|
|
Log.e("TIAOSHI###", "获得手机类型" + ChangLiang.phonetype);
|
|
//郝总的手机用第一个评论不上去
|
|
// AblViewUtil.paste(findcomentt, conment);//红米7a
|
|
AblViewUtil.sayInput(conment, findcomentt);
|
|
} else {
|
|
Log.e("TIAOSHI###", "获得手机类型" + ChangLiang.phonetype);
|
|
AblViewUtil.sayInput(conment, findcomentt);//华为畅享20
|
|
}
|
|
//发送
|
|
AblViewUtil.mySleep(2+new Random().nextInt(5)+1);
|
|
|
|
// 点击分别发送
|
|
List<AccessibilityNodeInfo> list = AblViewUtil.findByText("分别发送");
|
|
for (AccessibilityNodeInfo item : list) {
|
|
clickcommonthree(item, "发私信");
|
|
}
|
|
AblViewUtil.mySleep(6+new Random().nextInt(5)+1);
|
|
AblStepHandler.sendMsg(AblSteps.STEP_203);
|
|
}
|
|
|
|
private AccessibilityNodeInfo getEdit() {
|
|
AccessibilityNodeInfo nodeinfo = null;
|
|
AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow();
|
|
for (int i = 0; i < root.getChildCount(); i++) {
|
|
AccessibilityNodeInfo child = root.getChild(i);
|
|
// Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription());
|
|
for (int y = 0; y < child.getChildCount(); y++) {
|
|
AccessibilityNodeInfo child1 = child.getChild(y);
|
|
// Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription());
|
|
if("android.widget.EditText".equals(child1.getClassName())){
|
|
if(child1.getText().equals("有什么想和好友说的...")){
|
|
nodeinfo=child1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return nodeinfo;
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* 点击直播间下方的更多按钮(备注:在首页点击直播进去的可用)
|
|
* 1.说点什么
|
|
* 2.更多
|
|
* 3.礼物
|
|
*/
|
|
public void clickmore(String type) {
|
|
AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow();
|
|
for (int i = 0; i < root.getChildCount(); i++) {
|
|
AccessibilityNodeInfo child = root.getChild(i);
|
|
// Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription());
|
|
for (int y = 0; y < child.getChildCount(); y++) {
|
|
AccessibilityNodeInfo child1 = child.getChild(y);
|
|
// Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription());
|
|
switch (type) {
|
|
case "1"://说点什么
|
|
if ("android.widget.TextView".equals(child1.getClassName())) {
|
|
if (child1.getText() != null) {
|
|
if (child1.getText().toString().equals("说点什么...")) {
|
|
AblService.getInstance().clickcommontwo(child1, "");
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case "2"://更多
|
|
if ("android.widget.Button".equals(child1.getClassName())) {
|
|
if (child1.getContentDescription().equals("更多")) {
|
|
AblService.getInstance().clickcommontwo(child1, "点击了更多");
|
|
}
|
|
}
|
|
break;
|
|
case "3"://礼物
|
|
if ("android.widget.Button".equals(child1.getClassName())) {
|
|
if (child1.getContentDescription().equals("礼物")) {
|
|
AblService.getInstance().clickcommontwo(child1, "");
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/**
|
|
* 点击直播间下方的更多按钮(备注:通过搜索点击直播进去的可用)
|
|
* 1.说点什么
|
|
* 2.更多
|
|
* 3.礼物
|
|
*/
|
|
public void clickmoreli(String type) {
|
|
AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow();
|
|
for (int i = 0; i < root.getChildCount(); i++) {
|
|
AccessibilityNodeInfo child = root.getChild(i);
|
|
// Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription());
|
|
for (int y = 0; y < child.getChildCount(); y++) {
|
|
AccessibilityNodeInfo child1 = child.getChild(y);
|
|
// Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription());
|
|
for (int j = 0; j < child1.getChildCount(); j++) {
|
|
AccessibilityNodeInfo child2 = child1.getChild(j);
|
|
// Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription());
|
|
for (int x = 0; x < child2.getChildCount(); x++) {
|
|
AccessibilityNodeInfo child3 = child2.getChild(x);
|
|
// Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription());
|
|
for (int r = 0; r < child3.getChildCount(); r++) {
|
|
AccessibilityNodeInfo child4 = child3.getChild(r);
|
|
// Log.e("TIAOSHI###", "----5Node:" + child4.getClassName() + ":" + child4.getText() + ":" + child4.getContentDescription());
|
|
switch (type) {
|
|
case "1"://说点什么
|
|
if ("android.widget.TextView".equals(child4.getClassName())) {
|
|
if (child4.getText() != null) {
|
|
if (child4.getText().toString().equals("说点什么...")) {
|
|
AblService.getInstance().clickcommontwo(child4, "");
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case "2"://更多
|
|
if ("android.widget.Button".equals(child4.getClassName())) {
|
|
if (child4.getContentDescription().equals("更多")) {
|
|
AblService.getInstance().clickcommontwo(child4, "点击了更多");
|
|
}
|
|
}
|
|
break;
|
|
case "3"://礼物
|
|
if ("android.widget.Button".equals(child4.getClassName())) {
|
|
if (child4.getContentDescription().equals("礼物")) {
|
|
AblService.getInstance().clickcommontwo(child4, "");
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 分享
|
|
* 1为分享 2为私信朋友
|
|
*/
|
|
public void share(String type) {
|
|
AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow();
|
|
for (int i = 0; i < root.getChildCount(); i++) {
|
|
AccessibilityNodeInfo child = root.getChild(i);
|
|
// Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription());
|
|
for (int y = 0; y < child.getChildCount(); y++) {
|
|
AccessibilityNodeInfo child1 = child.getChild(y);
|
|
// Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription());
|
|
for (int j = 0; j < child1.getChildCount(); j++) {
|
|
AccessibilityNodeInfo child2 = child1.getChild(j);
|
|
// Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription());
|
|
for (int x = 0; x < child2.getChildCount(); x++) {
|
|
AccessibilityNodeInfo child3 = child2.getChild(x);
|
|
// Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription());
|
|
switch (type) {
|
|
case "1":
|
|
if ("android.widget.TextView".equals(child3.getClassName())) {
|
|
if (child3.getText() != null) {
|
|
if (child3.getText().toString().equals("分享")) {
|
|
AblService.getInstance().clickcommontwo(child3, "");
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case "2":
|
|
if ("android.widget.TextView".equals(child3.getClassName())) {
|
|
if (child3.getText() != null) {
|
|
if (child3.getText().toString().equals("私信朋友")) {
|
|
AblService.getInstance().clickcommontwo(child3, "");
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//点击右上角搜索
|
|
public void DianSou() {
|
|
//华为畅享20
|
|
AblService.getInstance().clickPoint(990, 163, 300);
|
|
switch (ChangLiang.phonetype){
|
|
case "0":
|
|
//红米7a
|
|
AblService.getInstance().clickPoint(656, 99, 300);
|
|
break;
|
|
case "1":
|
|
//华为畅享20
|
|
AblService.getInstance().clickPoint(659, 99, 300);
|
|
break;
|
|
case "2":
|
|
//华为畅享20
|
|
AblService.getInstance().clickPoint(990, 163, 300);
|
|
break;
|
|
case "3":
|
|
//note9
|
|
AblService.getInstance().clickPoint(990, 163, 300);
|
|
break;
|
|
default:
|
|
}
|
|
Log.e("TIAOSHI###", "点击搜索按钮");
|
|
}
|
|
|
|
/**
|
|
* 说点什么节点
|
|
* @return
|
|
*/
|
|
public AccessibilityNodeInfo geouyintd() {
|
|
AccessibilityNodeInfo nodeinfo = null;
|
|
AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow();
|
|
for (int i = 0; i < root.getChildCount(); i++) {
|
|
AccessibilityNodeInfo child = root.getChild(i);
|
|
Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription());
|
|
if ("android.widget.TextView".equals(child.getClassName())) {
|
|
if (child.getText().toString().equals("说点什么...:")) {
|
|
nodeinfo=child;
|
|
}
|
|
}
|
|
}
|
|
return nodeinfo;
|
|
}
|
|
/**
|
|
* 输入框
|
|
* @return
|
|
*/
|
|
public AccessibilityNodeInfo getedittext() {
|
|
AccessibilityNodeInfo nodeinfo = null;
|
|
AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow();
|
|
for (int i = 0; i < root.getChildCount(); i++) {
|
|
AccessibilityNodeInfo child = root.getChild(i);
|
|
// Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription());
|
|
if ("android.widget.EditText".equals(child.getClassName())) {
|
|
nodeinfo=child;
|
|
}
|
|
}
|
|
return nodeinfo;
|
|
}
|
|
|
|
/**
|
|
* 发送节点
|
|
* @return
|
|
*/
|
|
public AccessibilityNodeInfo geouyintdd() {
|
|
AccessibilityNodeInfo nodeinfo = null;
|
|
AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow();
|
|
for (int i = 0; i < root.getChildCount(); i++) {
|
|
AccessibilityNodeInfo child = root.getChild(i);
|
|
// Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription());
|
|
if ("android.widget.Button".equals(child.getClassName())) {
|
|
if(child.getContentDescription()!=null) {
|
|
if (child.getContentDescription().toString().equals("发送")) {
|
|
nodeinfo = child;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return nodeinfo;
|
|
}
|
|
|
|
|
|
/**
|
|
* 点击礼物下面的菜单
|
|
* 1.礼物
|
|
* 2.表情
|
|
* 3.粉丝团
|
|
* 4.等级
|
|
* 5.背包
|
|
*/
|
|
public void clickmenu(String type) {
|
|
AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow();
|
|
for (int i = 0; i < root.getChildCount(); i++) {
|
|
AccessibilityNodeInfo child = root.getChild(i);
|
|
for (int y = 0; y < child.getChildCount(); y++) {
|
|
AccessibilityNodeInfo child1 = child.getChild(y);
|
|
for (int j = 0; j < child1.getChildCount(); j++) {
|
|
AccessibilityNodeInfo child2 = child1.getChild(j);
|
|
Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription());
|
|
for (int x = 0; x < child2.getChildCount(); x++) {
|
|
AccessibilityNodeInfo child3 = child2.getChild(x);
|
|
Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription());
|
|
switch (type) {
|
|
case "1"://礼物
|
|
if ("android.widget.TextView".equals(child3.getClassName())) {
|
|
if (child3.getText() != null) {
|
|
if (child3.getText().toString().equals("礼物")) {
|
|
AblService.getInstance().clickcommontwo(child3, "");
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case "2"://表情
|
|
if ("android.widget.TextView".equals(child3.getClassName())) {
|
|
if (child3.getText().toString().equals("表情")) {
|
|
AblService.getInstance().clickcommontwo(child3, "");
|
|
}
|
|
}
|
|
break;
|
|
case "3"://粉丝团
|
|
if ("android.widget.TextView".equals(child3.getClassName())) {
|
|
if (child3.getText().toString().equals("粉丝团")) {
|
|
AblService.getInstance().clickcommontwo(child3, "");
|
|
}
|
|
}
|
|
break;
|
|
case "4"://等级
|
|
if ("android.widget.TextView".equals(child3.getClassName())) {
|
|
if (child3.getText().toString().equals("等级")) {
|
|
AblService.getInstance().clickcommontwo(child3, "");
|
|
}
|
|
}
|
|
case "5"://背包
|
|
if ("android.widget.TextView".equals(child3.getClassName())) {
|
|
if (child3.getText().toString().equals("背包")) {
|
|
AblService.getInstance().clickcommontwo(child3, "");
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获得背包中第一个位置的了礼物
|
|
*/
|
|
public List<AccessibilityNodeInfo> geliwu() {
|
|
List<AccessibilityNodeInfo> liwus = new ArrayList<>();
|
|
AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow();
|
|
for (int i = 0; i < root.getChildCount(); i++) {
|
|
AccessibilityNodeInfo child = root.getChild(i);
|
|
for (int y = 0; y < child.getChildCount(); y++) {
|
|
AccessibilityNodeInfo child1 = child.getChild(y);
|
|
for (int j = 0; j < child1.getChildCount(); j++) {
|
|
AccessibilityNodeInfo child2 = child1.getChild(j);
|
|
if ("android.view.ViewGroup".equals(child2.getClassName())) {
|
|
Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription());
|
|
liwus.add(child2);
|
|
// for (int x = 0; x < child2.getChildCount(); x++) {
|
|
// AccessibilityNodeInfo child3 = child2.getChild(x);
|
|
// Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription());
|
|
// }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return liwus;
|
|
}
|
|
|
|
/**
|
|
* 点击加关注
|
|
*/
|
|
public void clickGuanzhu() {
|
|
AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow();
|
|
for (int i = 0; i < root.getChildCount(); i++) {
|
|
AccessibilityNodeInfo child = root.getChild(i);
|
|
// Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription());
|
|
for (int y = 0; y < child.getChildCount(); y++) {
|
|
AccessibilityNodeInfo child1 = child.getChild(y);
|
|
// Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription());
|
|
for (int j = 0; j < child1.getChildCount(); j++) {
|
|
AccessibilityNodeInfo child2 = child1.getChild(j);
|
|
// Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription());
|
|
if ("android.widget.TextView".equals(child2.getClassName())) {
|
|
if (child2.getText() != null) {
|
|
if (child2.getText().toString().equals("关注")) {
|
|
AblService.getInstance().clickcommontwo(child2, "");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|