|
@@ -0,0 +1,141 @@
|
|
|
+package com.wdkl.app.ncs.callingbed.hardware.imp;
|
|
|
+
|
|
|
+import android.app.Application;
|
|
|
+import android.content.Context;
|
|
|
+import android.content.pm.PackageInfo;
|
|
|
+import android.content.pm.PackageManager;
|
|
|
+import android.util.Log;
|
|
|
+
|
|
|
+import com.wdkl.app.ncs.callingbed.activity.AppUpdateActivity;
|
|
|
+import com.wdkl.app.ncs.callingbed.activity.CallingbedActivity;
|
|
|
+import com.wdkl.app.ncs.callingbed.hardware.HardTools;
|
|
|
+import com.wdkl.app.ncs.callingbed.helper.AppUpdateHelper;
|
|
|
+import com.wdkl.app.ncs.callingbed.helper.NetHelper;
|
|
|
+import com.wdkl.app.ncs.callingbed.helper.SOSHelper;
|
|
|
+import com.wdkl.app.ncs.callingbed.helper.SerialPortHelper;
|
|
|
+import com.wdkl.ncs.android.middleware.common.Constant;
|
|
|
+import com.wdkl.ncs.android.middleware.utils.AppUtil;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import serialporttest.utils.SerialPortUtil;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Z-3128硬件控制类
|
|
|
+ *
|
|
|
+ * */
|
|
|
+public class YldHardTools extends HardTools {
|
|
|
+
|
|
|
+ public static final String HARDWDT_SERVICE = "Z3128HardTools";
|
|
|
+ private Application app;
|
|
|
+
|
|
|
+
|
|
|
+ private static class YldHardToolsHolder{
|
|
|
+ private final static YldHardTools yldHardTools = new YldHardTools();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static YldHardTools getInstance(){
|
|
|
+ return YldHardToolsHolder.yldHardTools;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void init() {
|
|
|
+ SerialPortUtil.getInstance().openSerialPortYld();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void unInit() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void resetDevice() {
|
|
|
+
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void resetDevicex(Application application) {
|
|
|
+ AppUpdateHelper.reboot(application);
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void Registration(Context context) {
|
|
|
+ //获取mac地址
|
|
|
+ Constant.LOCAL_MAC = NetHelper.getInstance().getIMEI();
|
|
|
+ Constant.DEVICE_REGISTER_ID = Constant.LOCAL_MAC;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setSerial(CallingbedActivity callingbedActivity) {
|
|
|
+ try {
|
|
|
+ Thread.sleep(1500); // 延时1500毫秒 (1.5秒)
|
|
|
+
|
|
|
+ SerialPortHelper.setSosLight("0");
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void uninstallApp(Context context, boolean isuninstall, String name) {
|
|
|
+ //卸载原来二代系统apk
|
|
|
+ if (isuninstall) {
|
|
|
+ Thread thread = new Thread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ // 在子线程中执行的代码
|
|
|
+ if (checkAppExist(context,name)) {
|
|
|
+ AppUtil.uninstallApp(name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setSOSStart() {
|
|
|
+ SOSHelper.sosStart();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setSOSStop() {
|
|
|
+ SOSHelper.sosStop();
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void setDoorLight(int type) {
|
|
|
+ if (type==1){
|
|
|
+ //绿色
|
|
|
+ SerialPortHelper.setDoorLight(1, Constant.nursingColor);
|
|
|
+ }else if (type==2){
|
|
|
+ //白色
|
|
|
+ SerialPortHelper.setDoorLight(1, "111"); //白色
|
|
|
+ }else if (type==3){
|
|
|
+ //红色
|
|
|
+ SerialPortHelper.setDoorLight(1, "200"); //红色闪烁
|
|
|
+ }else if (type==4){
|
|
|
+ //红色
|
|
|
+ SerialPortHelper.setDoorLight(0, "000"); //关闭
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void installApk(AppUpdateActivity context) {
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void startInstallApk(AppUpdateActivity context) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean checkAppExist(Context context, String name) {
|
|
|
+ PackageManager packageManager = context.getPackageManager();
|
|
|
+ List<PackageInfo> packageInfoList = packageManager.getInstalledPackages(0);
|
|
|
+ boolean appExist = false;
|
|
|
+ for (PackageInfo pInfo : packageInfoList) {
|
|
|
+ if (name.equals(pInfo.packageName)) {
|
|
|
+ appExist = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Log.e("wdkl_app", "callingdoor app exist: " + appExist);
|
|
|
+ return appExist;
|
|
|
+ }
|
|
|
+}
|