支持标注卡槽号码(优先使用)、设备信息;自定义转发信息模版

This commit is contained in:
pppscn 2021-03-11 01:12:04 +08:00
parent 54380b63d1
commit 3a53f02850
32 changed files with 390 additions and 153 deletions

View File

@ -52,8 +52,9 @@ Android手机监听短信并根据指定规则转发到其他手机钉钉机
- [x] 兼容6.xx、7.xx、8.xx、9.xx、10.xx
- [x] 支持双卡手机,增加卡槽标识/运营商/手机号(如果能获取的话)
- [x] 支持多重匹配规则
- [x] 支持标注卡槽号码(优先使用)、设备信息;自定义转发信息模版
- [ ] 支持正则匹配规则
- [ ] 支持卡槽号码标注与匹配规则
- [ ] 支持卡槽匹配规则
- [ ] 转发规则、发送方配置导出与导入
### 使用流程:
@ -80,7 +81,7 @@ Android手机监听短信并根据指定规则转发到其他手机钉钉机
| ![前台服务常驻状态栏](pic/taskbar.jpg "前台服务常驻状态栏") | ![应用主界面](pic/main.jpg "应用主界面") |
| 转发规则 | 转发详情 |
| ![转发规则](pic/rule.jpg "转发规则") | ![转发详情](pic/maindetail.jpg "转发详情") |
| 添加/编辑转发规则 | 多重匹配规则 |
| 添加/编辑转发规则测试 | 多重匹配规则 |
| ![添加/编辑转发规则](pic/ruleset.jpg "添加/编辑转发规则") | ![多重匹配规则](pic/multimatch.jpg "多重匹配规则")|
| 支持以下转发方式(发送方) | 添加/编辑发送方钉钉 |
| ![发送方](pic/sender.jpg "发送方") | ![添加/编辑发送方钉钉](pic/sendersetdingding.jpg "添加/编辑发送方钉钉") |
@ -90,7 +91,7 @@ Android手机监听短信并根据指定规则转发到其他手机钉钉机
| ![添加/编辑发送方网页通知](pic/sendersetwebnotify.jpg "添加/编辑发送方网页通知") | ![添加/编辑发送方企业微信群机器人](pic/sendersetqywechat.jpg "添加/编辑发送方企业微信群机器人") |
| 添加/编辑发送方企业微信应用 | 应用设置 |
| ![添加/编辑发送方企业微信应用](pic/sendersetqywxapp.jpg "添加/编辑发送方企业微信应用") | ![应用设置](pic/setting.jpg "应用设置") |
| 在线升级 | 转发短信模板增加卡槽标识 |
| 关于/在线升级 | 转发短信模板增加卡槽标识 |
| ![在线升级](pic/update.jpg "在线升级") | ![转发短信模板增加卡槽标识](pic/siminfo.jpg "转发短信模板增加卡槽标识") |
@ -112,14 +113,17 @@ Android手机监听短信并根据指定规则转发到其他手机钉钉机
+ [v1.4.1](app/release/SmsForwarder_release_20210304_1.4.1.apk) 设置中允许关闭页面帮助/表单填写提示
+ [v1.5.0](app/release/SmsForwarder_release_20210305_1.5.0.apk) 新增转发到企业微信应用消息
+ [v1.5.1](app/release/SmsForwarder_release_20210310_1.5.1.apk) 解决Android 9.xx、10.xx收不到广播问题
+ [v1.5.2](app/release/SmsForwarder_release_20210311_1.5.2.apk) 支持标注卡槽号码(优先使用)、设备信息;自定义转发信息模版
--------
## 反馈与建议:
+ QQ交流群562854376
![QQ交流群562854376](pic/qqgroup.jpg "QQ交流群562854376")
+ 提交issues 或 pr
| | |
| ---- | ---- |
| QQ交流群562854376 | 提交issues 或 pr |
| ![QQ交流群562854376](pic/qqgroup.jpg "QQ交流群562854376") | ![QQ交流群562854376](pic/about.jpg "QQ交流群562854376") |
## LICENSE
BSD

Binary file not shown.

View File

@ -10,9 +10,9 @@
{
"type": "SINGLE",
"filters": [],
"versionCode": 14,
"versionName": "1.5.1",
"outputFile": "SmsForwarder_release_20210310_1.5.1.apk"
"versionCode": 15,
"versionName": "1.5.2",
"outputFile": "SmsForwarder_release_20210311_1.5.2.apk"
}
]
}

