keyCabinet-android/app/build.gradle
@@ -10,8 +10,8 @@ applicationId "com.doumee.keyCabinet" minSdkVersion build_versions.min_sdk targetSdkVersion build_versions.target_sdk versionCode 1 versionName "1.0.0" versionCode 2 versionName "1.0.1" //支持vectorDrawables矢量图 vectorDrawables.useSupportLibrary = true keyCabinet-android/app/src/main/AndroidManifest.xml
@@ -76,19 +76,19 @@ android:resource="@xml/provider_paths" /> </provider> <receiver <!--<receiver android:name="com.doumee.keyCabinet.ui.service.BootCompleteReceiver" android:enabled="true" android:exported="true"> <!-- 接收启动完成的广播 --> <!– 接收启动完成的广播 –> <intent-filter android:priority="1000"> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> </receiver>--> <service android:name="com.doumee.keyCabinet.ui.service.HeartbeatService" /> <service android:name="com.doumee.keyCabinet.ui.service.FaceUpdateService" /> <!--<service android:name="com.doumee.keyCabinet.ui.service.HeartbeatService" /> <service android:name="com.doumee.keyCabinet.ui.service.FaceUpdateService" />--> <uses-library android:name="org.apache.http.legacy" keyCabinet-android/app/src/main/java/com/doumee/keyCabinet/ui/keyCabinet/KeyCabinetActivity.java
@@ -169,7 +169,7 @@ downTime = 60; break; case 2: getDB().clTip1.setVisibility(View.GONE); //getDB().clTip1.setVisibility(View.GONE); if(status==0) { //重新开门 openTime = StringUtil.DateToStr(new Date()); @@ -321,8 +321,7 @@ return; } isOpened = true; Toast.makeText(mContext, "操作4", Toast.LENGTH_LONG).show(); doRegister(4, null); getVM().doAction(4); } else { //失败 //如果是钥匙不对继续开门 @@ -335,12 +334,12 @@ } if (!gridDo.getCurKeyCode().equals(selectBean.getKeyCode())) { //钥匙不匹配 doRegister(10,null); getVM().doAction(10,null); EventBus.getDefault().post(new OpenGridEvent(selectBean.getChannelCode(), selectBean.getBoardCode())); return; } } doRegister(3, null); getVM().doAction(3); } } } @@ -385,18 +384,17 @@ if (gridDo.getCurKeyCode().equals(selectBean.getKeyCode())) { //领取失败 isOpened = false; doRegister(6, null); getVM().doAction(6); getVM().closeGrid(gridDo); }else { //钥匙不匹配 //Toast.makeText(mContext, "操作10", Toast.LENGTH_LONG).show(); doRegister(10,null); getVM().doAction(10,null); EventBus.getDefault().post(new OpenGridEvent(selectBean.getChannelCode(), selectBean.getBoardCode())); } } else { //钥匙拿走了 isOpened = false; doRegister(5, null); getVM().doAction(5); getVM().closeGrid(gridDo); } }else { @@ -422,17 +420,17 @@ if (gridDo.getCurKeyCode().equals(selectBean.getKeyCode())) { //相同归还成功 isOpened = false; doRegister(8, null); getVM().doAction(8); getVM().closeGrid(gridDo); }else { //钥匙不匹配 doRegister(10,null); getVM().doAction(10,null); EventBus.getDefault().post(new OpenGridEvent(selectBean.getChannelCode(), selectBean.getBoardCode())); } } else { //钥匙未归还 isOpened = false; doRegister(9, null); getVM().doAction(9); getVM().closeGrid(gridDo); } }else { @@ -488,25 +486,24 @@ if (gridDo.getCurKeyCode().equals(selectBean.getKeyCode())) { //领取失败 isOpened = false; doRegister(6, null); getVM().doAction(6); getVM().closeGrid(gridDo); }else { //钥匙不匹配 //Toast.makeText(mContext, "操作10", Toast.LENGTH_LONG).show(); doRegister(10,null); getVM().doAction(10); EventBus.getDefault().post(new OpenGridEvent(selectBean.getChannelCode(), selectBean.getBoardCode())); } } else { //钥匙拿走了 isOpened = false; doRegister(5, null); getVM().doAction(5); getVM().closeGrid(gridDo); } }else { //没关门 if(TextUtils.isEmpty(gridDo.getCurKeyCode())){ //空了 doRegister(7,null); getVM().doAction(7); } } }else { @@ -522,24 +519,24 @@ if (gridDo.getCurKeyCode().equals(selectBean.getKeyCode())) { //相同归还成功 isOpened = false; doRegister(8, null); getVM().doAction(8); getVM().closeGrid(gridDo); }else { //钥匙不匹配 doRegister(10,null); getVM().doAction(10); EventBus.getDefault().post(new OpenGridEvent(selectBean.getChannelCode(), selectBean.getBoardCode())); } } else { //钥匙未归还 isOpened = false; doRegister(9, null); getVM().doAction(9); getVM().closeGrid(gridDo); } }else { //没关门 if(!TextUtils.isEmpty(gridDo.getCurKeyCode())){ //有钥匙了 doRegister(7,null); getVM().doAction(7); } } } else { keyCabinet-android/app/src/main/java/com/doumee/keyCabinet/ui/keyCabinet/ManageCabinetActivity.java
@@ -184,11 +184,6 @@ for(int i=0;i<updateList.size();i++){ upList[i] = updateList.get(i); } //todo 去掉 CabinetGridDo gridDo = oldMap.get("0101"); if(gridDo!=null){ EventBus.getDefault().post(new HttpEvent(StringUtil.DateToStrSS(new Date())+"=================>更新数据当前钥匙2:"+gridDo.getCurKeyCode())); } DaoManager.getCabinetGridDao().update(upList); } @@ -359,7 +354,7 @@ } if(isShowOpenTip){ if(openTipDownCount==0){ doRegister(9,null); getVM().doAction(9); }else { openTipDownCount--; getDB().tvClKmClose.setText(openTipDownCount+"s 自动关闭"); keyCabinet-android/app/src/main/java/com/doumee/keyCabinet/ui/main/MainActivity.java
@@ -10,6 +10,7 @@ import android.graphics.drawable.BitmapDrawable; import android.hardware.Camera; import android.opengl.Visibility; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Message; @@ -210,12 +211,12 @@ getDB().setModel(getVM()); initRGBCheck(); handler.sendEmptyMessageDelayed(0, 1000); //启动心跳 /*//启动心跳 Intent intent = new Intent(MainActivity.this, HeartbeatService.class); startService(intent); //启动更新人脸 Intent intent2 = new Intent(MainActivity.this, FaceUpdateService.class); startService(intent2); startService(intent2);*/ getPermission(); Timber.tag("====>").d(LMobileInfo.getDeviceUniqueId()); } @@ -229,10 +230,10 @@ long availableMemory = memoryInfo.availMem/(1024*1024); long usedMemory = totalMemory - availableMemory; //getDB().tvM.setText("总内存:"+totalMemory+",使用内存:"+usedMemory+",可用内存:"+availableMemory); if((availableMemory<400&&showTime!=null&&(System.currentTimeMillis()-showTime>5000))|| if((availableMemory<100&&showTime!=null&&(System.currentTimeMillis()-showTime>5000))|| ("02:00:00".equals(StringUtil.getHM()))){ //可用内存小于400M,或者每天凌晨2点,重启app //restartApp(); restartApp(); } } @@ -316,14 +317,15 @@ getDB().imgLeft.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { public void onClick(View v1) { //todo 临时代码 if (getDB().nsv.getVisibility()== View.VISIBLE) { getDB().nsv.setVisibility(View.GONE); }else { getDB().nsv.setVisibility(View.VISIBLE); } YNHAPI mAPI = YNHAPI.getInstance(); mAPI.setNavigationBarVisibility(YNHAPI.NavigationBarVisibility.VISIBLE); } }); upErrInfo(); @@ -470,6 +472,7 @@ isShowing = true; YNHAPI mAPI = YNHAPI.getInstance(); mAPI.setNavigationBarVisibility(YNHAPI.NavigationBarVisibility.ALWAYS_INVISIBLE); mAPI.setBootLaunchApk("com.doumee.keyCabinet", true); showTime = System.currentTimeMillis(); if(!isFaceOk) { initLicense(); @@ -1174,6 +1177,8 @@ //定时拉取基本信息 getVM().devLogin(); getPermission(); getVM().devHeart(); EventBus.getDefault().post(new GetFacesEvent()); }else { loopDownCount--; } @@ -1375,7 +1380,7 @@ EventBus.getDefault().post(new CloseGridOneResultEvent(key,"00".equals(open)?1:0)); if(isShowing&&isShowTip){ //修改显示提醒 doRegister(5,null); getVM().doAction(5); } }else if(data.startsWith("80")){ //查询所有门状态 @@ -1470,7 +1475,7 @@ keyPreviousData = data; }else if(data.startsWith("CC02")){ runOnUiThread(() -> { //getVM().addInfo("获取到钥匙数据:" + data); getVM().addInfo("获取到钥匙数据:" + data); jxKey(data); }); keyPreviousData = null; @@ -1478,7 +1483,7 @@ if(!TextUtils.isEmpty(keyPreviousData)){ String data2 = keyPreviousData+data; runOnUiThread(() -> { //getVM().addInfo("获取到钥匙数据:" + data2); getVM().addInfo("获取到钥匙数据:" + data2); if(data2.contains("CC01")&&data2.contains("CC02")){ String[] sp = data2.split("CC02"); if(sp.length==2){ @@ -1538,12 +1543,6 @@ updateList.add(gridDo); } } } //todo 去掉 CabinetGridDo gridDo = oldMap.get("0101"); if(gridDo!=null) { EventBus.getDefault().post(new HttpEvent(StringUtil.DateToStrSS(new Date())+ "=================>更新数据当前钥匙7:" + gridDo.getCurKeyCode())); } getVM().updateGrids(updateList); @@ -1748,15 +1747,15 @@ private boolean isInitPort; //初始化串口 private void initPort(){ SpUtil.setString("port_grid","/dev/ttyS7"); SpUtil.setString("port_key","/dev/ttyS1"); SpUtil.setString("port_jiu","/dev/ttyS2"); //SpUtil.setString("port_grid","/dev/ttyS7"); //SpUtil.setString("port_key","/dev/ttyS1"); //SpUtil.setString("port_jiu","/dev/ttyS2"); gridPath = SpUtil.getString("port_grid"); //getVM().addInfo("门串口链接:"+gridPath); getVM().addInfo("门串口链接:"+gridPath); keyPath = SpUtil.getString("port_key"); //getVM().addInfo("钥匙串口链接:"+keyPath); getVM().addInfo("钥匙串口链接:"+keyPath); jiuPath = SpUtil.getString("port_jiu"); //getVM().addInfo("酒精串口链接:"+jiuPath); getVM().addInfo("酒精串口链接:"+jiuPath); if(!TextUtils.isEmpty(SpUtil.getString("port_grid"))&& !TextUtils.isEmpty(SpUtil.getString("port_key"))&& !TextUtils.isEmpty(SpUtil.getString("port_jiu"))){ keyCabinet-android/app/src/main/java/com/doumee/keyCabinet/ui/main/MainVM.java
@@ -71,7 +71,6 @@ public void devLogin(){ //清除登录信息 MApplication.saveConfigBean(new DevConfigBean()); EventBus.getDefault().post(new HttpEvent("获取钥匙柜基本信息-请求")); getRetrofitService(Apis.class).getCabinetInfoForDriver(LMobileInfo.getDeviceUniqueId()) .compose(RxUtils.schedulersTransformer()) @@ -89,6 +88,7 @@ toast(MApplication.mContext.getString(R.string.guide_toast_1)); } }else { MApplication.saveConfigBean(new DevConfigBean()); toast(response.getMessage()); } } @@ -156,12 +156,6 @@ } if(addList.size()>0){ DaoManager.getCabinetGridDao().insert(addList); } //todo 去掉 CabinetGridDo gridDo = oldMap.get("0101"); if(gridDo!=null){ EventBus.getDefault().post(new HttpEvent(StringUtil.DateToStrSS(new Date())+"=================>更新数据当前钥匙1:"+gridDo.getCurKeyCode())); } if(updateList.size()>0){ @@ -330,7 +324,7 @@ .subscribe(new SimpleObserver<BaseResponse>(rxJavaGcManager) { @Override public void onNext(@NonNull BaseResponse response) { toast("关门接口调用成功"); } @Override keyCabinet-android/app/src/main/java/com/doumee/keyCabinet/utils/CrashHandler.java
@@ -14,6 +14,7 @@ import com.doumee.keyCabinet.ui.guide.GuideActivity; import com.doumee.keyCabinet.ui.main.MainActivity; import com.doumee.lib_coremodel.util.SpUtil; import com.innohi.YNHAPI; import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; @@ -86,22 +87,30 @@ public void uncaughtException(Thread thread, Throwable ex) { try { //导出异常信息到SD卡中 YNHAPI mAPI = YNHAPI.getInstance(); mAPI.setNavigationBarVisibility(YNHAPI.NavigationBarVisibility.VISIBLE); dumpExceptionToSDCard(ex); //System.out.println("重启应用"); // 创建一个新的启动意图 /*Intent intent = new Intent(mContext, MainActivity.class); // 设置FLAG_ACTIVITY_CLEAR_TASK标志位 intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); // 使用PendingIntent包装启动意图 PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_ONE_SHOT); // 获取AlarmManager实例 AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); // 在500毫秒后触发重启操作 alarmManager.set(AlarmManager.RTC, System.currentTimeMillis() + 10, pendingIntent); long time = SpUtil.getLong("err_app"); SpUtil.saveLong("err_app",System.currentTimeMillis()); if(System.currentTimeMillis()-time>60000){ //报错间隔60秒,才重启 //System.out.println("重启应用"); // 创建一个新的启动意图 Intent intent = new Intent(mContext, MainActivity.class); // 设置FLAG_ACTIVITY_CLEAR_TASK标志位 intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); // 使用PendingIntent包装启动意图 PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_ONE_SHOT); // 获取AlarmManager实例 AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); // 在500毫秒后触发重启操作 alarmManager.set(AlarmManager.RTC, System.currentTimeMillis() + 10, pendingIntent); android.os.Process.killProcess(android.os.Process.myPid()); System.exit(1);*/ android.os.Process.killProcess(android.os.Process.myPid()); System.exit(1); } //这里可以通过网络上传异常信息到服务器,便于开发人员分析日志从而解决bug } catch (IOException e) { e.printStackTrace(); System.out.println("错误日志1"+e.getMessage()); @@ -263,7 +272,7 @@ dumpPhoneInfo(print); print.println(); ex.printStackTrace(print); SpUtil.saveString(FILE_NAME+time,new String(out.toByteArray())); //SpUtil.saveString(FILE_NAME+time,new String(out.toByteArray())); print.close(); } catch (Exception e) { e.printStackTrace(); keyCabinet-android/app/src/main/java/com/doumee/keyCabinet/utils/face/FaceSDKManager.java
@@ -66,7 +66,7 @@ } return; } // todo 增加判空处理 if (listener != null) { listener.initStart(); } keyCabinet-android/app/src/main/java/com/doumee/keyCabinet/utils/update/UpdateDialog.java
@@ -55,7 +55,7 @@ } } }); getWritePermision(); //getWritePermision(); } public void setOnOtemListener(UpdialogListener lister) { keyCabinet-android/app/src/main/java/com/doumee/keyCabinet/utils/update/UpdateUtil.java
@@ -153,8 +153,8 @@ @Override public void setOnclickUpdate() { //updateDialog.hide(); /*downloadDialog = new DownloadDialog(activity, upgradeurl); updateDialog.hide(); downloadDialog = new DownloadDialog(activity, upgradeurl); downloadDialog.show(); downloadDialog.setCanceledOnTouchOutside(false); downloadDialog.setUpdateDialog(updateDialog); @@ -171,7 +171,7 @@ } return false; } });*/ }); } @Override keyCabinet-android/app/src/main/res/layout/face_activity.xml
@@ -702,10 +702,10 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/shape_jiujin_ok" android:paddingLeft="80dp" android:paddingRight="80dp" android:paddingTop="50dp" android:paddingBottom="50dp" android:paddingLeft="60dp" android:paddingRight="60dp" android:paddingTop="40dp" android:paddingBottom="40dp" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -714,8 +714,8 @@ <pl.droidsonroids.gif.GifImageView android:id="@+id/img_progress" android:layout_width="150dp" android:layout_height="150dp" android:layout_width="90dp" android:layout_height="90dp" android:src="@mipmap/zhuanquan" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" keyCabinet-android/app/src/main/res/layout/main_activity.xml
@@ -22,21 +22,6 @@ app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent"/> <TextView android:id="@+id/tv_m" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="内存" android:textSize="30sp" android:textColor="@color/white" android:gravity="center" app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent" android:paddingLeft="0dp" android:paddingRight="10dp" android:visibility="gone" /> <com.facebook.drawee.view.SimpleDraweeView android:id="@+id/img1" android:layout_width="match_parent" @@ -420,5 +405,20 @@ app:layout_constraintStart_toStartOf="parent" /> <TextView android:id="@+id/tv_m" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" android:textSize="30sp" android:textColor="@color/black" android:gravity="center" app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent" android:paddingLeft="0dp" android:paddingRight="10dp" android:visibility="gone" /> </androidx.constraintlayout.widget.ConstraintLayout> </layout> keyCabinet-android/app/src/main/res/layout/manage_login_activity.xml
@@ -88,7 +88,7 @@ android:layout_width="0dp" android:layout_height="75dp" android:background="@null" android:text="18656077929" android:text="" android:textColor="#111111" android:hint="请输入登录账号" android:textColorHint="#999999" @@ -138,7 +138,7 @@ android:layout_width="0dp" android:layout_height="75dp" android:background="@null" android:text="Whyc2025" android:text="" android:hint="请输入账号密码" android:textColorHint="#999999" android:textSize="24sp" keyCabinet-android/lib_coremodel/src/main/java/com/doumee/lib_coremodel/util/SpUtil.java
@@ -104,6 +104,16 @@ return getSharedPreferences().getInt(key, 0); } public static void saveLong(String key, Long value){ SharedPreferences.Editor editor = getSharedPreferences().edit(); editor.putLong(key, value); editor.commit(); } public static Long getLong(String key){ return getSharedPreferences().getLong(key, 0L); } public static boolean getBoolean(String key){ return getSharedPreferences().getBoolean(key, false); }