| | |
| | | import android.text.Spanned; |
| | | import android.text.TextUtils; |
| | | import android.text.style.TextAppearanceSpan; |
| | | import android.util.Log; |
| | | import android.view.Gravity; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | |
| | | import com.example.datalibrary.model.User; |
| | | import com.example.datalibrary.utils.ToastUtils; |
| | | import com.example.datalibrary.view.PreviewTexture; |
| | | import com.mc.enjoysdk.McHome; |
| | | import com.mc.enjoysdk.McSystemUi; |
| | | import com.mc.enjoysdk.transform.McSystemUiFlag; |
| | | import com.proembed.service.MyService; |
| | | import com.yanzhenjie.permission.runtime.Permission; |
| | | |
| | | import org.greenrobot.eventbus.EventBus; |
| | | import org.greenrobot.eventbus.Subscribe; |
| | | import org.greenrobot.eventbus.ThreadMode; |
| | | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.PrintStream; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Timer; |
| | | import java.util.TimerTask; |
| | | import java.util.concurrent.ExecutorService; |
| | | import java.util.concurrent.Executors; |
| | | import java.util.concurrent.Future; |
| | | import java.util.regex.Matcher; |
| | |
| | | private int downCount = 0; |
| | | private Long lastDownTime; |
| | | private Long showTime; |
| | | private McSystemUi mcSystemUi; |
| | | private McHome mcHome; |
| | | private MyService mXService; |
| | | |
| | | private Handler handler = new Handler(){ |
| | | @Override |
| | |
| | | Intent intent2 = new Intent(MainActivity.this, FaceUpdateService.class); |
| | | startService(intent2);*/ |
| | | getPermission(); |
| | | Timber.tag("====>").d(LMobileInfo.getDeviceUniqueId()); |
| | | mcSystemUi = McSystemUi.getInstance(this); |
| | | mcHome = McHome.getInstance(this); |
| | | mXService = new MyService(this); |
| | | //Timber.tag("====>").d(LMobileInfo.getDeviceUniqueId()); |
| | | } |
| | | |
| | | private void initM(){ |
| | |
| | | if((availableMemory<100&&showTime!=null&&(System.currentTimeMillis()-showTime>5000))|| |
| | | ("02:00:00".equals(StringUtil.getHM()))){ |
| | | //可用内存小于400M,或者每天凌晨2点,重启app |
| | | //ToastView.show(MApplication.mContext,"内存紧张,重新启动"); |
| | | restartApp(); |
| | | } |
| | | } |
| | |
| | | } |
| | | lastDownTime1 = System.currentTimeMillis(); |
| | | downCount1++; |
| | | System.out.println(); |
| | | //Timber.tag("==>").d(""+downCount1); |
| | | if(downCount1>4) { |
| | | downCount1=0; |
| | |
| | | } |
| | | } |
| | | }); |
| | | |
| | | getDB().imgLeft.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v1) { |
| | |
| | | getDB().nsv.setVisibility(View.VISIBLE); |
| | | } |
| | | //显示状态栏 |
| | | mcSystemUi.temporarilySwitchStatusBar(true); |
| | | //显示导航栏 |
| | | mcSystemUi.temporarilySwitchNavigation(true); |
| | | MCUtils.show(mXService); |
| | | } |
| | | }); |
| | | upErrInfo(); |
| | |
| | | if(devConfigBean!=null){ |
| | | if(devConfigBean.getBannerList()!=null) { |
| | | setBanner(devConfigBean.getBannerList()); |
| | | } |
| | | if(!isFaceOk) { |
| | | initLicense(); |
| | | } |
| | | setJiuConfig(); |
| | | initPort(); |
| | |
| | | switch (type){ |
| | | case 2: |
| | | case 3: { |
| | | if(!isFaceOk) { |
| | | initLicense(); |
| | | return; |
| | | } |
| | | //校验是否登录 |
| | | if(MApplication.getConfigBean().getId()==null){ |
| | | Toast.makeText(mContext, "设备未添加,无法操作", Toast.LENGTH_SHORT).show(); |
| | |
| | | super.onResume(); |
| | | isShowing = true; |
| | | getVM().setSubmit(true); |
| | | MCUtils.hind(mcSystemUi); |
| | | mcHome.setHomePackage("com.doumee.keyCabinet"); |
| | | MCUtils.hind(mXService); |
| | | MCUtils.setHomePackage(mXService,"com.doumee.keyCabinet"); |
| | | showTime = System.currentTimeMillis(); |
| | | if(!isFaceOk) { |
| | | initLicense(); |
| | | } |
| | | if(isHavePermission) { |
| | | checkUpdate(); |
| | | } |
| | |
| | | |
| | | @Subscribe |
| | | public void GetFacesEvent(GetFacesEvent event){ |
| | | getVM().addInfo("查询人脸数据======》"); |
| | | if(!isFinishing()&&!isUpdatingFace){ |
| | | getVM().addInfo("查询人脸数据======》isDBLoad = "+isDBLoad); |
| | | if(isDBLoad){ |
| | |
| | | } |
| | | |
| | | private void initModel(List<FaceUserBean> userBeans) { |
| | | if(!isFaceOk){ |
| | | return; |
| | | } |
| | | if (com.example.datalibrary.manager.FaceSDKManager.initStatus == com.example.datalibrary.manager.FaceSDKManager.SDK_MODEL_LOAD_SUCCESS) { |
| | | getVM().addInfo("更新人脸===》开始更新"); |
| | | //getVM().addInfo("更新人脸===》开始更新"); |
| | | waitUpdate(userBeans); |
| | | }else { |
| | | getVM().addInfo("更新人脸===》初始化"); |
| | | //getVM().addInfo("更新人脸===》初始化"); |
| | | initFaceSDKManager(userBeans); |
| | | } |
| | | } |
| | |
| | | |
| | | @Override |
| | | public void onResultBytes(byte[] bytes) { |
| | | if(isFinishing()){ |
| | | if(isFinishing()||getVM()==null){ |
| | | return; |
| | | } |
| | | if(bytes.length==0){ |
| | |
| | | |
| | | @Subscribe(threadMode = ThreadMode.MAIN) |
| | | public void HttpEvent(HttpEvent e){ |
| | | if(!isFinishing()){ |
| | | if(!isFinishing()&&getVM()!=null){ |
| | | getVM().addInfo(e.getMsg()); |
| | | } |
| | | } |
| | |
| | | //一号版 |
| | | bh = 1; |
| | | } |
| | | String[] sp = data.split("AA"); |
| | | List<String> sp = new ArrayList<>(); |
| | | String data2 = data.substring(8,data.length()); |
| | | while (data2.length()>0){ |
| | | if (data2.length()<22) { |
| | | sp.add(data2+""); |
| | | data2 = ""; |
| | | }else { |
| | | sp.add(data2.substring(0,22)); |
| | | data2 = data2.substring(22); |
| | | } |
| | | } |
| | | for(String s:sp){ |
| | | if(s.length()>=20){ |
| | | String key = SportUtils.intToHex(bh)+s.substring(4,6); |
| | |
| | | }else { |
| | | gridDo.setCurKeyCode(""); |
| | | } |
| | | if("0101".equals(key)) { |
| | | if("0109".equals(key)) { |
| | | getVM().addInfo(key+" , "+isHaveKey+" "+keyCode); |
| | | getVM().addInfo(key + "设置钥匙:" + gridDo.getCurKeyCode()); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public void onResultBytes(byte[] bytes) { |
| | | if(isFinishing()){ |
| | | if(isFinishing()||getVM()==null){ |
| | | return; |
| | | } |
| | | if(bytes.length==0){ |
| | |
| | | /*SpUtil.setString("port_grid","/dev/ttyS0"); |
| | | SpUtil.setString("port_key","/dev/ttyS4"); |
| | | SpUtil.setString("port_jiu","/dev/ttyS9");*/ |
| | | |
| | | gridPath = SpUtil.getString("port_grid"); |
| | | getVM().addInfo("门串口链接:"+gridPath); |
| | | keyPath = SpUtil.getString("port_key"); |
| | | getVM().addInfo("钥匙串口链接:"+keyPath); |
| | | jiuPath = SpUtil.getString("port_jiu"); |
| | | getVM().addInfo("酒精串口链接:"+jiuPath); |
| | | if(!TextUtils.isEmpty(SpUtil.getString("port_grid"))&& |
| | | !TextUtils.isEmpty(SpUtil.getString("port_key"))&& |
| | | !TextUtils.isEmpty(SpUtil.getString("port_jiu"))){ |
| | | if(isInitPort){ |
| | | return; |
| | | } |
| | | gridPath = SpUtil.getString("port_grid"); |
| | | getVM().addInfo("门串口链接:"+gridPath); |
| | | keyPath = SpUtil.getString("port_key"); |
| | | getVM().addInfo("钥匙串口链接:"+keyPath); |
| | | jiuPath = SpUtil.getString("port_jiu"); |
| | | getVM().addInfo("酒精串口链接:"+jiuPath); |
| | | xhCount=0; |
| | | closePort(chosePort); |
| | | if(!TextUtils.isEmpty(SpUtil.getString("port_grid"))){ |