Skip to content
Snippets Groups Projects
Commit 9dcbf1ca authored by Lennart Goedhart's avatar Lennart Goedhart Committed by GitHub
Browse files

Merge pull request #89 from volkerrichert/master

moving permission to the right place. THX @pogman
parents 902690f4 646ca355
No related branches found
No related tags found
No related merge requests found
...@@ -18,6 +18,9 @@ ...@@ -18,6 +18,9 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.USB_PERMISSION" /> <uses-permission android:name="android.permission.USB_PERMISSION" />
<!-- allow to disable battery optimization -->
<uses-permission-sdk-23 android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<application <application
android:name=".UploaderApplication" android:name=".UploaderApplication"
android:allowBackup="true" android:allowBackup="true"
...@@ -26,8 +29,6 @@ ...@@ -26,8 +29,6 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<!-- allow to disable battery optimization -->
<uses-permission-sdk-23 android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<!-- I have set screenOrientation to "portrait" to avoid the restart of AsyncTasks when you rotate the phone --> <!-- I have set screenOrientation to "portrait" to avoid the restart of AsyncTasks when you rotate the phone -->
<activity <activity
......
...@@ -10,6 +10,8 @@ import android.preference.PreferenceManager; ...@@ -10,6 +10,8 @@ import android.preference.PreferenceManager;
import android.support.v4.content.LocalBroadcastManager; import android.support.v4.content.LocalBroadcastManager;
import android.util.Log; import android.util.Log;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.ResponseHandler; import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity; import org.apache.http.entity.StringEntity;
...@@ -169,22 +171,22 @@ public class NightscoutUploadIntentService extends IntentService { ...@@ -169,22 +171,22 @@ public class NightscoutUploadIntentService extends IntentService {
addMbgEntry(entriesBody, record); addMbgEntry(entriesBody, record);
} }
uploadToNightscout(new URL(baseURL + "/entries"), secret, entriesBody); boolean isUploaded = uploadToNightscout(new URL(baseURL + "/entries"), secret, entriesBody);
for(int i = 0; i < devicestatusBody.length(); i++) { for(int i = 0; isUploaded && i < devicestatusBody.length(); i++) {
uploadToNightscout(new URL(baseURL + "/devicestatus"), secret, devicestatusBody.getJSONObject(i)); isUploaded &= uploadToNightscout(new URL(baseURL + "/devicestatus"), secret, devicestatusBody.getJSONObject(i));
} }
// Yay! We uploaded. Tell Realm if (isUploaded) {
// FIXME - check the upload succeeded! // Yay! We uploaded. Tell Realm
mRealm.beginTransaction(); // FIXME - check the upload succeeded!
mRealm.beginTransaction();
for (PumpStatusEvent updateRecord : records) { for (PumpStatusEvent updateRecord : records) {
updateRecord.setUploaded(true); updateRecord.setUploaded(true);
}
mRealm.commitTransaction();
} }
mRealm.commitTransaction();
} catch (Exception e) { } catch (Exception e) {
Log.e(TAG, "Unable to post data", e); Log.e(TAG, "Unable to post data", e);
} }
...@@ -236,6 +238,7 @@ public class NightscoutUploadIntentService extends IntentService { ...@@ -236,6 +238,7 @@ public class NightscoutUploadIntentService extends IntentService {
httpclient.execute(post, responseHandler); httpclient.execute(post, responseHandler);
} catch (Exception e) { } catch (Exception e) {
Log.w(TAG, "Unable to post data to: '" + post.getURI().toString() + "'", e); Log.w(TAG, "Unable to post data to: '" + post.getURI().toString() + "'", e);
return false;
} }
return true; return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment