-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Negotiating data exchange, Tracking last sent data on the receiver & generate hash key if not presenter device start #32
Conversation
db0c31f
to
19c2831
Compare
Capitalize Constant sub-classes/interfaces instead of using UPPER_CASE
- Add room and encrypted sql cipher - Use Wifi mac address as the device unique identifier since it persists across installs and device formats - Add SendingDevice records as sending_devices table to keep track of sending devices - Add p2p_received_history table to keep track of received history - Sending devices sends the hash_key(app-lifetime-key) to the receiving device together with the unique identifier - Register new sending device on recieving device - Clear previous receiving history if the sending device has it's app-lifetime-key(hash_key) changed
…enderPresenter - Move log strings and other UI strings to strings.xml
- This seems to work better than ConnectionsClient.stopAllEndpoints() and reduces the possibilty of memory leaks - This also fixes the NPE when a connection callback is called after the app exits and the interactor is null
- Change the current connection level of the app after authorization and after negotiating the start of the data exchange Fixes #8
19c2831
to
d8835e3
Compare
view.showToast(view.getString(R.string.an_error_occurred_before_acceptance_or_rejection), Toast.LENGTH_LONG); | ||
resetState(); | ||
startAdvertisingMode(); | ||
if (getCurrentPeerDevice() != null && endpointId.equals(getCurrentPeerDevice().getEndpointId())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't there be an else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The else is not supposed to be possible, if it is, then due to the memory leak whose issue is here #39.
The app was crashing without the if since the code was being run even after exiting the activity and the ConnectionsClient is holding on to the callbacks passed
If the google issue has no reply by the time I am done with the remaining issues and no other solution in site, then we'll have to use WeakReferences for the view (Or clean it up) but the API might still hold onto the listener until it makes the last call
The else happening, means that the callback was called although we are not connected to the endpoint or have already disconnected
resetState(); | ||
view.showToast(String.format(view.getString(R.string.connection_to_endpoint_broken), endpointId), Toast.LENGTH_LONG); | ||
startAdvertisingMode(); | ||
if (getCurrentPeerDevice() != null && endpointId.equals(getCurrentPeerDevice().getEndpointId())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't there be an else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The else is not supposed to be possible, if it is, then due to the memory leak whose issue is here #39.
The app was crashing without the if since the code was being run even after exiting the activity and the ConnectionsClient is holding on to the callbacks passed
If the google issue has no reply by the time I am done with the remaining issues and no other solution in site, then we'll have to use WeakReferences for the view (Or clean it up) but the API might still hold onto the listener until it makes the last call
The else happening, means that the callback was called although we are not connected to the endpoint or have already disconnected
sendingDevice.setAppLifetimeKey(appLifetimeKey); | ||
db.sendingDeviceDao().update(sendingDevice); | ||
|
||
return db.p2pReceivedHistoryDao() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't clear be done before update or maybe consider using Transaction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either can work, there is device_id
which will never change and is used to reference the device in the received_history
table. I will add a transaction to this
p2p-sync/src/main/java/org/smartregister/p2p/presenter/P2PReceiverPresenter.java
Outdated
Show resolved
Hide resolved
Timber.e(view.getString(R.string.log_endpoint_lost), endpointId); | ||
resetState(); | ||
startAdvertisingMode(); | ||
if (getCurrentPeerDevice() != null && endpointId.equals(getCurrentPeerDevice().getEndpointId())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding else to do cleanup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The else is not supposed to be possible, if it is, then due to the memory leak whose issue is here #39.
The app was crashing without the if since the code was being run even after exiting the activity and the ConnectionsClient is holding on to the callbacks passed
If the google issue has no reply by the time I am done with the remaining issues and no other solution in site, then we'll have to use WeakReferences for the view (Or clean it up) but the API might still hold onto the listener until it makes the last call
The else happening, means that the callback was called although we are not connected to the endpoint or have already disconnected
view.showToast(view.getString(R.string.an_error_occurred_before_acceptance_or_rejection), Toast.LENGTH_LONG); | ||
resetState(); | ||
startDiscoveringMode(); | ||
if (getCurrentPeerDevice() != null && endpointId.equals(getCurrentPeerDevice().getEndpointId())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider doing cleanup for an else clause
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same case
The else is not supposed to be possible, if it is, then due to the memory leak whose issue is here #39.
The app was crashing without the if since the code was being run even after exiting the activity and the ConnectionsClient is holding on to the callbacks passed
If the google issue has no reply by the time I am done with the remaining issues and no other solution in site, then we'll have to use WeakReferences for the view (Or clean it up) but the API might still hold onto the listener until it makes the last call
The else happening, means that the callback was called although we are not connected to the endpoint or have already disconnected
view.showToast(String.format(view.getString(R.string.connection_to_endpoint_broken) | ||
, endpointId), Toast.LENGTH_LONG); | ||
startDiscoveringMode(); | ||
if (getCurrentPeerDevice() != null && endpointId.equals(getCurrentPeerDevice().getEndpointId())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider an else and doing cleanup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The else is not supposed to be possible, if it is, then due to the memory leak whose issue is here #39.
The app was crashing without the if since the code was being run even after exiting the activity and the ConnectionsClient is holding on to the callbacks passed
If the google issue has no reply by the time I am done with the remaining issues and no other solution in site, then we'll have to use WeakReferences for the view (Or clean it up) but the API might still hold onto the listener until it makes the last call
The else happening, means that the callback was called although we are not connected to the endpoint or have already disconnected
Fixes #8
Fixes #5
Covers some tasks on #6