(WIP) Upgrade Telephony plugin to read SMS history (Android side)
ClosedPublic

Authored by sredman on Mar 25 2018, 8:20 PM.

Details

Summary

Add support for requesting all conversations and sending the reply

Test Plan
  • Build this diff
  • Build the corresponding KDE-side diff (D11854)
  • Put a breakpoint in handleRequestConversations somewhere where you can inspect one or more Message objects
  • Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations()
  • Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation

Diff Detail

Repository
R225 KDE Connect - Android application
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
sredman requested review of this revision.Mar 25 2018, 8:20 PM
sredman created this revision.
sredman added a subscriber: KDE Connect.
mtijink added inline comments.
src/org/kde/kdeconnect/Helpers/SMSHelper.java
45

getSMSURIBad? I think getSMSURIBase is more logical. Also, these can easily be inlined in the getSMSUri function.

77

The return type could use some improvements. I'd suggest a data class holding these result with logical names.

Also, getSMS is not really discriptive for what the function actually does (getting SMS threads).

104

Android coding style.

sredman added inline comments.Mar 31 2018, 10:18 PM
src/org/kde/kdeconnect/Helpers/SMSHelper.java
45

As the comment suggests, using this method to access messages is a bad idea. Thus the method name. In the standard library it resolves to the same thing as Telephony.Sms.CONTENT_URI, so I expect it will work most of the time, but it is very likely that some older phones have designed their own way of doing things and this method will not work, possibly even causing spectacular explosions

With that in mind, the reason I left these two in functions is:

  1. In case we need to add more special-case URI-getting code in the future
  2. So that I could put a big header comment on getSMSURIBad explaining why it was a bad idea to use that method, but I guess I didn't do a good enough job :)

I suppose getSMSURIGood could be inlined, since it doesn't need much explaination

77

These are both good points, especially with respect to creating a custom class for the return type. I will definitely do that.

The more I think about what I need from the SMS database in order to support the SMS app, the more I realize that this code in its current form won't work anyway. I will need more helper methods, meaning I will need to do better names.

104

Darn it. I was doing so well up to here. I have been doing brace-on-next-line for so long it's hard to not!

sredman retitled this revision from Add helper for reading SMS messages to Upgrade Telephony plugin to read SMS history (Android side).Apr 1 2018, 1:06 AM
sredman added a reviewer: KDE Connect.
sredman updated this revision to Diff 31079.Apr 1 2018, 1:12 AM

Add basic support for requesting all conversations

sredman marked 6 inline comments as done.Apr 1 2018, 1:15 AM
sredman updated this revision to Diff 31081.Apr 1 2018, 4:11 AM

Tweak protocol

nicolasfella added inline comments.
src/org/kde/kdeconnect/Plugins/TelephonyPlugin/TelephonyPlugin.java
379

You could batch them into a JSON array and just send one packet to reduce overhead

sredman updated this revision to Diff 31114.Apr 1 2018, 5:54 PM

Support sending messages as batch packet

sredman marked an inline comment as done.Apr 1 2018, 7:22 PM
mtijink added inline comments.Apr 7 2018, 8:16 AM
src/org/kde/kdeconnect/Helpers/SMSHelper.java
202

I was thinking somethink you could use like this: message.address, etc., instead of message.get(Message.ADDRESS).

So the class just has these fields instead of extending a hashmap.

sredman updated this revision to Diff 34247.May 16 2018, 12:23 AM
sredman marked an inline comment as done.

Make Message a field-based container class

Restricted Application added a subscriber: kdeconnect. · View Herald TranscriptMay 16 2018, 12:23 AM

Thanks for me remember how final works in Java, this turned out to be easy!

sredman retitled this revision from Upgrade Telephony plugin to read SMS history (Android side) to (WIP) Upgrade Telephony plugin to read SMS history (Android side).May 16 2018, 12:37 AM
sredman edited the summary of this revision. (Show Details)
sredman edited the test plan for this revision. (Show Details)
nicolasfella accepted this revision.Jun 6 2018, 10:03 PM

Let's merge it and refactor then

This revision is now accepted and ready to land.Jun 6 2018, 10:03 PM
This revision was automatically updated to reflect the committed changes.