View File

@ -10,6 +10,7 @@ import android.util.Log;
import com.idormy.sms.forwarder.MyApplication;
import com.idormy.sms.forwarder.model.vo.SmsVo;
import com.idormy.sms.forwarder.sender.SendUtil;
import com.idormy.sms.forwarder.utils.SettingUtil;
import com.idormy.sms.forwarder.utils.SimUtil;
import java.util.ArrayList;
@ -35,12 +36,19 @@ public class SmsForwarderBroadcastReceiver extends BroadcastReceiver {
if (object != null) {
//获取接收手机号
String phoneNumber = "";
String simInfo = "";
try {
//获取卡槽ID
String simInfoId = String.valueOf(SimUtil.getSimId(extras));
Map<String, String> sim = MyApplication.SimInfo.get(simInfoId);
int sim_id = Integer.parseInt(sim.get("sim_id")) + 1;
phoneNumber = "SIM" + sim_id + "_" + sim.get("carrier_name") + "_" + sim.get("phone_number");
simInfo = sim_id == 2 ? SettingUtil.getAddExtraSim2() : SettingUtil.getAddExtraSim1();
if (!simInfo.isEmpty()) {
simInfo = "SIM" + sim_id + "_" + simInfo;
} else {
simInfo = "SIM" + sim_id + "_" + sim.get("carrier_name") + "_" + sim.get("phone_number");
}
} catch (Exception e) {
Log.e(TAG, "获取接收手机号失败:" + e.getMessage());
}
@ -67,7 +75,7 @@ public class SmsForwarderBroadcastReceiver extends BroadcastReceiver {
}
for (String mobile : mobileToContent.keySet()) {
smsVoList.add(new SmsVo(mobile, mobileToContent.get(mobile), date, phoneNumber));
smsVoList.add(new SmsVo(mobile, mobileToContent.get(mobile), date, simInfo));
}
Log.d(TAG, "短信:" + smsVoList);
SendUtil.send_msg_list(context, smsVoList);

View File

@ -1,14 +1,11 @@
package com.idormy.sms.forwarder;
import android.Manifest;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.telephony.TelephonyManager;
@ -29,13 +26,12 @@ import com.idormy.sms.forwarder.BroadCastReceiver.SmsForwarderBroadcastReceiver;
import com.idormy.sms.forwarder.adapter.LogAdapter;
import com.idormy.sms.forwarder.model.vo.LogVo;
import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.SimUtil;
import com.idormy.sms.forwarder.utils.aUtil;
import com.umeng.analytics.MobclickAgent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MainActivity extends AppCompatActivity implements ReFlashListView.IReflashListener {
@ -67,9 +63,8 @@ public class MainActivity extends AppCompatActivity implements ReFlashListView.I
}
//获取SIM卡信息
getSimInfo(Line1Number);
//MyApplication appContext = ((MyApplication) getApplicationContext());
//appContext.setSimInfo(SimInfo);
MyApplication appContext = ((MyApplication) getApplicationContext());
SimUtil.getSimInfo(appContext, Line1Number);
setContentView(R.layout.activity_main);
LogUtil.init(this);
@ -303,37 +298,4 @@ public class MainActivity extends AppCompatActivity implements ReFlashListView.I
MobclickAgent.onPause(this);
}
//获取SIM卡信息
private void getSimInfo(String Line1Number) {
try {
Uri uri = Uri.parse("content://telephony/siminfo"); //访问raw_contacts表
MyApplication appContext = ((MyApplication) getApplicationContext());
ContentResolver resolver = appContext.getContentResolver();
Cursor cursor = resolver.query(uri, new String[]{"_id", "icc_id", "sim_id", "display_name", "carrier_name", "name_source", "color", "number", "display_number_format", "data_roaming", "mcc", "mnc"}, "sim_id >= 0", null, "_id");
if (cursor != null) {
while (cursor.moveToNext()) {
Log.d(TAG, "_id: " + cursor.getString(cursor.getColumnIndex("_id")));
Log.d(TAG, "sim_id: " + cursor.getString(cursor.getColumnIndex("sim_id")));
Log.d(TAG, "carrier_name: " + cursor.getString(cursor.getColumnIndex("carrier_name")));
Log.d(TAG, "display_name: " + cursor.getString(cursor.getColumnIndex("display_name")));
Map<String, String> sim = new HashMap();
String id = cursor.getString(cursor.getColumnIndex("_id"));
sim.put("_id", id);
sim.put("sim_id", cursor.getString(cursor.getColumnIndex("sim_id")));
sim.put("carrier_name", cursor.getString(cursor.getColumnIndex("carrier_name")));
sim.put("display_name", cursor.getString(cursor.getColumnIndex("display_name")));
sim.put("phone_number", Line1Number);
if (Line1Number != "Unknown") {
Line1Number = "Unknown";
}
MyApplication.SimInfo.put(id, sim);
}
cursor.close();
}
} catch (Exception e) {
Log.e(TAG, "getSimInfo fail" + e.getMessage());
Toast.makeText(MainActivity.this, "获取SIM卡信息失败请先手动设置", Toast.LENGTH_LONG).show();
}
}
}

