Exemplo n.º 1
0
 private void sendAutoMsg(String incomingNumber) {
   SharedPreferences sh = KindroidMessengerApplication.getSharedPrefs(context);
   boolean autoSendMsg =
       sh.getBoolean(com.kindroid.kincent.util.Constant.SHARE_PREFS_PRIVACY_AUTO_SEND_MSG, false);
   if (autoSendMsg) {
     PrivacyDBUtils pdbUtils = PrivacyDBUtils.getInstance(context);
     String autoMsg = pdbUtils.getAutoMsg();
     if (autoMsg != null) {
       SmsManager smsManager = SmsManager.getDefault();
       smsManager.sendTextMessage(incomingNumber, null, autoMsg, null, null);
     }
   }
 }
Exemplo n.º 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;
      }
    }
  }