1.修改IcLog e的输出。
authorkfl_614 <kfl_614@163.com>
Tue, 24 Mar 2020 10:48:06 +0000 (18:48 +0800)
committerkfl_614 <kfl_614@163.com>
Tue, 24 Mar 2020 10:48:06 +0000 (18:48 +0800)
2.添加血压测量后。往后台传数据

14 files changed:
app/build.gradle
app/proguard-rules.pro
app/src/main/AndroidManifest.xml
app/src/main/java/com/ic/work/WorkService.java
app/src/main/java/com/ic/work/hardware/BloodRunnable.java
app/src/main/java/com/ic/work/hardware/MessengerCoreService.java [new file with mode: 0644]
app/src/main/java/com/ic/work/process/BloodProcess.java
app/src/main/java/com/ic/work/process/PedProcess.java
app/src/main/java/com/ic/work/process/WeatherProcess.java
app/src/main/java/com/ic/work/utils/HardwareUtils.java
app/src/main/java/com/ic/work/utils/IcLog.java
app/src/main/java/com/ic/work/weather/LocationHelper.java
app/src/main/res/layout/activity_main.xml
app/version_code.properties

index b5fb414..1348432 100644 (file)
@@ -4,7 +4,6 @@ static def getL02ApkBaseName() {
     return "ICL02WorkService"
 }
 
-
 android {
 
     def currentVersionCode = getVersionCode()
index 9ff9d79..7ca457d 100644 (file)
@@ -162,4 +162,6 @@ public protected <methods>;
 # And if you use AsyncExecutor:
 -keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
     <init>(java.lang.Throwable);
-}
\ No newline at end of file
+}
+
+-keep class com.mapbox.mapboxsdk.**{ *; }
\ No newline at end of file
index 53673ad..41cf9f9 100644 (file)
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="com.ic.work">
+    package="com.ic.work"
+    android:sharedUserId="android.uid.system">
 
     <!-- 这个权限用于进行网络定位-->
     <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
index dd9e582..d51da3b 100644 (file)
@@ -16,6 +16,7 @@ import com.ic.work.event.PedRecordResultEvent;
 import com.ic.work.event.PedSettingEvent;
 import com.ic.work.event.WeatherAgainEvent;
 import com.ic.work.event.WeatherResultEvent;
+import com.ic.work.hardware.MessengerCoreService;
 import com.ic.work.process.BloodProcess;
 import com.ic.work.process.PedProcess;
 import com.ic.work.process.WeatherProcess;