View File

@ -26,6 +26,7 @@ import com.idormy.sms.forwarder.model.vo.SmsVo;
import com.idormy.sms.forwarder.sender.SendUtil;
import com.idormy.sms.forwarder.sender.SenderUtil;
import com.idormy.sms.forwarder.utils.RuleUtil;
import com.idormy.sms.forwarder.utils.SettingUtil;
import com.umeng.analytics.MobclickAgent;
import java.util.ArrayList;
@ -332,7 +333,7 @@ public class RuleActivity extends AppCompatActivity {
Button buttonruletest = view.findViewById(R.id.buttonruletest);
AlertDialog.Builder ad1 = new AlertDialog.Builder(RuleActivity.this);
ad1.setTitle("测试规则");
ad1.setIcon(android.R.drawable.ic_dialog_info);
ad1.setIcon(android.R.drawable.ic_dialog_email);
ad1.setView(view);
buttonruletest.setOnClickListener(new View.OnClickListener() {
@Override
@ -342,7 +343,8 @@ public class RuleActivity extends AppCompatActivity {
Log.i("editTextTestMsgContent", editTextTestMsgContent.getText().toString());
try {
SmsVo testSmsVo = new SmsVo(editTextTestPhone.getText().toString(), editTextTestMsgContent.getText().toString(), new Date(), editTextTestPhone.getText().toString());
String simInfo = "SIM1_" + SettingUtil.getAddExtraSim1();
SmsVo testSmsVo = new SmsVo(editTextTestPhone.getText().toString(), editTextTestMsgContent.getText().toString(), new Date(), simInfo);
SendUtil.sendMsgByRuleModelSenderId(handler, ruleModel, testSmsVo, senderId);
} catch (Exception e) {
Toast.makeText(RuleActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();

View File

@ -516,7 +516,7 @@ public class SenderActivity extends AppCompatActivity {
String barkServer = editTextBarkServer.getText().toString();
if (!barkServer.isEmpty()) {
try {
SenderBarkMsg.sendMsg(handler, barkServer, "19999999999", "【京东】验证码为387481切勿将验证码告知他人请在页面中输入完成验证如有问题请点击 ihelp.jd.com 联系京东客服", "18888888888");
SenderBarkMsg.sendMsg(handler, barkServer, "19999999999", "【京东】验证码为387481切勿将验证码告知他人请在页面中输入完成验证如有问题请点击 ihelp.jd.com 联系京东客服");
} catch (Exception e) {
Toast.makeText(SenderActivity.this, "发送失败:" + e.getMessage(), Toast.LENGTH_LONG).show();
e.printStackTrace();

View File

@ -4,8 +4,10 @@ import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Switch;
import androidx.appcompat.app.AppCompatActivity;
@ -33,6 +35,12 @@ public class SettingActivity extends AppCompatActivity {
EditText et_add_extra_sim2 = (EditText) findViewById(R.id.et_add_extra_sim2);
editAddExtraSim2(et_add_extra_sim2);
Switch switch_sms_template = (Switch) findViewById(R.id.switch_sms_template);
switchSmsTemplate(switch_sms_template);
EditText textSmsTemplate = (EditText) findViewById(R.id.text_sms_template);
editSmsTemplate(textSmsTemplate);
}
//设置转发附加信息
@ -66,7 +74,6 @@ public class SettingActivity extends AppCompatActivity {
@Override
public void afterTextChanged(Editable s) {
SettingUtil.setAddExtraDeviceMark(et_add_extra_device_mark.getText().toString());
}
});
}
@ -89,7 +96,6 @@ public class SettingActivity extends AppCompatActivity {
@Override
public void afterTextChanged(Editable s) {
SettingUtil.setAddExtraSim1(et_add_extra_sim1.getText().toString());
}
});
}
@ -112,10 +118,80 @@ public class SettingActivity extends AppCompatActivity {
@Override
public void afterTextChanged(Editable s) {
SettingUtil.setAddExtraSim2(et_add_extra_sim2.getText().toString());
}
});
}
//设置转发时启用自定义模版
private void switchSmsTemplate(Switch switch_sms_template) {
boolean isOn = SettingUtil.getSwitchSmsTemplate();
switch_sms_template.setChecked(isOn);
final LinearLayout layout_sms_template = (LinearLayout) findViewById(R.id.layout_sms_template);
layout_sms_template.setVisibility(isOn ? View.VISIBLE : View.GONE);
final EditText textSmsTemplate = (EditText) findViewById(R.id.text_sms_template);
switch_sms_template.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Log.d(TAG, "onCheckedChanged:" + isChecked);
layout_sms_template.setVisibility(isChecked ? View.VISIBLE : View.GONE);
SettingUtil.switchSmsTemplate(isChecked);
if (!isChecked) {
textSmsTemplate.setText("{{来源号码}}\n{{短信内容}}\n{{卡槽信息}}\n{{接收时间}}\n{{设备名称}}");
}
}
});
}
//设置转发附加信息devicemark
private void editSmsTemplate(final EditText textSmsTemplate) {
textSmsTemplate.setText(SettingUtil.getSmsTemplate());
textSmsTemplate.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
SettingUtil.setSmsTemplate(textSmsTemplate.getText().toString());
}
});
}
//插入标签
public void toInsertLabel(View v) {
EditText textSmsTemplate = (EditText) findViewById(R.id.text_sms_template);
textSmsTemplate.setFocusable(true);
textSmsTemplate.requestFocus();
switch (v.getId()) {
case R.id.bt_insert_sender:
textSmsTemplate.append("{{来源号码}}");
return;
/*case R.id.bt_insert_receiver:
textSmsTemplate.append("{{接收号码}}");
return;*/
case R.id.bt_insert_content:
textSmsTemplate.append("{{短信内容}}");
return;
case R.id.bt_insert_extra:
textSmsTemplate.append("{{卡槽信息}}");
return;
case R.id.bt_insert_time:
textSmsTemplate.append("{{接收时间}}");
case R.id.bt_insert_device_name:
textSmsTemplate.append("{{设备名称}}");
return;
default:
return;
}
}
}

