<commit_before>package com.auto.auto.service;

import android.accessibilityservice.AccessibilityService;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;

import com.auto.auto.Model.Account;
import com.auto.auto.Constant;
import com.auto.auto.Operation;
import com.newland.support.nllogger.LogUtils;

import java.util.ArrayList;
import java.util.List;

public class AutoPushCard extends AccessibilityService {

    boolean isLoginOperate = false;
    boolean isAlreadyOpenCheckOut = false;

    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    @Override
    public void onAccessibilityEvent(AccessibilityEvent accessibilityEvent) {

        int eventType = accessibilityEvent.getEventType();
        String packageName = accessibilityEvent.getPackageName().toString();
        if (Operation.isInCheckInDuration()) {

            if (eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED && Constant.DING_PACKAGE_NAME.equals(packageName)) {
                autoLogin();
                closeWebAlert();
            } else if (eventType == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED && Constant.DING_PACKAGE_NAME.equals(packageName)) {
                //界面的切换会多次调用，在这里进行是否打卡成功的检测，比较妥当
                openWorkNotificationPage();
            }
        }

        if (Operation.isInCheckOutDuration()) {

            if (eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED && Constant.DING_PACKAGE_NAME.equals(packageName)) {
                startCheckOut();
            }
        }
    }

    private void startCheckOut() {
        if (isAlreadyOpenCheckOut) {
            return;
        }

        List<AccessibilityNodeInfo> bottomTab = findNodeById(Constant.BOTTOM_TAB_LAYOUT);
        if (bottomTab.size() > 0) {
            List<AccessibilityNodeInfo> toWorkPageButton = bottomTab.get(0).findAccessibilityNodeInfosByViewId(Constant.TAB_FOR_WORK);
            if (toWorkPageButton.size() > 0) {
                toWorkPageButton.get(0).performAction(AccessibilityNodeInfo.ACTION_CLICK);
                openCheckOutPage();
            }
        } else {
            LogUtils.d("$$$ 下班打卡未发现底部tabBar，点击返回按钮");
            List<AccessibilityNodeInfo> backButton = findNodeById(Constant.BACK_BUTTON);
            if (backButton.size() > 0) {
                backButton.get(0).performAction(AccessibilityNodeInfo.ACTION_CLICK);
            }
        }
    }<commit_msg>(*)添加下班自动打卡<commit_after>package com.auto.auto.service;

import android.accessibilityservice.AccessibilityService;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;

import com.auto.auto.Model.Account;
import com.auto.auto.Constant;
import com.auto.auto.Operation;
import com.newland.support.nllogger.LogUtils;

import java.util.ArrayList;
import java.util.List;

public class AutoPushCard extends AccessibilityService {

    boolean isLoginOperate = false;
    boolean isAlreadyOpenCheckOut = false;

    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    @Override
    public void onAccessibilityEvent(AccessibilityEvent accessibilityEvent) {

        int eventType = accessibilityEvent.getEventType();
        String packageName = accessibilityEvent.getPackageName().toString();
        if (Operation.isInCheckInDuration()) {

            if (eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED && Constant.DING_PACKAGE_NAME.equals(packageName)) {
                autoLogin();
                closeWebAlert();
            } else if (eventType == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED && Constant.DING_PACKAGE_NAME.equals(packageName)) {
                //界面的切换会多次调用，在这里进行是否打卡成功的检测，比较妥当
                openWorkNotificationPage();
            }
        }

        if (Operation.isInCheckOutDuration()) {

            if (eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED && Constant.DING_PACKAGE_NAME.equals(packageName)) {
                startCheckOut();
            }
        }
    }

    private void findAndClickCheckoutBtn() {
        List<AccessibilityNodeInfo> webList = findNodeById(Constant.WEB_VIEW);
        if (webList != null & webList.size() > 0) {
            final AccessibilityNodeInfo webNode = webList.get(0);
            try {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            webNode.getChild(0).getChild(0).getChild(2).getChild(1).getChild(1).performAction(AccessibilityNodeInfo.ACTION_CLICK);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }).start();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    private void startCheckOut() {
        if (isAlreadyOpenCheckOut) {
            return;
        }

        List<AccessibilityNodeInfo> bottomTab = findNodeById(Constant.BOTTOM_TAB_LAYOUT);
        if (bottomTab.size() > 0) {
            List<AccessibilityNodeInfo> toWorkPageButton = bottomTab.get(0).findAccessibilityNodeInfosByViewId(Constant.TAB_FOR_WORK);
            if (toWorkPageButton.size() > 0) {
                toWorkPageButton.get(0).performAction(AccessibilityNodeInfo.ACTION_CLICK);
                openCheckOutPage();
                findAndClickCheckoutBtn();
            }
        } else {
            LogUtils.d("$$$ 下班打卡未发现底部tabBar，点击返回按钮");
            List<AccessibilityNodeInfo> backButton = findNodeById(Constant.BACK_BUTTON);
            if (backButton.size() > 0) {
                backButton.get(0).performAction(AccessibilityNodeInfo.ACTION_CLICK);
            }
        }
    }
{'fraction_non_alphanumeric': 0.09399304980969717, 'fraction_numerical': 0.0031441337084229686, 'mean_word_length': 2.6062052505966586, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6741488', 'n_tokens_mistral': 1743, 'n_tokens_neox': 1720, 'n_words': 241}