@@ -44,6 +45,8 @@ public class WorkService extends Service {
 
     private WorkServiceApp mApp;
 
+    private MessengerCoreService  coreService;
+
     @Override
     public IBinder onBind(Intent intent) {
         if (intent != null) {
@@ -86,6 +89,9 @@ public class WorkService extends Service {
 
         registerBroadcast();
 
+        coreService = new MessengerCoreService();
+        coreService.bindCoreService(getApplicationContext());
+
         IcLog.i(TAG, "work service is start");
     }
 
@@ -105,6 +111,11 @@ public class WorkService extends Service {
         EventBus.getDefault().unregister(this);
 
         unregisterReceiver(mIntentReceiver);
+
+        if(coreService != null){
+            coreService.onUnBindCoreService(getApplicationContext());
+            coreService=null;
+        }
     }
 
     @Subscribe(threadMode = ThreadMode.MAIN)
@@ -127,6 +138,10 @@ public class WorkService extends Service {
                     event.getLow(), event.getHeart());
         }
 
+        if(coreService != null){
+            coreService.sendBloodValueMessage(event.getHigh(),event.getLow(),event.getHeart());
+        }
+
         //发送一次广播给 心率 launcher
         sendHeartBroadcast(event.getHeart());
     }
@@ -203,7 +218,7 @@ public class WorkService extends Service {
         sendBroadcast(pedIntent);
     }
 
-    private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
+    private  BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
         @Override
         public void onReceive(Context context, Intent intent) {
             if (intent != null) {
index 3486560..453557a 100644 (file)
@@ -70,7 +70,7 @@ public class BloodRunnable implements Runnable{
             HardwareUtils.onNdkDisablePPG();
 
         } catch (InterruptedException e) {
-            IcLog.e(TAG, "Stop Get Heart Value");
+            IcLog.e(TAG, "Stop Get Heart Value",e);
         }finally {
             HardwareUtils.onNdkDisablePPG();
         }
diff --git a/app/src/main/java/com/ic/work/hardware/MessengerCoreService.java b/app/src/main/java/com/ic/work/hardware/MessengerCoreService.java
new file mode 100644 (file)
index 0000000..c2f661c
--- /dev/null
@@ -0,0 +1,117 @@
+package com.ic.work.hardware;
+
+import android.annotation.SuppressLint;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.Message;
+import android.os.Messenger;
+import android.os.RemoteException;
+
+import com.ic.work.utils.IcLog;
+
+public class MessengerCoreService {
+
+    private final static String TAG = "MessengerCoreService";
+
+    private final static int RESULT_OK = 200;
+    private final static int RESULT_ERROR = 500;
+    private final static int MSG_WHAT_SEND_VOICE = 1001;
+
+    private final static int MSG_WHAT_PPG = 1007;
+    private final static String key_ppg = "ppg";
+    private final static String key_bph = "bph";
+    private final static String key_bpl = "bpl";
+
+    private Messenger mGetReplyMessenger;
+    private Messenger mService = null;
+
+    public void bindCoreService(Context context) {
+
+        if (mService != null) {
+            return;
+        }
+
+        ComponentName componentName = new ComponentName(
+                "com.enqualcomm.support",
+                "com.enqualcomm.support.CoreService");
+        Intent mIntent = new Intent().setComponent(componentName);
+        context.bindService(mIntent, mServiceConnection, Context.BIND_AUTO_CREATE);
+        mGetReplyMessenger = new Messenger(new MessageHandler());
+    }
+
+    public void onUnBindCoreService(Context context) {
+        context.unbindService(mServiceConnection);
+        mService = null;
+    }
+
+    private ServiceConnection mServiceConnection = new ServiceConnection() {
+        /**
+         * @param name
+         * @param service
+         */
+        @Override
+        public void onServiceConnected(ComponentName name, IBinder service) {
+            IcLog.i(TAG, "onServiceConnected");
+            mService = new Messenger(service);
+            Message msg = Message.obtain(null, MSG_WHAT_SEND_VOICE);
+           msg.replyTo = mGetReplyMessenger;
+            try {
+                mService.send(msg);
+            } catch (RemoteException e) {
+                IcLog.e(TAG, "onServiceConnected", e);
+            }
+        }
+
+        /**
+         * @param name
+         */
+        @Override
+        public void onServiceDisconnected(ComponentName name) {
+            mService = null;
+            IcLog.i(TAG, "onServiceDisconnected");
+
+        }
+    };
+
+    public void sendBloodValueMessage(int high, int low, int heart) {
+
+        Bundle data = new Bundle();
+
+        data.putString(key_ppg, String.valueOf(heart));
+        data.putString(key_bph, String.valueOf(high));
+        data.putString(key_bpl, String.valueOf(low));
+
+        Message msg = Message.obtain(null, MSG_WHAT_PPG);
+        msg.setData(data);
+        msg.replyTo = mGetReplyMessenger;
+        try {
+            if (mService != null)
+                mService.send(msg);
+        } catch (Exception e) {
+            IcLog.e(TAG, "sendBloodValueMessage", e);
+        }
+
+    }
+
+    @SuppressLint("HandlerLeak")
+    private class MessageHandler extends Handler {
+        @Override
+        public void handleMessage(Message msg) {
+            switch (msg.what) {
+                case RESULT_ERROR:
+                    IcLog.i(TAG, " PPG Data Send Error!");
+                    break;
+                case RESULT_OK:
+                    IcLog.i(TAG, " PPG Data Send Success!");
+                    break;
+                default:
+                    super.handleMessage(msg);
+            }
+        }
+    }
+}
index af88312..d51088d 100644 (file)
@@ -60,16 +60,16 @@ public class BloodProcess {
                 mCallbacks.getBroadcastItem(i).updateBloodCheckResult(heih, low, heart);
             }
         } catch (NullPointerException e) {
-            IcLog.e(TAG, e.getMessage());
+            IcLog.e(TAG, "",e);
         } catch (RemoteException er) {
-            IcLog.e(TAG, er.getMessage());
+            IcLog.e(TAG, "",er);
         } finally {
             try {
                 if (N > 0) {
                     mCallbacks.finishBroadcast();
                 }
             } catch (IllegalArgumentException ll) {
-                IcLog.e(TAG, ll.getMessage());
+                IcLog.e(TAG, "",ll);
             }
         }
     }
@@ -82,16 +82,16 @@ public class BloodProcess {
                 mCallbacks.getBroadcastItem(i).updateBloodCheckTips(top, bottom);
             }
         } catch (NullPointerException e) {
-            IcLog.e(TAG, e.getMessage());
+            IcLog.e(TAG, "",e);
         } catch (RemoteException er) {
-            IcLog.e(TAG, er.getMessage());
+            IcLog.e(TAG, "",er);
         } finally {
             try {
                 if (N > 0) {
                     mCallbacks.finishBroadcast();
                 }
             } catch (IllegalArgumentException ll) {
-                IcLog.e(TAG, ll.getMessage());
+                IcLog.e(TAG, "",ll);
             }
         }
     }
