Exemplo n.º 1
0
 /* insert */
 public static int insert(DatabaseHelper databaseHelper, system_messageVo system_messageVo) {
   RuntimeExceptionDao<system_messageVo, Integer> system_messageDao =
       databaseHelper.getSystem_messageDao();
   if (exist(databaseHelper, system_messageVo)) {
     return 0;
   }
   return system_messageDao.create(system_messageVo);
 }
Exemplo n.º 2
0
  private void smsTunnel() {
    Cursor cursor = null;
    String sms_id = null; // 数据处理标记,存入SharedPreferences
    try {
      RuntimeExceptionDao<SmsStructure, Long> dao =
          QualityApplication.getApplication(this).getDatabaseHelper().getSmsStructureDAO();
      cursor =
          getContentResolver()
              .query(
                  SmsContentObserver.SMS_URI,
                  null,
                  "_id > ?",
                  new String[] {sharedPreferences.getString(SmsContentObserver.SMS_FLAG_ID, "0")},
                  "_ID ASC");
      while (cursor.moveToNext()) {
        sms_id = cursor.getString(cursor.getColumnIndex("_id"));
        int type = cursor.getInt(cursor.getColumnIndex("type"));
        String number = cursor.getString(cursor.getColumnIndex("address"));
        String name = Contacts.lookupPersonName(getApplicationContext(), number, null);
        DateTime ddate = new DateTime(cursor.getLong(cursor.getColumnIndex("date")));

        SmsStructure structure =
            new SmsStructure(
                MobileNetType.getPhoneType(getApplicationContext()),
                MobileNetType.getMobileTypeValue(getApplicationContext()),
                name,
                number,
                type,
                ddate);
        dao.create(structure);
      }
    } catch (Exception e) {
      Log.w(TAG, "未能处理当前短信记录数据", e);
    } finally {
      try {
        if (null != cursor) cursor.close();
      } catch (Exception e) {
      }
      if (!Strings.isEmpty(sms_id))
        sharedPreferences.edit().putString(SmsContentObserver.SMS_FLAG_ID, sms_id).commit();
    }
    sendMessage(PhoneStateService.OBSERVER_INSTALL, PhoneStateService.OBSERVER_INSTALL_SMS);
  }
Exemplo n.º 3
0
  public boolean verificaLogin() {
    boolean cadastrado = false;
    RuntimeExceptionDao<Usuario, Integer> usrDao = getHelper().getUsuarioRuntimeExceptionDao();
    usrDao.create(new Usuario("user1", "1234"));
    List<Usuario> usrs = usrDao.queryForAll();

    // Log.d("demo", usrs.toString());

    for (Usuario u : usrs) {
      // Log.d("demo", u.login);
      // Log.d("demo", etLogin.getText().toString());
      if (u.login.equals(etLogin.getText().toString())
          && u.senha.equals(etSenha.getText().toString())) {
        cadastrado = true;
      }
    }

    return cadastrado;
  }
Exemplo n.º 4
0
 private void callsTunnel() {
   Cursor cursor = null;
   String calls_id = null; // 数据处理标记,存入SharedPreferences
   try {
     RuntimeExceptionDao<CallsStructure, Long> dao =
         QualityApplication.getApplication(this).getDatabaseHelper().getCallsStructureDAO();
     cursor =
         getContentResolver()
             .query(
                 CallsContentObserver.CALLS_URI,
                 null,
                 "_id > ?",
                 new String[] {
                   sharedPreferences.getString(CallsContentObserver.CALLS_FLAG_ID, "0")
                 },
                 CallLog.Calls._ID + " ASC");
     while (cursor.moveToNext()) {
       calls_id = cursor.getString(cursor.getColumnIndex(CallLog.Calls._ID));
       int type = cursor.getInt(cursor.getColumnIndex(CallLog.Calls.TYPE));
       String number = cursor.getString(cursor.getColumnIndex(CallLog.Calls.NUMBER));
       String name =
           Contacts.lookupPersonName(
               getApplicationContext(),
               number,
               cursor.getString(cursor.getColumnIndex(CallLog.Calls.CACHED_NAME)));
       long duration = cursor.getLong(cursor.getColumnIndex(CallLog.Calls.DURATION));
       DateTime ddate = new DateTime(cursor.getLong(cursor.getColumnIndex(CallLog.Calls.DATE)));
       CallsStructure structure =
           new CallsStructure(
               MobileNetType.getPhoneType(getApplicationContext()),
               MobileNetType.getMobileTypeValue(getApplicationContext()),
               name,
               number,
               type,
               CallDropCause.UNKNOW.toString(),
               duration,
               ddate);
       dao.create(structure);
     }
   } catch (Exception e) {
     Log.w(TAG, "未能处理当前通话记录数据", e);
   } finally {
     try {
       if (null != cursor) cursor.close();
     } catch (Exception e) {
     }
     if (!Strings.isEmpty(calls_id))
       sharedPreferences.edit().putString(CallsContentObserver.CALLS_FLAG_ID, calls_id).commit();
   }
   try {
     RuntimeExceptionDao<CallCauseCache, Long> dao =
         QualityApplication.getApplication(this).getDatabaseHelper().getCallCauseCacheDAO();
     RuntimeExceptionDao<CallsStructure, Long> callDao =
         QualityApplication.getApplication(this).getDatabaseHelper().getCallsStructureDAO();
     List<CallCauseCache> caches = dao.queryForAll();
     // 遍历
     if (null != caches && caches.size() > 0) {
       for (CallCauseCache cache : caches) {
         CallsStructure struct =
             callDao
                 .queryBuilder()
                 .orderBy("ddate", false)
                 .where()
                 .eq("ddate", cache.getDdate())
                 .queryForFirst();
         if (null != struct) {
           // 更新断开原因
           struct.setCause(cache.getCause());
           callDao.update(struct);
           // 删除
           dao.deleteById(cache.getId());
         }
       }
     }
   } catch (Exception e) {
     Log.d(TAG, "更新通话断开原因时出现异常");
   }
   sendMessage(PhoneStateService.OBSERVER_INSTALL, PhoneStateService.OBSERVER_INSTALL_CALLS);
 }
Exemplo n.º 5
0
 /*
  * 存储数据
  */
 public void addRundata(RunData rundata) {
   rundataDao.create(rundata);
 }