更新短信接收规则设定:
1.启用了只接受通讯录,通讯录里有记录 2.如果不是数字通讯地址,但是在通讯录内 3.通讯地址是数字,并且在短信接收规则内。 以上3种情况就接收,其他一律放到回收站。
This commit is contained in:
@@ -77,21 +77,30 @@ public class SMSRecevier extends BroadcastReceiver {
|
||||
PhoneUtil phoneUtil = new PhoneUtil(context);
|
||||
boolean isPhoneInContacts = phoneUtil.isPhoneInContacts(szSmsAddress);
|
||||
LogUtils.d(TAG, String.format("isPhoneInContacts %s", isPhoneInContacts));
|
||||
|
||||
|
||||
boolean isPhoneByDigit = phoneUtil.isPhoneByDigit(szSmsAddress);
|
||||
LogUtils.d(TAG, String.format("isPhoneByDigit %s", isPhoneByDigit));
|
||||
|
||||
|
||||
AppConfigUtil configUtil = AppConfigUtil.getInstance(context);
|
||||
boolean isOnlyReceiveContacts = configUtil.mAppConfigBean.isEnableOnlyReceiveContacts();
|
||||
LogUtils.d(TAG, String.format("isOnlyReceiveContacts %s", isOnlyReceiveContacts));
|
||||
|
||||
|
||||
boolean isInSMSAcceptRule = SMSReceiveRuleUtil.getInstance(context, false).checkIsSMSAcceptInRule(context, szSmsBody);
|
||||
LogUtils.d(TAG, String.format("isInSMSAcceptRule %s", isInSMSAcceptRule));
|
||||
|
||||
if (isPhoneByDigit
|
||||
&& (!isOnlyReceiveContacts || isPhoneInContacts || isInSMSAcceptRule)) {
|
||||
|
||||
// 启用了只接受通讯录,通讯录里有记录
|
||||
if (isOnlyReceiveContacts && isPhoneInContacts) {
|
||||
return true;
|
||||
}
|
||||
// 如果不是数字通讯地址,但是在通讯录内
|
||||
if (!isPhoneByDigit && isPhoneInContacts) {
|
||||
return true;
|
||||
}
|
||||
// 通讯地址是数字,并且在短信接收规则内。
|
||||
if (isPhoneByDigit && isInSMSAcceptRule) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -19,6 +19,10 @@ public class SMSRecevier_Test {
|
||||
String szSmsAddress = "无名小辈";
|
||||
test1(context, szSmsBody, szSmsAddress);
|
||||
|
||||
szSmsBody = "无影无迹";
|
||||
szSmsAddress = "淘宝物流";
|
||||
test1(context, szSmsBody, szSmsAddress);
|
||||
|
||||
szSmsBody = "无影无迹";
|
||||
szSmsAddress = "1?0";
|
||||
test1(context, szSmsBody, szSmsAddress);
|
||||
|
@@ -5,11 +5,11 @@ package cc.winboll.studio.mymessagemanager.unittest;
|
||||
* @Date 2025/02/25 19:00:10
|
||||
* @Describe 应用单元测试窗口
|
||||
*/
|
||||
import cc.winboll.studio.mymessagemanager.unittest.*;
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import cc.winboll.studio.mymessagemanager.R;
|
||||
import android.view.View;
|
||||
import cc.winboll.studio.mymessagemanager.R;
|
||||
import cc.winboll.studio.shared.log.LogUtils;
|
||||
import cc.winboll.studio.shared.log.LogView;
|
||||
|
||||
public class UnitTestActivity extends Activity {
|
||||
@@ -28,7 +28,9 @@ public class UnitTestActivity extends Activity {
|
||||
}
|
||||
|
||||
public void onMain(View view) {
|
||||
//SMSRecevier_Test.main(this);
|
||||
LogUtils.d(TAG, "SMSRecevier_Test");
|
||||
SMSRecevier_Test.main(this);
|
||||
LogUtils.d(TAG, "AddressUtils_Test");
|
||||
AddressUtils_Test.main(this);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user