index 77738b2..5ea82ad 100644 (file)
@@ -92,16 +92,16 @@ public class PedProcess {
                 mCallbacks.getBroadcastItem(i).updatePedCount(count);
             }
         } catch (NullPointerException e) {
-            IcLog.e(TAG, e.getMessage());
+            IcLog.e(TAG, "",e);
         } catch (RemoteException er) {
-            IcLog.e(TAG, er.getMessage());
+            IcLog.e(TAG, "",er);
         } finally {
             try {
                 if (N > 0) {
                     mCallbacks.finishBroadcast();
                 }
             } catch (IllegalArgumentException ll) {
-                IcLog.e(TAG, ll.getMessage());
+                IcLog.e(TAG, "",ll);
             }
         }
     }
@@ -114,16 +114,16 @@ public class PedProcess {
                 mCallbacks.getBroadcastItem(i).updatePedRecord(record);
             }
         } catch (NullPointerException e) {
-            IcLog.e(TAG, e.getMessage());
+            IcLog.e(TAG, "",e);
         } catch (RemoteException er) {
-            IcLog.e(TAG, er.getMessage());
+            IcLog.e(TAG, "",er);
         } finally {
             try {
                 if (N > 0) {
                     mCallbacks.finishBroadcast();
                 }
             } catch (IllegalArgumentException ll) {
-                IcLog.e(TAG, ll.getMessage());
+                IcLog.e(TAG,"", ll);
             }
         }
     }
index 77058ff..c05e276 100644 (file)
@@ -57,16 +57,16 @@ public class WeatherProcess {
                 mCallbacks.getBroadcastItem(i).updateCurrWeather(parcelable);
             }
         } catch (NullPointerException e) {
-            IcLog.e(TAG, e.getMessage());
+            IcLog.e(TAG, "",e);
         } catch (RemoteException er) {
-            IcLog.e(TAG, er.getMessage());
+            IcLog.e(TAG, "",er);
         } finally {
             try {
                 if (N > 0) {
                     mCallbacks.finishBroadcast();
                 }
             } catch (IllegalArgumentException ll) {
-                IcLog.e(TAG, ll.getMessage());
+                IcLog.e(TAG, "",ll);
             }
         }
     }
index 13e029a..9bd06a9 100644 (file)
@@ -10,7 +10,7 @@ public class HardwareUtils {
         try {
             return ICJniUtils.isPPGavailable() == 0;
         } catch (Exception e) {
-            IcLog.e(TAG, e.getMessage());
+            IcLog.e(TAG, "",e);
             return true;
         }
     }
@@ -19,7 +19,7 @@ public class HardwareUtils {
         try {
             ICJniUtils.enablePPG();
         } catch (Exception e) {
-            IcLog.e(TAG, e.getMessage());
+            IcLog.e(TAG, "",e);
         }
     }
 
