554325746@qq.com
2019-08-07 2539f53391765abb74b6fe63f46e5a2c701e950f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package com.basic.security.activity;
 
import android.content.Intent;
import android.view.WindowManager;
import android.widget.LinearLayout;
 
import com.alfeye.readcardlib.readcard.ReadCardUtil;
import com.basic.security.R;
import com.basic.security.activity.helper.MaLoggedInTimeoutToLogout;
import com.basic.security.manager.IdCardManager;
import com.basic.security.utils.Constants;
import com.basic.security.utils.KeyboardUtil;
import com.basic.security.utils.PermissionHelper;
import com.basic.security.utils.ToastUtil;
import com.basic.security.manager.impl.erlang.ErlangProcess;
 
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;
 
import static com.basic.security.utils.Constants.isNewIDCardReader;
 
 
@EActivity(R.layout.activity_main)
public class MainActivity extends MaLoggedInTimeoutToLogout {
 
    public MainActivity getActivity() {
        return this;
    }
 
    public boolean mainActivityInitComplete = false;
    public static boolean faceDbInitComplete = false;
 
 
    //1是usb模式   0是串口模式   5.1.1
//    public ReadUtil readUtil;
 
    //新的pad  白色   身份证读卡器
    public ReadCardUtil readCardUtil;
 
    @AfterViews
    protected void afterViews() {
 
        if (!PermissionHelper.hasWriteStoragePermission(this)) {
            PermissionHelper.requestWriteStoragePermission(this);
        }
 
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // 保持屏幕常亮
 
        hideSystemUIThread();
        addFragments();
 
        addCameraToFragment();
        addVideoViewToFragment();
        addToolbarButtonsToFragment();
 
        addTimeoutToBlank();
 
        addIdCardPhoneComponent();
 
        addBackgroundAndBorderComponent();
 
        addCameras();
 
        setUpClickHook();
 
        addFaceComponents();
 
        addSystemSettingTabs();
 
        addSystemSettingHintTabs();
 
        addPersonManagerComponents();
 
        logoutChecker();
 
        hideOneFragment(fragment_menu);
        hideOneFragment(fragment_person_identity);
        hideOneFragment(fragment_face_list);
        hideOneFragment(fragment_face_detail);
        hideOneFragment(fragment_system_setting_tabs);
        hideOneFragment(fragment_su_auto_ic_wait_phone);
        hideOneFragment(fragment_su_logged_ic_wait_idcard);
        hideOneFragment(fragment_su_logged_ic_compare_success);
        hideOneFragment(fragment_background_and_border);
 
        showFragment(fragment_home);
 
        mainActivityInitComplete = true;
        checkDeviceId();
    }
 
    @ViewById
    LinearLayout id111;
 
    @Override
    protected void onResume() {
        super.onResume();
        Intent intent1 = new Intent();
        intent1.setPackage("com.basic.project.idcardservice");
        intent1.setAction("com.basic.read.IDCard");
        intent1.putExtra("type", "start_service");
        intent1.setFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
        startService(intent1);
 
    }
 
    long startTime = 0;
 
    @Override
    public void onBackPressed() {
        long currentTime = System.currentTimeMillis();
        if ((currentTime - startTime) >= 2000) {
            ToastUtil.show("再按一次退出");
            startTime = currentTime;
        } else {
//            ErlangProcess.stopErlangProcess();
            exitApp();
        }
    }
 
    private void exitApp() {
        if (isNewIDCardReader) {
 
            if (readCardUtil != null) {
                readCardUtil.stopReadCard();
                readCardUtil.destroy();
            }
 
        } else {
            IdCardManager.unRegisterBroadcast(this);
        }
 
        finish();
        System.exit(0);
    }
 
    @Override
    protected void onPause() {
        super.onPause();
        KeyboardUtil.hideSoftKeyboard();
    }
 
    @Override
    protected void onStop() {
        super.onStop();
//        exitApp();
    }
 
 
}