Skip to content

Commit

Permalink
-Android notification is now mandatory and displays messages from oth…
Browse files Browse the repository at this point in the history
…er monitors e.g. user Receives alerts that MQTT is down or Mongo credentials are incorrect.

-Detailed exception handling around G4 IO errors
-Added a new condition to handle mongo not connected
  • Loading branch information
ktind committed Sep 14, 2014
1 parent d11f963 commit 158ca44
Show file tree
Hide file tree
Showing 31 changed files with 908 additions and 884 deletions.
2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.ktind.cgm.bgscout"
minSdkVersion 16
targetSdkVersion 20
versionCode 9
versionName "0.0.9"
versionCode 10
versionName "0.1.1"
}
buildTypes {
release {
Expand All @@ -27,8 +27,8 @@ dependencies {
compile files('libs/protobuf-java-2.5.0.jar')
compile files('libs/acra-4.5.0.jar')
compile 'com.google.android.gms:play-services-wearable:5.0.77'
compile 'com.android.support:support-v4:20.0.0'
compile 'com.android.support:support-v4:20.0.+'
compile 'com.google.code.gson:gson:2.3'
compile 'com.android.support:support-v13:20.0.0'
compile project(':pEBBLE_KIT')
compile project(':PEBBLE_KIT')
}
9 changes: 5 additions & 4 deletions mobile/mobile.iml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugJava" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
Expand Down Expand Up @@ -42,22 +43,22 @@
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
Expand Down Expand Up @@ -94,7 +95,7 @@
<orderEntry type="library" exported="" name="mongo-java-driver-2.12.3" level="project" />
<orderEntry type="library" exported="" name="acra-4.5.0" level="project" />
<orderEntry type="library" exported="" name="gson-2.3" level="project" />
<orderEntry type="module" module-name="pEBBLE_KIT" exported="" />
<orderEntry type="module" module-name="PEBBLE_KIT" exported="" />
</component>
</module>

41 changes: 8 additions & 33 deletions mobile/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

<application
android:name=".BGScout"
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
android:theme="@style/AppTheme"
android:allowBackup="true" >
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.gms.analytics.globalConfigResource"
Expand All @@ -34,42 +34,19 @@
</service>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop" >
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
</intent-filter>

<meta-data
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/device_filter" />


android:launchMode="singleInstance" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="com.ktind.cgm.DEVICE_POLL" />
</intent-filter>
<intent-filter>
<action android:name="com.ktind.cgm.MQTT_KEEPALIVE" />
</intent-filter>
<intent-filter>
<action android:name="com.ktind.cgm.MQTT_RECONNECT" />
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
</intent-filter>
<meta-data
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/device_filter" />
</activity>
<!--<activity-->
<!--android:name=".DeviceActivity"-->
<!--android:label="@string/title_activity_device"-->
<!--android:launchMode="singleTop">-->
<!--<intent-filter>-->
<!--<action android:name="android.intent.action.MAIN" />-->

<!--<category android:name="android.intent.category.LAUNCHER" />-->
<!--</intent-filter>-->
<!--</activity>-->
<activity
android:name=".SettingsActivity"
android:label="@string/title_activity_settings"
Expand All @@ -78,7 +55,5 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="com.ktind.cgm.bgscout.MainActivity" />
</activity>

</application>

</manifest>
27 changes: 18 additions & 9 deletions mobile/src/main/java/com/ktind/cgm/bgscout/AbstractDevice.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ public void start(){
monitors.add(new PebbleMonitor(getName(),deviceID, getContext()));
}

if (sharedPref.getBoolean(deviceIDStr + "_android_monitor", false)) {
Log.i(TAG, "Adding a local android monitor");
mon = new AndroidNotificationMonitor(getName(), deviceID, getContext());
if (phoneNum!=null) {
((AndroidNotificationMonitor) mon).setPhoneNum(phoneNum);
}
monitors.add(mon);
}
// if (sharedPref.getBoolean(deviceIDStr + "_android_monitor", false)) {
// Log.i(TAG, "Adding a local android monitor");
// mon = new AndroidNotificationMonitor(getName(), deviceID, getContext());
// if (phoneNum!=null) {
// ((AndroidNotificationMonitor) mon).setPhoneNum(phoneNum);
// }
// monitors.add(mon);
// }
if (!isRemote()) {
if (sharedPref.getBoolean(deviceIDStr + "_mongo_upload", false)) {
Log.i(TAG, "Adding a mongo upload monitor");
Expand All @@ -136,6 +136,16 @@ public void start(){
} else {
Log.i(TAG, "Ignoring monitors that do not allow remote devices");
}
// mon=new WearMonitor(getName(),deviceID,getContext());
// monitors.add(mon);

// TODO Remove option since it longer does anything
Log.i(TAG, "Adding a local android monitor");
mon = new AndroidNotificationMonitor(getName(), deviceID, getContext());
if (phoneNum!=null) {
((AndroidNotificationMonitor) mon).setPhoneNum(phoneNum);
}
monitors.add(mon);
Log.d(TAG, "Number of monitors created: " + monitors.size());
started=true;
IntentFilter intentFilter=new IntentFilter(Constants.UIDO_QUERY);
Expand Down Expand Up @@ -198,7 +208,6 @@ public void setUnit(GlucoseUnit unit) {
public void fireMonitors(DownloadObject dl) {
stats.startMonitorTimer();
Log.d(TAG,"Firing monitors");
// FIXME why is monitors set to null here sometimes?
if (monitors==null)
return;
for (AbstractMonitor monitor:monitors)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ final public void process(DownloadObject d) {
if (isAllowVirtual() || ! d.isRemoteDevice()){
lastSuccessDate=sharedPref.getLong("last_"+deviceIDStr+"_"+monitorType,new Date().getTime()-900000L);
Log.d(TAG, "Trimming data for monitor "+name+"/"+monitorType);
final DownloadObject dl=new DownloadObject(d);
final AnalyzedDownload dl=new AnalyzedDownload(d);
dl.setEgvRecords(trimReadingsAfter(getlastSuccessDate(), d.getEgvArrayListRecords()));
Log.d(TAG, "Processing monitor "+name+" for "+monitorType);
new Thread(new Runnable() {
Expand Down
Loading

0 comments on commit 158ca44

Please sign in to comment.