@@ -27,7 +27,7 @@ public class HardwareUtils {
         try {
             ICJniUtils.disablePPG();
         } catch (Exception e) {
-            IcLog.e(TAG, e.getMessage());
+            IcLog.e(TAG, "",e);
         }
     }
 
@@ -35,7 +35,7 @@ public class HardwareUtils {
         try {
             return ICJniUtils.isWeared() == 0;
         } catch (Exception e) {
-            IcLog.e(TAG, e.getMessage());
+            IcLog.e(TAG, "",e);
             return true;
         }
     }
@@ -44,7 +44,7 @@ public class HardwareUtils {
         try {
             return ICJniUtils.getPPG();
         } catch (Exception e) {
-            IcLog.e(TAG, e.getMessage());
+            IcLog.e(TAG, "",e);
             return 0;
         }
     }
@@ -53,7 +53,7 @@ public class HardwareUtils {
         try {
             return ICJniUtils.getHighBloodPressure();
         } catch (Exception e) {
-            IcLog.e(TAG, e.getMessage());
+            IcLog.e(TAG, "",e);
             return 0;
         }
     }
@@ -62,7 +62,7 @@ public class HardwareUtils {
         try {
             return ICJniUtils.getLowBloodPressure();
         } catch (Exception e) {
-            IcLog.e(TAG, e.getMessage());
+            IcLog.e(TAG,"",e);
             return 0;
         }
     }
@@ -71,7 +71,7 @@ public class HardwareUtils {
         try {
             return ICJniUtils.getStepCount();
         } catch (Exception e) {
-            IcLog.e(TAG, e.getMessage());
+            IcLog.e(TAG, "",e);
             return 0;
         }
     }
@@ -80,7 +80,7 @@ public class HardwareUtils {
         try {
             return ICJniUtils.resetStepCount();
         } catch (Exception e) {
-            IcLog.e(TAG, e.getMessage());
+            IcLog.e(TAG, "",e);
             return 0;
         }
     }
index ce8d0b9..3a51987 100644 (file)
@@ -12,7 +12,7 @@ import com.ic.work.BuildConfig;
 public class IcLog {
 
     private static final String DOT = ".";
-    private static boolean isDebug = true;
+    private static boolean isDebug = BuildConfig.DEBUG;
     private static String tagHead = "";
 
     public static void v(String tag, String msg) {
@@ -39,12 +39,13 @@ public class IcLog {
         }
     }
 
-    public static void e(String tag, String msg) {
+    public static void e(String tag,  String msg,Throwable e) {
         if (isDebug) {
-            Log.e(mergeHeadTag(tag), msg);
+            Log.e(mergeHeadTag(tag), msg,e);
         }
     }
 
+
     public static void setDebug(boolean debug) {
         isDebug = debug;
     }
index 250369c..3d5765a 100644 (file)
@@ -28,7 +28,7 @@ public class LocationHelper {
                     //定位失败时,可通过ErrCode(错误码)信息来确定失败的原因,errInfo是错误信息,详见错误码表。
                     IcLog.e(TAG, "location Error, ErrCode:"
                             + aMapLocation.getErrorCode() + ", errInfo:"
-                            + aMapLocation.getErrorInfo());
+                            + aMapLocation.getErrorInfo(),null);
                     EventBus.getDefault().post(new LocationResultEvent(""));
                 }
             }
index 20a7f50..6e79ec6 100644 (file)
         android:text="启动服务"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintHorizontal_bias="0.498"
         app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toTopOf="parent" />
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintVertical_bias="0.274" />
+
+    <Button
+        android:id="@+id/start_service_bttt"
+        android:layout_width="140dp"
+        android:layout_height="80dp"
+        android:text="fffffff"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/start_service_bt" />
 </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
index f9789d8..8ee6a5b 100644 (file)
@@ -1,2 +1,2 @@
-#Mon Mar 23 18:58:17 CST 2020
-VERSION_CODE=11
+#Tue Mar 24 18:46:07 CST 2020
+VERSION_CODE=13