Smack 4.2.1-beta2-SNAPSHOT OmemoService#subscribeToDeviceLists starts up too late to process PEP_NODE_DEVICE_LIST_NOTIFY

Found that OmemoManager#PEPListener deviceListUpdateListener() did not manage to process the following pubsub#event sent from server due to late in PEP_NODE_DEVICE_LIST_NOTIFY listener registration.

aTalk has implemented the reflection method, and it is being called immediately upon xmpp connection to resolve the problem for smack 4.2.1-beta2-SNAPSHOT.

private void subscribeToDeviceLists(OmemoManager omemoManager)
{
OmemoService omemoService = OmemoService.getInstance();
try {
Method addPEPListener = OmemoService.class.getDeclaredMethod
(“subscribeToDeviceLists”, OmemoManager.class);
addPEPListener.setAccessible(true);
addPEPListener.invoke(omemoService, omemoManager);
}
catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
}

======

07-23 23:02:12.599 D/SMACK: RECV (0):

Continue testing with the OmemoManager#deviceListUpdateListener() after the reflection private method implementation. In smack omemo deviceListUpdateListener() handling upon receipt of an deviceList stanza, it will perform

mergeCachedDeviceList(OmemoManager.this, from, omemoDeviceListElement);

in which it will update the “activeDevices” and “inactiveDevices” list with the received omemoDevice ID’s; in the persistent storage. The update does not checked for any new deviceID nor make new entry in the entities table if any. Under the smack omemo default file based backend storage, this works fine as the actual entities information can be added at a later stage (not sure when and how smack omemo update the entities info - guess it is during olmMessage sending?).

aTalk however implements omemo persistent storage using SQLite database, update the device active state without any entry in the entities will fail. If needs to, aTalk can perform check in the below override method and create new/missing entry in the entities table while updating its active state.

storeCachedDeviceList(OmemoManager omemoManager, BareJid contact, CachedDeviceList deviceList)

Would smack omemo considers enhance the deviceListUpdateListener() method to take care the above scenario i.e. create new identities entry if missing before calling active state update.

Any other better recommendations?

========== aTalk log ======================

07-24 08:22:40.555 D/SMACK: RECV (0): 11creation@001500:736494:893196creation@001500:736494:893 196

07-24 08:22:40.555 W/αTalk: [11] org.atalk.persistance.DatabaseBackend.storeCachedDeviceList().1314 Identities table contains no device: swan@atalk.org:816614937

I created a new entry in the identities table for the new deviceId leaving keyPair value empty during the storeCachedDeviceList() if no exist, but found that smack omemoService does not in any point in the whole operation attempts to update the missing keyPair for the newly created identities entry. Neither OmemoService attempts to load the newly created keyPair.

/--------------------------------------/

Further testing shows that the olmMessage sent from aTalk (swan@atalk.org) contains only #2 but excluded #3 (alternate device); whereas olmMessage sent from conversations contains both #2 and #1 (alternate device).

  1. swan@atalk.org:1711246335 (S3-aTalk)

  2. leopard@atalk.org:1011347036 (Note3-aTalk)

  3. swan@atalk.org:816614937 (S3-conversations)

=============== olmMessage sent from S3-aTalk to Note3-aTalk (leopard) ==================

07-24 14:17:12.277 D/SMACK: RECV (0): ****MwohBbNw++gXyOYvrwCqhlrN3SQu4GrGdcCUxr+OzNuOTxB1EAEYAyIw+tVlSC1SZokiODuMTAtBgkQF VujvkWcqbI9kCu5YVdxiZMInL3nN3YdswaX89uMNy5iMvTx5V3k=xwXPRDyyDz5oqJJ2Xr sJmw==niYQqw==I sent you an OMEMO encrypted message but your client doesn’t seem to support that. Find more information on https://conversations.im/omemo56de2403-0b80-4c24-ac16-95fe7a85018b

=============== olmMessage sent from S3-conversations to Note3-aTalk (leopard) ==================

07-24 14:17:54.777 D/SMACK: RECV (0): **MwgMEiEFhZCIcePfLlJRNYy+o9vEdckqN/XfWpq51eP5UQHz4GQaIQUUV5ApOiQnNcECsTvKWCH8wDMr Qe4XtFTcxf88Tg61YSJjMwohBRkTFwRc88k+9cDwCt6Igt/5+SwLSgzV/7wuuabv5Ig3EK8BGAAiMIUW w1JbOAx0rj0oIne/Ttv3fp7JG07oPJthIAoiTZUB4/EPFi/i7g9G0d1YWHlSO6KIYRkgva3gKJmcsoUD MAE=**MwohBWhK4U6+HxL2ZrzP+Yt4qddq73NyDfFMtDA+BGb7B55SEAAYASIwNIlGQOxpYu0ghoAzWHFUN77R JMyRKknkcySeKuy7blsetEMhTz+CMvjvZ9dShXK8mLejbIOdqTI=PeK0se/ZpC0RpVzCB9 H3qQ==OJw9

This will be fixed with https://github.com/igniterealtime/Smack/pull/177