예제 #1
0
 private boolean insertEntriesIfNotDuplicate(
     List<Packet> packets,
     NetworkType nwType,
     String nwOperator,
     Event event,
     long eventReportedAt) {
   boolean atleastOneEntryIsAdded = false;
   if (packets != null && packets.size() > 0) {
     long logEntryUid = sDBHelper.insertLogEntry(nwType, nwOperator, event, eventReportedAt);
     for (Packet packet : packets) {
       // Check if the log entry to be added is already present.
       // Silent SMS has only one type of code entry, so if it is
       // already present don't create an log entry.
       boolean isDuplicate =
           sDBHelper.isPacketAlreadyInserted(packet.getPacketTypeId(), packet.getHexCode());
       if (!isDuplicate) {
         long packetUid =
             sDBHelper.insertPacket(
                 logEntryUid,
                 eventReportedAt,
                 packet.getPacketTypeId(),
                 packet.getHexCode(),
                 isDuplicate);
         for (PacketAttribute packetAttribute : packet.getPacketAttributes()) {
           sDBHelper.insertPacketAttribute(
               packetUid,
               eventReportedAt,
               packetAttribute.getPacketAttrTypeId(),
               packetAttribute.getHexCode(),
               packetAttribute.getDisplayText());
           atleastOneEntryIsAdded = true;
         }
       } else {
         /*Log.e(LOG_TAG,
         "Code entry already exists in database."
         		+ codeEntry.getKind() + ", "
         		+ codeEntry.getHexCode());*/
       }
     }
     // If no entry is added then delete the log entry.
     if (!atleastOneEntryIsAdded) {
       sDBHelper.deleteLogEntry(logEntryUid);
     }
   }
   return atleastOneEntryIsAdded;
 }
예제 #2
0
 private EventDetails getEventDetails() {
   EventDetails eventDetails = sDBHelper.getOldestUnconsumedEvent();
   if (eventDetails == null) {
     Application application = ((Application) getApplication());
     NetworkType nwType = application.getNwType();
     String nwOperator = application.getNwOperator();
     eventDetails = new EventDetails(Event.NONE, nwType, nwOperator);
   }
   return eventDetails;
 }
예제 #3
0
 private void insertEntriesIntoDB(
     List<Packet> packets,
     NetworkType nwType,
     String nwOperator,
     Event event,
     long eventReportedAt) {
   if (packets != null && packets.size() > 0) {
     long logEntryUid = sDBHelper.insertLogEntry(nwType, nwOperator, event, eventReportedAt);
     for (Packet packet : packets) {
       // Check if the log entry to be added is already present.
       boolean isDuplicate =
           sDBHelper.isPacketAlreadyInserted(packet.getPacketTypeId(), packet.getHexCode());
       if (isDuplicate) {
         /*
          * Log.e(LOG_TAG, "Code entry already exists in database." +
          * logEntryUid + ", " + codeEntry.getKind() + ", " +
          * codeEntry.getHexCode());
          */
       }
       long codeEntryUid =
           sDBHelper.insertPacket(
               logEntryUid,
               eventReportedAt,
               packet.getPacketTypeId(),
               packet.getHexCode(),
               isDuplicate);
       for (PacketAttribute packetAttribute : packet.getPacketAttributes()) {
         sDBHelper.insertPacketAttribute(
             codeEntryUid,
             eventReportedAt,
             packetAttribute.getPacketAttrTypeId(),
             packetAttribute.getHexCode(),
             packetAttribute.getDisplayText());
       }
     }
   }
 }