示例#1
0
 private void deletePrivacyCallogs() {
   int sum = PrivacyContactsActivity.sPrivacyContactsListItems.size();
   for (int i = 0; i < sum; i++) {
     PrivacyContactDataItem item = PrivacyContactsActivity.sPrivacyContactsListItems.get(i);
     PhoneType pt = ConvertUtils.getPhonetype(item.getPhoneNumber());
     Cursor localCursor =
         context
             .getContentResolver()
             .query(
                 CALLOG_URI,
                 CALLOG_PROJECTION,
                 "number LIKE '%" + pt.getPhoneNo() + "%'",
                 null,
                 null);
     if (localCursor != null && localCursor.getCount() > 0) {
       while (localCursor.moveToNext()) {
         int isNew = localCursor.getInt(localCursor.getColumnIndex(CallLog.Calls.NEW));
         int type = localCursor.getInt(localCursor.getColumnIndex(CallLog.Calls.TYPE));
         System.out.println("isNew :" + isNew);
         if (isNew == 1 || type == CallLog.Calls.MISSED_TYPE) {
           updateNotification();
         }
       }
       context
           .getContentResolver()
           .delete(CALLOG_URI, "number LIKE '%" + pt.getPhoneNo() + "%'", null);
     }
   }
 }
示例#2
0
  private void checkPrivacy(String incomingNumber) {
    List<PrivacyContactDataItem> mItems = PrivacyContactsActivity.sPrivacyContactsListItems;
    int sum = mItems.size();
    for (int i = 0; i < sum; i++) {
      PrivacyContactDataItem item = mItems.get(i);
      PhoneType pt = ConvertUtils.getPhonetype(incomingNumber);
      if (item.getPhoneNumber().contains(pt.getPhoneNo())) {
        if (item.getBlockedType() == 1) {
          endCall(incomingNumber);
          SharedPreferences sh = KindroidMessengerApplication.getSharedPrefs(context);
          boolean notiforNew =
              sh.getBoolean(
                  com.kindroid.kincent.util.Constant.SHARE_PREFS_PRIVACY_NOTIFY_FOR_NEW, true);
          if (notiforNew) {
            updateNotification();
            //						boolean vibrate = sh.getBoolean(Constant.SHARE_PREFS_PRIVACY_VIBRATE_NOTIFY,
            // false);
            //						if(vibrate){
            //							Vibrator  vibrator = (Vibrator)getApplication().getSystemService(Service
            // .VIBRATOR_SERVICE);
            //							vibrator.vibrate( new long[]{100,10,100,1000},-1);
            //							vibrator.cancel();
            //						}
          }
        }
        ContentValues cv = new ContentValues();
        long currentTime = System.currentTimeMillis();
        cv.put(
            PrivateDBHelper.PrivateCllIn.NAME, SafeUtils.getEncStr(context, item.getContactName()));
        cv.put(
            PrivateDBHelper.PrivateCllIn.NUMBER,
            SafeUtils.getEncStr(context, item.getPhoneNumber()));
        cv.put(PrivateDBHelper.PrivateCllIn.DATE, currentTime);
        cv.put(PrivateDBHelper.PrivateCllIn.BLOCKED_TYPE, item.getBlockedType());
        PrivacyDBUtils pdbUtils = PrivacyDBUtils.getInstance(context);
        pdbUtils.addCallIn(context, cv);

        Intent mIntent =
            new Intent(com.kindroid.kincent.util.Constant.PRIVACY_CALL_BROADCAST_ACTION);
        mIntent.putExtra(PrivateDBHelper.PrivateCllIn.NAME, item.getContactName());
        mIntent.putExtra(PrivateDBHelper.PrivateCllIn.NUMBER, item.getPhoneNumber());
        mIntent.putExtra(PrivateDBHelper.PrivateCllIn.DATE, currentTime);
        mIntent.putExtra(PrivateDBHelper.PrivateCllIn.BLOCKED_TYPE, item.getBlockedType());

        context.sendBroadcast(mIntent);
        break;
      }
    }
  }