1
0
mirror of https://github.com/nerzhul/ownCloud-SMS-App.git synced 2026-08-20 12:52:59 +00:00

Don't let Java choose when cleaning SmsBuffer, do it ourself

This commit is contained in:
Loic Blot
2017-08-23 22:59:43 +02:00
committed by Loïc Blot
parent 5e6a1fc28e
commit 11bbed02b8
5 changed files with 21 additions and 6 deletions
@@ -60,6 +60,7 @@ public interface ASyncSMSSync {
}
}
OCSMSNotificationUI.cancel(_context);
_smsBuffer.clear();
Log.i(ASyncSMSSync.TAG, "Stopping background sync");
return null;
}
@@ -175,6 +175,7 @@ public class OCSMSOwnCloudClient {
}
doHttpRequest(post);
if (_jsonQueryBuffer == null) {
Log.e(OCSMSOwnCloudClient.TAG,"Request failed. It doesn't return a valid JSON Object");
throw new OCSyncException(R.string.err_sync_push_request, OCSyncErrorType.IO);
@@ -24,13 +24,14 @@ public class SmsBuffer {
private long mHandle;
String TAG = SmsBuffer.class.getSimpleName();
public SmsBuffer() {
mHandle = SmsBuffer.createNativeObject();
}
protected void finalize() throws Throwable {
SmsBuffer.deleteNativeObject(mHandle);
mHandle = 0;
clear();
super.finalize();
}
@@ -45,9 +46,21 @@ public class SmsBuffer {
public void push(int id, int mbid, int type, long date, String address, String body,
String read, String seen) {
if (mHandle == 0) {
throw new IllegalAccessError("Pushing data to empty native handler, aborting");
}
SmsBuffer.push(mHandle, id, mbid, type, date, address, body, read, seen);
}
public void clear() {
if (mHandle == 0) {
return;
}
SmsBuffer.deleteNativeObject(mHandle);
mHandle = 0;
}
/*
JNI: Eepty method
*/