@@ -136,35 +136,12 @@ public interface MessageListener {
136136 * Prepare Messages for Upload.
137137 */
138138
139- public void createSessionHistoryUploadMessage (ConfigManager configManager , DeviceAttributes deviceAttributes , String currentSessionId ) throws JSONException {
140- MPDatabase db = getDatabase ();
141- db .beginTransaction ();
142- try {
143- List <MessageService .ReadyMessage > readyMessages = MessageService .getSessionHistory (db , currentSessionId );
144- if (readyMessages .size () <= 0 ) {
145- db .setTransactionSuccessful ();
146- return ;
147- }
148-
149- HashMap <BatchId , MessageBatch > uploadMessagesByBatchId = getUploadMessageByBatchIdMap (readyMessages , db , configManager , true );
150-
151- List <JSONObject > deviceInfos = SessionService .processSessions (db , uploadMessagesByBatchId );
152- for (JSONObject deviceInfo : deviceInfos ) {
153- deviceAttributes .updateDeviceInfo (mContext , deviceInfo );
154- }
155- createUploads (uploadMessagesByBatchId , db , deviceAttributes , configManager , currentSessionId , true );
156- db .setTransactionSuccessful ();
157- } finally {
158- db .endTransaction ();
159- }
160- }
161-
162139 public boolean hasMessagesForUpload () {
163140 MPDatabase db = getDatabase ();
164141 return MessageService .hasMessagesForUpload (db );
165142 }
166143
167- public void createMessagesForUploadMessage (ConfigManager configManager , DeviceAttributes deviceAttributes , String currentSessionId , boolean sessionHistoryEnabled ) throws JSONException {
144+ public void createMessagesForUploadMessage (ConfigManager configManager , DeviceAttributes deviceAttributes , String currentSessionId ) throws JSONException {
168145 MPDatabase db = getDatabase ();
169146 db .beginTransaction ();
170147 try {
@@ -173,7 +150,7 @@ public void createMessagesForUploadMessage(ConfigManager configManager, DeviceAt
173150 db .setTransactionSuccessful ();
174151 return ;
175152 }
176- HashMap <BatchId , MessageBatch > uploadMessagesByBatchId = getUploadMessageByBatchIdMap (readyMessages , db , configManager , false , sessionHistoryEnabled );
153+ HashMap <BatchId , MessageBatch > uploadMessagesByBatchId = getUploadMessageByBatchIdMap (readyMessages , db , configManager , false );
177154
178155 List <ReportingService .ReportingMessage > reportingMessages = ReportingService .getReportingMessagesForUpload (db );
179156 for (ReportingService .ReportingMessage reportingMessage : reportingMessages ) {
@@ -209,7 +186,7 @@ public void createMessagesForUploadMessage(ConfigManager configManager, DeviceAt
209186 for (JSONObject deviceInfo : deviceInfos ) {
210187 deviceAttributes .updateDeviceInfo (mContext , deviceInfo );
211188 }
212- createUploads (uploadMessagesByBatchId , db , deviceAttributes , configManager , currentSessionId , false , sessionHistoryEnabled );
189+ createUploads (uploadMessagesByBatchId , db , deviceAttributes , configManager , currentSessionId );
213190 db .setTransactionSuccessful ();
214191 } finally {
215192 db .endTransaction ();
@@ -228,11 +205,11 @@ public void deleteMessagesAndSessions(String currentSessionId) {
228205 }
229206 }
230207
231- private HashMap <BatchId , MessageBatch > getUploadMessageByBatchIdMap (List <MessageService .ReadyMessage > readyMessages , MPDatabase db , ConfigManager configManager , boolean isHistory ) throws JSONException {
232- return getUploadMessageByBatchIdMap (readyMessages , db , configManager , isHistory , false );
208+ private HashMap <BatchId , MessageBatch > getUploadMessageByBatchIdMap (List <MessageService .ReadyMessage > readyMessages , MPDatabase db , ConfigManager configManager ) throws JSONException {
209+ return getUploadMessageByBatchIdMap (readyMessages , db , configManager , false );
233210 }
234211
235- private HashMap <BatchId , MessageBatch > getUploadMessageByBatchIdMap (List <MessageService .ReadyMessage > readyMessages , MPDatabase db , ConfigManager configManager , boolean isHistory , boolean markAsUpload ) throws JSONException {
212+ private HashMap <BatchId , MessageBatch > getUploadMessageByBatchIdMap (List <MessageService .ReadyMessage > readyMessages , MPDatabase db , ConfigManager configManager , boolean markAsUpload ) throws JSONException {
236213 HashMap <BatchId , MessageBatch > uploadMessagesByBatchId = new HashMap <BatchId , MessageBatch >();
237214 int highestUploadedMessageId = -1 ;
238215 for (MessageService .ReadyMessage readyMessage : readyMessages ) {
@@ -247,11 +224,7 @@ private HashMap<BatchId, MessageBatch> getUploadMessageByBatchIdMap(List<Message
247224 if (messageLength + uploadMessage .getMessageLengthBytes () > Constants .LIMIT_MAX_UPLOAD_SIZE ) {
248225 break ;
249226 }
250- if (isHistory ) {
251- uploadMessage .addSessionHistoryMessage (msgObject );
252- } else {
253- uploadMessage .addMessage (msgObject );
254- }
227+ uploadMessage .addMessage (msgObject );
255228 InternalListenerManager .getListener ().onCompositeObjects (readyMessage , uploadMessage );
256229 uploadMessage .incrementMessageLengthBytes (messageLength );
257230 highestUploadedMessageId = readyMessage .getMessageId ();
@@ -266,11 +239,7 @@ private HashMap<BatchId, MessageBatch> getUploadMessageByBatchIdMap(List<Message
266239 return uploadMessagesByBatchId ;
267240 }
268241
269- private void createUploads (Map <BatchId , MessageBatch > uploadMessagesByBatchId , MPDatabase db , DeviceAttributes deviceAttributes , ConfigManager configManager , String currentSessionId , boolean historyMessages ) {
270- createUploads (uploadMessagesByBatchId , db , deviceAttributes , configManager , currentSessionId , historyMessages , false );
271- }
272-
273- private void createUploads (Map <BatchId , MessageBatch > uploadMessagesByBatchId , MPDatabase db , DeviceAttributes deviceAttributes , ConfigManager configManager , String currentSessionId , boolean historyMessages , boolean sessionHistoryEnabled ) {
242+ private void createUploads (Map <BatchId , MessageBatch > uploadMessagesByBatchId , MPDatabase db , DeviceAttributes deviceAttributes , ConfigManager configManager , String currentSessionId ) {
274243 for (Map .Entry <BatchId , MessageBatch > messageBatchEntry : uploadMessagesByBatchId .entrySet ()) {
275244 BatchId batchId = messageBatchEntry .getKey ();
276245 MessageBatch uploadMessage = messageBatchEntry .getValue ();
@@ -284,12 +253,7 @@ private void createUploads(Map<BatchId, MessageBatch> uploadMessagesByBatchId, M
284253 if (uploadMessage .getDeviceInfo () == null || sessionId .equals (currentSessionId )) {
285254 uploadMessage .setDeviceInfo (deviceAttributes .getDeviceInfo (mContext ));
286255 }
287- JSONArray messages ;
288- if (historyMessages ) {
289- messages = uploadMessage .getSessionHistoryMessages ();
290- } else {
291- messages = uploadMessage .getMessages ();
292- }
256+ JSONArray messages = uploadMessage .getMessages ();
293257 JSONArray identities = findIdentityState (configManager , messages , batchId .getMpid ());
294258 uploadMessage .setIdentities (identities );
295259 JSONObject userAttributes = findUserAttributeState (messages , batchId .getMpid ());
@@ -311,12 +275,7 @@ private void createUploads(Map<BatchId, MessageBatch> uploadMessagesByBatchId, M
311275 }
312276
313277 UploadService .insertUpload (db , batch , configManager .getApiKey ());
314- //if this was to process session history, or
315- //if we're never going to process history AND
316- //this batch contains a previous session, then delete the session.
317- if (!historyMessages && !sessionHistoryEnabled ) {
318- cleanSessions (currentSessionId );
319- }
278+ cleanSessions (currentSessionId );
320279 }
321280 }
322281 }
0 commit comments