View File

@ -1,5 +1,7 @@
package com.idormy.sms.forwarder.model.vo;
import com.idormy.sms.forwarder.utils.SettingUtil;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
@ -8,16 +10,16 @@ public class SmsVo implements Serializable {
String mobile;
String content;
Date date;
String phoneNumber = "本机号码:未知";
String simInfo = "本机号码:未知";
public SmsVo() {
}
public SmsVo(String mobile, String content, Date date, String phoneNumber) {
public SmsVo(String mobile, String content, Date date, String simInfo) {
this.mobile = mobile;
this.content = content;
this.date = date;
this.phoneNumber = phoneNumber;
this.simInfo = simInfo;
}
public String getMobile() {
@ -44,19 +46,32 @@ public class SmsVo implements Serializable {
this.date = date;
}
public String getPhoneNumber() {
return phoneNumber;
public String getSimInfo() {
return simInfo;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
public void setSimInfo(String simInfo) {
this.simInfo = simInfo;
}
public String getSmsVoForSend() {
return mobile + "\n" +
content + "\n" +
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date) + "\n" +
phoneNumber;
boolean switchAddExtra = SettingUtil.getSwitchAddExtra();
boolean switchSmsTemplate = SettingUtil.getSwitchSmsTemplate();
String smsTemplate = SettingUtil.getSmsTemplate().trim();
String deviceMark = SettingUtil.getAddExtraDeviceMark().trim();
if (!switchAddExtra) {
smsTemplate = smsTemplate.replace("{{卡槽信息}}\n", "").replace("{{卡槽信息}}", "");
}
if (!switchSmsTemplate) {
smsTemplate = "{{来源号码}}\n{{短信内容}}\n{{卡槽信息}}\n{{接收时间}}\n{{设备名称}}";
}
return smsTemplate.replace("{{来源号码}}", mobile)
.replace("{{短信内容}}", content)
.replace("{{卡槽信息}}", simInfo)
.replace("{{接收时间}}", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date))
.replace("{{设备名称}}", deviceMark)
.trim();
}
@Override
@ -65,7 +80,7 @@ public class SmsVo implements Serializable {
"mobile='" + mobile + '\'' +
", content='" + content + '\'' +
", date=" + date +
", phoneNumber=" + phoneNumber +
", simInfo=" + simInfo +
'}';
}
}

View File

@ -68,7 +68,7 @@ public class SendUtil {
List<SenderModel> senderModels = SenderUtil.getSender(ruleModel.getSenderId(), null);
for (SenderModel senderModel : senderModels
) {
LogUtil.addLog(new LogModel(smsVo.getMobile(), smsVo.getContent(), smsVo.getPhoneNumber(), senderModel.getId()));
LogUtil.addLog(new LogModel(smsVo.getMobile(), smsVo.getContent(), smsVo.getSimInfo(), senderModel.getId()));
SendUtil.senderSendMsgNoHandError(smsVo, senderModel);
}
}
@ -117,7 +117,6 @@ public class SendUtil {
} catch (Exception e) {
Log.e(TAG, "senderSendMsg: dingding error " + e.getMessage());
}
}
}
break;
@ -133,7 +132,6 @@ public class SendUtil {
} catch (Exception e) {
Log.e(TAG, "senderSendMsg: SenderMailMsg error " + e.getMessage());
}
}
}
break;
@ -144,11 +142,10 @@ public class SendUtil {
BarkSettingVo barkSettingVo = JSON.parseObject(senderModel.getJsonSetting(), BarkSettingVo.class);
if (barkSettingVo != null) {
try {
SenderBarkMsg.sendMsg(handError, barkSettingVo.getServer(), smsVo.getMobile(), smsVo.getContent(), smsVo.getPhoneNumber());
SenderBarkMsg.sendMsg(handError, barkSettingVo.getServer(), smsVo.getMobile(), smsVo.getSmsVoForSend());
} catch (Exception e) {
Log.e(TAG, "senderSendMsg: SenderBarkMsg error " + e.getMessage());
}
}
}
break;
@ -163,7 +160,6 @@ public class SendUtil {
} catch (Exception e) {
Log.e(TAG, "senderSendMsg: SenderWebNotifyMsg error " + e.getMessage());
}
}
}
break;
@ -178,7 +174,6 @@ public class SendUtil {
} catch (Exception e) {
Log.e(TAG, "senderSendMsg: SenderQyWxGroupRobotMsg error " + e.getMessage());
}
}
}
break;
@ -193,7 +188,6 @@ public class SendUtil {
} catch (Exception e) {
Log.e(TAG, "senderSendMsg: qywx_app error " + e.getMessage());
}
}
}
break;

