Thank for the information. In aTalk v0.9.1 release, actually I have included the step to fetch new prekeys for active device when missing using method buildSessionFromOmemoBundle(). However seems this is not working for this case.
public void storeCachedDeviceList(OmemoManager omemoManager, BareJid contact, CachedDeviceList deviceList)
throws CannotEstablishOmemoSessionException, CorruptedOmemoKeyException
{
if (contact == null) {
return;
}
final SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
// Active devices
values.put(SQLiteOmemoStore.ACTIVE, 1);
Set<Integer> activeDevices = deviceList.getActiveDevices();
for (int deviceId : activeDevices) {
String[] selectionArgs = {contact.toString(), Integer.toString(deviceId)};
int row = db.update(SQLiteOmemoStore.IDENTITIES_TABLE_NAME, values,
SQLiteOmemoStore.BARE_JID + "=? AND " + SQLiteOmemoStore.DEVICE_ID + "=?",
selectionArgs);
if (row == 0) {
logger.warn("Identities table contains no activeDevice (fetch new): " + contact + ":" + deviceId);
// create the identities & preKeys for missing deviceId
OmemoDevice omemoDevice = new OmemoDevice(contact, deviceId);
// may throws CannotEstablishOmemoSessionException, CorruptedOmemoKeyException
OmemoService.getInstance().buildSessionFromOmemoBundle(omemoManager, omemoDevice, false);
}
}
// Inactive devices
values.put(SQLiteOmemoStore.ACTIVE, 0);
Set<Integer> inActiveDevices = deviceList.getInactiveDevices();
for (int deviceId : inActiveDevices) {
String[] selectionArgs = {contact.toString(), Integer.toString(deviceId)};
int row = db.update(SQLiteOmemoStore.IDENTITIES_TABLE_NAME, values,
SQLiteOmemoStore.BARE_JID + "=? AND " + SQLiteOmemoStore.DEVICE_ID + "=?",
selectionArgs);
if (row == 0) {
logger.warn("Identities table contains no inactiveDevice: " + contact + ":" + deviceId);
new Exception().printStackTrace();
}
}
}