@Override public void handleMessage(Message message) { Log.d(LOG_TAG, "DONE: " + message.what); if (message.getData().getInt("error") == 0) { if (Utils.isGalaxyS2()) { Utils.deleteLogFilesWithPrefix(new String[] {Constants.LOG_FILE_S2_PREFIX_AENAES}); } Log.e(LOG_TAG, "Received message from PhoneSecService."); // files are not available as soon as message received from // service. SystemClock.sleep(3000); lookForSecurityCodes(); } else { Log.e(LOG_TAG, "Error while fetching modem log."); } }
private void lookForSecurityCodes() { File[] matchingLogFile = Utils.searchLogFile(); if (matchingLogFile == null || matchingLogFile.length == 0) { Log.e(LOG_TAG, "Log file not found."); return; } else { EventDetails eventDetails = getEventDetails(); NetworkType nwType = eventDetails.getNwType(); String nwOperator = eventDetails.getNwOperator(); Event event = eventDetails.getEvent(); long eventReportedAt = eventDetails.getReportedAt(); Log.e(LOG_TAG, "Current Event " + event.name()); for (int i = 0; i < matchingLogFile.length; i++) { Log.d(LOG_TAG, "Source log file : " + matchingLogFile[i].getAbsolutePath()); long startTime = System.currentTimeMillis(); byte[] filteredByteSeq = sLogFileReader.readFile(matchingLogFile[i], event, nwType); if (filteredByteSeq == null) { Utils.deleteLogFile(matchingLogFile[i]); continue; } long endTime = System.currentTimeMillis(); Log.e( LOG_TAG, "Time taken to read and filter log file " + (endTime - startTime) / 1000 + " Seconds."); // Silent SMS does not generate an event, to know the presence // of Silent SMS log file needs to be scanned. startTime = System.currentTimeMillis(); List<Packet> silentSMSEntries = sPacketReader.generateResult( filteredByteSeq, Constants.SMS, event, getApplicationContext()); Log.e(LOG_TAG, "Number of silent SMS entries : " + silentSMSEntries.size()); List<Packet> profileParams = sPacketReader.generateResult( filteredByteSeq, Constants.PROFILE_PARAMS, event, getApplicationContext()); beginProfileParamComparison(profileParams); Log.e(LOG_TAG, "Number of Profile parameters found : " + profileParams.size()); if (event != Event.NONE) { if (NetworkType._3G == nwType) { List<Packet> _3gEntries = sPacketReader.generateResult( filteredByteSeq, Constants._3G, event, getApplicationContext()); insertEntriesIntoDB(_3gEntries, NetworkType._3G, nwOperator, event, eventReportedAt); Log.e(LOG_TAG, "Number of 3G entries : " + _3gEntries.size()); _3gEntries = null; } else if (NetworkType.GSM == nwType) { List<Packet> gsmEntries = sPacketReader.generateResult( filteredByteSeq, Constants.GSM, event, getApplicationContext()); insertEntriesIntoDB(gsmEntries, NetworkType.GSM, nwOperator, event, eventReportedAt); Log.e(LOG_TAG, "Number of GSM entries : " + gsmEntries.size()); gsmEntries = null; } } if (insertEntriesIfNotDuplicate( silentSMSEntries, nwType, nwOperator, Event.INCOMING_SILENT_SMS, System.currentTimeMillis())) { setSilentSMSNotification(); } insertEntriesIfNotDuplicate( profileParams, nwType, nwOperator, Event.PROFILE_PARAMS, System.currentTimeMillis()); Utils.deleteLogFile(matchingLogFile[i]); endTime = System.currentTimeMillis(); Log.e( LOG_TAG, "Time taken to extract code info " + (endTime - startTime) / 1000 + " Seconds."); filteredByteSeq = null; silentSMSEntries = null; profileParams = null; } matchingLogFile = null; } }