View File

@ -22,14 +22,16 @@ public class SenderBarkMsg {
static String TAG = "SenderBarkMsg";
public static void sendMsg(final Handler handError, String barkServer, String from, String content, String phoneNumber) throws Exception {
Log.i(TAG, "sendMsg barkServer:" + barkServer + " from:" + from + " content:" + content + " phoneNumber:" + phoneNumber);
public static void sendMsg(final Handler handError, String barkServer, String from, String content) throws Exception {
Log.i(TAG, "sendMsg barkServer:" + barkServer + " from:" + from + " content:" + content);
if (barkServer == null || barkServer.isEmpty()) {
return;
}
content += "\n[" + phoneNumber + "]";
//特殊处理避免标题重复
content = content.replaceFirst("^" + from + "(.*)", "").trim();
barkServer += URLEncoder.encode(from, "UTF-8");
barkServer += "/" + URLEncoder.encode(content, "UTF-8");
barkServer += "?isArchive=1"; //自动保存

View File

@ -9,6 +9,8 @@ public class Define {
public static String SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_MARK = "tsms_msg_key_string_add_extra_device_mark";
public static String SP_MSG_KEY_STRING_ADD_EXTRA_SIM1 = "tsms_msg_key_string_add_extra_sim1";
public static String SP_MSG_KEY_STRING_ADD_EXTRA_SIM2 = "tsms_msg_key_string_add_extra_sim2";
public static String SP_MSG_KEY_SWITCH_SMS_TEMPLATE = "tsms_msg_key_switch_sms_template";
public static String SP_MSG_KEY_STRING_SMS_TEMPLATE = "tsms_msg_key_string_sms_template";
public static String SP_MSG = "forwarder_msg";
public static String SP_MSG_SET_KEY = "forwarder_msg_set_key";

View File

@ -32,6 +32,17 @@ public class SettingUtil {
return sp_setting.getBoolean(Define.SP_MSG_KEY_SWITCH_ADD_EXTRA, false);
}
public static void switchSmsTemplate(Boolean switchSmsTemplate) {
Log.d(TAG, "switchSmsTemplate :" + switchSmsTemplate);
sp_setting.edit()
.putBoolean(Define.SP_MSG_KEY_SWITCH_SMS_TEMPLATE, switchSmsTemplate)
.apply();
}
public static boolean getSwitchSmsTemplate() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_SWITCH_SMS_TEMPLATE, false);
}
public static String getAddExtraDeviceMark() {
return sp_setting.getString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_MARK, "");
}
@ -43,6 +54,17 @@ public class SettingUtil {
.apply();
}
public static String getSmsTemplate() {
return sp_setting.getString(Define.SP_MSG_KEY_STRING_SMS_TEMPLATE, "{{来源号码}}\n{{短信内容}}\n{{卡槽信息}}\n{{接收时间}}\n{{设备名称}}");
}
public static void setSmsTemplate(String textSmsTemplate) {
Log.d(TAG, "textSmsTemplate :" + textSmsTemplate);
sp_setting.edit()
.putString(Define.SP_MSG_KEY_STRING_SMS_TEMPLATE, textSmsTemplate)
.apply();
}
public static String getAddExtraSim1() {
return sp_setting.getString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM1, "");
}

