return "ICL02WorkService"
}
-
android {
def currentVersionCode = getVersionCode()
# 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
<?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" />
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;
private WorkServiceApp mApp;
+ private MessengerCoreService coreService;
+
@Override
public IBinder onBind(Intent intent) {
if (intent != null) {
registerBroadcast();
+ coreService = new MessengerCoreService();
+ coreService.bindCoreService(getApplicationContext());
+
IcLog.i(TAG, "work service is start");
}
EventBus.getDefault().unregister(this);
unregisterReceiver(mIntentReceiver);
+
+ if(coreService != null){
+ coreService.onUnBindCoreService(getApplicationContext());
+ coreService=null;
+ }
}
@Subscribe(threadMode = ThreadMode.MAIN)
event.getLow(), event.getHeart());
}
+ if(coreService != null){
+ coreService.sendBloodValueMessage(event.getHigh(),event.getLow(),event.getHeart());
+ }
+
//发送一次广播给 心率 launcher
sendHeartBroadcast(event.getHeart());
}
sendBroadcast(pedIntent);
}
- private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
+ private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent != null) {
HardwareUtils.onNdkDisablePPG();
} catch (InterruptedException e) {
- IcLog.e(TAG, "Stop Get Heart Value");
+ IcLog.e(TAG, "Stop Get Heart Value",e);
}finally {
HardwareUtils.onNdkDisablePPG();
}
--- /dev/null
+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);
+ }
+ }
+ }
+}
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);
}
}
}
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);
}
}
}
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);
}
}
}
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);
}
}
}
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);
}
}
}
try {
return ICJniUtils.isPPGavailable() == 0;
} catch (Exception e) {
- IcLog.e(TAG, e.getMessage());
+ IcLog.e(TAG, "",e);
return true;
}
}
try {
ICJniUtils.enablePPG();
} catch (Exception e) {
- IcLog.e(TAG, e.getMessage());
+ IcLog.e(TAG, "",e);
}
}
try {
ICJniUtils.disablePPG();
} catch (Exception e) {
- IcLog.e(TAG, e.getMessage());
+ IcLog.e(TAG, "",e);
}
}
try {
return ICJniUtils.isWeared() == 0;
} catch (Exception e) {
- IcLog.e(TAG, e.getMessage());
+ IcLog.e(TAG, "",e);
return true;
}
}
try {
return ICJniUtils.getPPG();
} catch (Exception e) {
- IcLog.e(TAG, e.getMessage());
+ IcLog.e(TAG, "",e);
return 0;
}
}
try {
return ICJniUtils.getHighBloodPressure();
} catch (Exception e) {
- IcLog.e(TAG, e.getMessage());
+ IcLog.e(TAG, "",e);
return 0;
}
}
try {
return ICJniUtils.getLowBloodPressure();
} catch (Exception e) {
- IcLog.e(TAG, e.getMessage());
+ IcLog.e(TAG,"",e);
return 0;
}
}
try {
return ICJniUtils.getStepCount();
} catch (Exception e) {
- IcLog.e(TAG, e.getMessage());
+ IcLog.e(TAG, "",e);
return 0;
}
}
try {
return ICJniUtils.resetStepCount();
} catch (Exception e) {
- IcLog.e(TAG, e.getMessage());
+ IcLog.e(TAG, "",e);
return 0;
}
}
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) {
}
}
- 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;
}
//定位失败时,可通过ErrCode(错误码)信息来确定失败的原因,errInfo是错误信息,详见错误码表。
IcLog.e(TAG, "location Error, ErrCode:"
+ aMapLocation.getErrorCode() + ", errInfo:"
- + aMapLocation.getErrorInfo());
+ + aMapLocation.getErrorInfo(),null);
EventBus.getDefault().post(new LocationResultEvent(""));
}
}
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
-#Mon Mar 23 18:58:17 CST 2020
-VERSION_CODE=11
+#Tue Mar 24 18:46:07 CST 2020
+VERSION_CODE=13