View File

@ -1,8 +1,16 @@
package com.idormy.sms.forwarder.utils;
import android.content.ContentResolver;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import com.idormy.sms.forwarder.MyApplication;
import java.util.HashMap;
import java.util.Map;
public class SimUtil {
private static String TAG = "SimUtil";
@ -41,4 +49,37 @@ public class SimUtil {
Log.d(TAG, " Slot Number " + whichSIM);
return whichSIM;
}
//获取SIM卡信息
public static void getSimInfo(MyApplication appContext, String Line1Number) {
try {
Uri uri = Uri.parse("content://telephony/siminfo"); //访问raw_contacts表
ContentResolver resolver = appContext.getContentResolver();
Cursor cursor = resolver.query(uri, new String[]{"_id", "icc_id", "sim_id", "display_name", "carrier_name", "name_source", "color", "number", "display_number_format", "data_roaming", "mcc", "mnc"}, "sim_id >= 0", null, "_id");
if (cursor != null) {
while (cursor.moveToNext()) {
Log.d(TAG, "_id: " + cursor.getString(cursor.getColumnIndex("_id")));
Log.d(TAG, "sim_id: " + cursor.getString(cursor.getColumnIndex("sim_id")));
Log.d(TAG, "carrier_name: " + cursor.getString(cursor.getColumnIndex("carrier_name")));
Log.d(TAG, "display_name: " + cursor.getString(cursor.getColumnIndex("display_name")));
Map<String, String> sim = new HashMap();
String id = cursor.getString(cursor.getColumnIndex("_id"));
sim.put("_id", id);
sim.put("sim_id", cursor.getString(cursor.getColumnIndex("sim_id")));
sim.put("carrier_name", cursor.getString(cursor.getColumnIndex("carrier_name")));
sim.put("display_name", cursor.getString(cursor.getColumnIndex("display_name")));
sim.put("phone_number", Line1Number);
if (Line1Number != "Unknown") {
Line1Number = "Unknown";
}
MyApplication.SimInfo.put(id, sim);
}
cursor.close();
}
} catch (Exception e) {
Log.e(TAG, "getSimInfo fail" + e.getMessage());
//Toast.makeText(MainActivity.this, "获取SIM卡信息失败请先手动设置", Toast.LENGTH_LONG).show();
}
}
}

View File

@ -111,7 +111,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="作者网站" />
android:text="开源地址" />
<TextView
android:id="@+id/linkweb"
@ -120,8 +120,8 @@
android:layout_weight="3"
android:autoLink="web"
android:gravity="right"
android:text="idormy.com"
android:textSize="18sp" />
android:text="https://github.com/pppscn/SmsForwarder"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -8,31 +9,6 @@
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="15dp">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="转发时附加卡槽信息"
android:textStyle="bold" />
<Switch
android:id="@+id/switch_add_extra"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="end"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -137,6 +113,31 @@
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="15dp">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="转发时附加卡槽信息"
android:textStyle="bold" />
<Switch
android:id="@+id/switch_add_extra"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="end"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -163,16 +164,124 @@
</LinearLayout>
<EditText
android:id="@+id/text_sms_template"
<LinearLayout
android:id="@+id/layout_sms_template"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:ems="16"
android:inputType=""
android:maxLines="5"
android:text="" />
android:layout_marginTop="2dp"
android:background="@android:color/white"
android:gravity="center_vertical"
android:orientation="vertical"
android:padding="15dp"
android:visibility="gone">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="转发信息模版"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="Tip按需插入内容标签留空使用默认模版"
android:textSize="11dp" />
</LinearLayout>
<EditText
android:id="@+id/text_sms_template"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType=""
android:text="" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/bt_insert_sender"
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_weight="1"
android:background="@color/colorPrimary"
android:onClick="toInsertLabel"
android:text="来源号码"
tools:ignore="NestedWeights" />
<!--<Button
android:id="@+id/bt_insert_receiver"
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_weight="1"
android:background="@color/colorPrimary"
android:onClick="toInsertLabel"
android:text="接收号码"
tools:ignore="NestedWeights" />-->
<Button
android:id="@+id/bt_insert_content"
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_weight="1"
android:background="@color/colorPrimary"
android:onClick="toInsertLabel"
android:text="短信内容" />
<Button
android:id="@+id/bt_insert_extra"
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_weight="1"
android:background="@color/colorPrimary"
android:onClick="toInsertLabel"
android:text="卡槽信息" />
<Button
android:id="@+id/bt_insert_time"
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_weight="1"
android:background="@color/colorPrimary"
android:onClick="toInsertLabel"
android:text="接收时间" />
<Button
android:id="@+id/bt_insert_device_name"
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_weight="1"
android:background="@color/colorPrimary"
android:onClick="toInsertLabel"
android:text="设备名称" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>

View File

@ -1,51 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:text="测试模拟的手机号" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:text="测试模拟的手机号" />
<EditText
android:id="@+id/editTextTestPhone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:ems="10"
android:inputType=""
android:text="" />
<EditText
android:id="@+id/editTextTestPhone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:ems="10"
android:inputType=""
android:text="" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:text="测试模拟的短信内容" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:text="测试模拟的短信内容" />
<EditText
android:id="@+id/editTextTestMsgContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:ems="10"
android:inputType=""
android:text="" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<EditText
android:id="@+id/editTextTestMsgContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:ems="10"
android:inputType=""
android:text="" />
</LinearLayout>
<Button
android:id="@+id/buttonruletest"
@ -57,4 +57,4 @@
</LinearLayout>
</LinearLayout>
</ScrollView>

BIN
pic/about.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 481 KiB

After

Width:  |  Height:  |  Size: 243 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 289 KiB

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 417 KiB

After

Width:  |  Height:  |  Size: 330 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 322 KiB

After

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 KiB

After

Width:  |  Height:  |  Size: 238 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 206 KiB

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 239 KiB

After

Width:  |  Height:  |  Size: 198 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 311 KiB

After

Width:  |  Height:  |  Size: 272 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 248 KiB

After

Width:  |  Height:  |  Size: 206 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 257 KiB

After

Width:  |  Height:  |  Size: 216 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 274 KiB

After

Width:  |  Height:  |  Size: 233 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 247 KiB

After

Width:  |  Height:  |  Size: 206 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 154 KiB

After

Width:  |  Height:  |  Size: 256 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 KiB

After

Width:  |  Height:  |  Size: 195 KiB