整理:文件命名统一规范

新增:引入frpclib.aar
pull/153/head
pppscn 2 years ago
parent 3c32b696c8
commit 55a5e15d48

@ -122,6 +122,7 @@
+ https://github.com/getActivity/XXPermissions (权限请求框架)
+ https://github.com/Xcreen/RestSMS 被动接收本地API方案
+ ~~https://github.com/juancrescente/SMSHub 主动轮询远程API方案v2.5.0+删除)~~
+ https://github.com/mainfunx/frpc_android (内网穿透)
+ [<img src="https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg?_ga=2.126618957.1361252949.1638261367-1417196221.1635638144&_gl=1*1pfl3dq*_ga*MTQxNzE5NjIyMS4xNjM1NjM4MTQ0*_ga_V0XZL7QHEB*MTYzODMzMjA4OC43LjAuMTYzODMzMjA5Ny4w" alt="GitHub license" style="zoom:50%;" />](https://jb.gg/OpenSourceSupport) (License Certificate for JetBrains All Products Pack)
--------

@ -124,6 +124,7 @@ Benefit by simplicity:
+ https://github.com/getActivity/XXPermissions (permission requiring)
+ https://github.com/Xcreen/RestSMS被动接收本地API方案
+ ~~https://github.com/juancrescente/SMSHub主动轮询远程API方案v2.5.0+删除)~~
+ https://github.com/mainfunx/frpc_android (内网穿透)
+ [<img src="https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg?_ga=2.126618957.1361252949.1638261367-1417196221.1635638144&_gl=1*1pfl3dq*_ga*MTQxNzE5NjIyMS4xNjM1NjM4MTQ0*_ga_V0XZL7QHEB*MTYzODMzMjA4OC43LjAuMTYzODMzMjA5Ny4w" alt="GitHub license" style="zoom:50%;" />](https://jb.gg/OpenSourceSupport) (License Certificate for JetBrains All Products Pack)
--------

@ -92,6 +92,13 @@ android {
lint {
checkReleaseBuilds false
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
}
@ -150,7 +157,7 @@ dependencies {
implementation 'com.squareup.okio:okio:3.0.0'
//fastjson
implementation "com.alibaba:fastjson:1.2.79"
implementation "com.alibaba:fastjson:1.2.80"
//XUpdate
implementation 'com.github.xuexiangjys:XUpdate:2.1.1'
@ -179,11 +186,25 @@ dependencies {
implementation 'com.github.getActivity:XXPermissions:13.2'
//jetty
implementation "org.eclipse.jetty:jetty-server:9.2.30.v20200428"
implementation "org.eclipse.jetty:jetty-servlet:9.2.30.v20200428"
def jetty_version = '9.2.30.v20200428'
//noinspection GradleDependency
implementation "org.eclipse.jetty:jetty-server:$jetty_version"
//noinspection GradleDependency
implementation "org.eclipse.jetty:jetty-servlet:$jetty_version"
//SDK
implementation 'com.umeng.umsdk:common:9.4.7'// ()
implementation 'com.umeng.umsdk:asms:1.6.0'//
//frpc
//implementation(name: 'frpclib', ext: 'aar')
implementation files('libs/frpclib.aar')
implementation 'io.github.jeremyliao:live-event-bus-x:1.8.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.21'
def room_version = "2.4.2"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-rxjava2:$room_version"
}

Binary file not shown.

Binary file not shown.

@ -12,9 +12,9 @@ import com.hjq.permissions.Permission;
import com.hjq.permissions.XXPermissions;
import com.hjq.toast.ToastUtils;
import com.idormy.sms.forwarder.receiver.RebootBroadcastReceiver;
import com.idormy.sms.forwarder.utils.CacheUtil;
import com.idormy.sms.forwarder.utils.CacheUtils;
import com.idormy.sms.forwarder.utils.CommonUtil;
import com.idormy.sms.forwarder.utils.SettingUtil;
import com.idormy.sms.forwarder.utils.SettingUtils;
import com.xuexiang.xupdate.easy.EasyUpdate;
import com.xuexiang.xupdate.proxy.impl.DefaultUpdateChecker;
@ -46,7 +46,7 @@ public class AboutActivity extends BaseActivity {
} else {
ToastUtils.show(R.string.toast_granted_part);
}
SettingUtil.switchEnableSms(true);
SettingUtils.switchEnableSms(true);
}
@Override
@ -58,7 +58,7 @@ public class AboutActivity extends BaseActivity {
} else {
ToastUtils.show(R.string.toast_denied);
}
SettingUtil.switchEnableSms(false);
SettingUtils.switchEnableSms(false);
}
});
@ -100,15 +100,15 @@ public class AboutActivity extends BaseActivity {
final TextView cache_size = findViewById(R.id.cache_size);
try {
cache_size.setText(CacheUtil.getTotalCacheSize(AboutActivity.this));
cache_size.setText(CacheUtils.getTotalCacheSize(AboutActivity.this));
} catch (Exception e) {
e.printStackTrace();
}
Button clear_all_cache = findViewById(R.id.clear_all_cache);
clear_all_cache.setOnClickListener(v -> {
CacheUtil.clearAllCache(AboutActivity.this);
CacheUtils.clearAllCache(AboutActivity.this);
try {
cache_size.setText(CacheUtil.getTotalCacheSize(AboutActivity.this));
cache_size.setText(CacheUtils.getTotalCacheSize(AboutActivity.this));
} catch (Exception e) {
e.printStackTrace();
}

@ -12,8 +12,6 @@ import java.lang.reflect.Method;
public class BaseActivity extends AppCompatActivity {
private final String TAG = "BaseActivity";
//启用menu
@Override
public boolean onCreateOptionsMenu(Menu menu) {
@ -37,8 +35,6 @@ public class BaseActivity extends AppCompatActivity {
intent = new Intent(this, AboutActivity.class);
break;
case R.id.to_help:
//Uri uri = Uri.parse("https://gitee.com/pp/SmsForwarder/wikis/pages");
//intent = new Intent(Intent.ACTION_VIEW, uri);
intent = new Intent(this, HelpActivity.class);
break;
default:
@ -52,6 +48,7 @@ public class BaseActivity extends AppCompatActivity {
//设置menu图标显示
@Override
public boolean onMenuOpened(int featureId, Menu menu) {
String TAG = "BaseActivity";
Log.d(TAG, "onMenuOpened, featureId=" + featureId);
if (menu != null) {
if (menu.getClass().getSimpleName().equals("MenuBuilder")) {

@ -26,9 +26,9 @@ import com.idormy.sms.forwarder.sender.HttpServer;
import com.idormy.sms.forwarder.utils.CloneUtils;
import com.idormy.sms.forwarder.utils.Define;
import com.idormy.sms.forwarder.utils.FileUtils;
import com.idormy.sms.forwarder.utils.HttpUtil;
import com.idormy.sms.forwarder.utils.NetUtil;
import com.idormy.sms.forwarder.utils.SettingUtil;
import com.idormy.sms.forwarder.utils.HttpUtils;
import com.idormy.sms.forwarder.utils.NetUtils;
import com.idormy.sms.forwarder.utils.SettingUtils;
import com.idormy.sms.forwarder.view.IPEditText;
import java.io.File;
@ -67,7 +67,7 @@ public class CloneActivity extends BaseActivity {
setContentView(R.layout.activity_clone);
Log.d(TAG, "onCreate: " + RebootBroadcastReceiver.class.getName());
HttpUtil.init(this);
HttpUtils.init(this);
HttpServer.init(this);
}
@ -120,7 +120,7 @@ public class CloneActivity extends BaseActivity {
receiveTxt = findViewById(R.id.receiveTxt);
Button receiveBtn = findViewById(R.id.receiveBtn);
serverIp = NetUtil.getLocalIp(CloneActivity.this);
serverIp = NetUtils.getLocalIp(CloneActivity.this);
ipText.setText(serverIp);
if (HttpServer.asRunning()) {
@ -134,14 +134,14 @@ public class CloneActivity extends BaseActivity {
//发送
sendBtn.setOnClickListener(v -> {
if (!HttpServer.asRunning() && NetUtil.NETWORK_WIFI != NetUtil.getNetWorkStatus()) {
if (!HttpServer.asRunning() && NetUtils.NETWORK_WIFI != NetUtils.getNetWorkStatus()) {
ToastUtils.show(getString(R.string.no_wifi_network));
return;
}
SettingUtil.switchEnableHttpServer(!SettingUtil.getSwitchEnableHttpServer());
SettingUtils.switchEnableHttpServer(!SettingUtils.getSwitchEnableHttpServer());
if (!HttpServer.update()) {
SettingUtil.switchEnableHttpServer(!SettingUtil.getSwitchEnableHttpServer());
SettingUtils.switchEnableHttpServer(!SettingUtils.getSwitchEnableHttpServer());
return;
}
if (!HttpServer.asRunning()) {
@ -163,7 +163,7 @@ public class CloneActivity extends BaseActivity {
return;
}
if (NetUtil.NETWORK_WIFI != NetUtil.getNetWorkStatus()) {
if (NetUtils.NETWORK_WIFI != NetUtils.getNetWorkStatus()) {
receiveTxt.setText(R.string.no_wifi_network);
ToastUtils.show(getString(R.string.no_wifi_network));
return;
@ -185,8 +185,8 @@ public class CloneActivity extends BaseActivity {
.build();
Map msgMap = new HashMap();
msgMap.put("versionCode", SettingUtil.getVersionCode());
msgMap.put("versionName", SettingUtil.getVersionName());
msgMap.put("versionCode", SettingUtils.getVersionCode());
msgMap.put("versionName", SettingUtils.getVersionName());
String requestMsg = JSON.toJSONString(msgMap);
Log.i(TAG, "requestMsg:" + requestMsg);
@ -222,7 +222,7 @@ public class CloneActivity extends BaseActivity {
CloneInfoVo cloneInfoVo = JSON.parseObject(responseStr, CloneInfoVo.class);
Log.d(TAG, cloneInfoVo.toString());
if (!SettingUtil.getVersionName().equals(cloneInfoVo.getVersionName())) {
if (!SettingUtils.getVersionName().equals(cloneInfoVo.getVersionName())) {
ToastUtils.show(getString(R.string.tips_versions_inconsistent));
return;
}
@ -268,7 +268,7 @@ public class CloneActivity extends BaseActivity {
CloneInfoVo cloneInfoVo = JSON.parseObject(responseStr, CloneInfoVo.class);
Log.d(TAG, Objects.requireNonNull(cloneInfoVo).toString());
if (!SettingUtil.getVersionName().equals(cloneInfoVo.getVersionName())) {
if (!SettingUtils.getVersionName().equals(cloneInfoVo.getVersionName())) {
ToastUtils.show(getString(R.string.tips_versions_inconsistent));
return;
}
@ -292,7 +292,7 @@ public class CloneActivity extends BaseActivity {
protected void onResume() {
super.onResume();
serverIp = NetUtil.getLocalIp(CloneActivity.this);
serverIp = NetUtils.getLocalIp(CloneActivity.this);
TextView ipText = findViewById(R.id.ipText);
ipText.setText(getString(R.string.local_ip) + serverIp);
}

@ -37,24 +37,25 @@ import com.idormy.sms.forwarder.service.BatteryService;
import com.idormy.sms.forwarder.service.FrontService;
import com.idormy.sms.forwarder.service.MusicService;
import com.idormy.sms.forwarder.utils.CommonUtil;
import com.idormy.sms.forwarder.utils.HttpUtil;
import com.idormy.sms.forwarder.utils.HttpUtils;
import com.idormy.sms.forwarder.utils.KeepAliveUtils;
import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.NetUtil;
import com.idormy.sms.forwarder.utils.LogUtils;
import com.idormy.sms.forwarder.utils.NetUtils;
import com.idormy.sms.forwarder.utils.OnePixelManager;
import com.idormy.sms.forwarder.utils.PhoneUtils;
import com.idormy.sms.forwarder.utils.RuleUtil;
import com.idormy.sms.forwarder.utils.SettingUtil;
import com.idormy.sms.forwarder.utils.RuleUtils;
import com.idormy.sms.forwarder.utils.SettingUtils;
import com.idormy.sms.forwarder.utils.SharedPreferencesHelper;
import com.idormy.sms.forwarder.utils.SmsUtil;
import com.idormy.sms.forwarder.utils.TimeUtil;
import com.idormy.sms.forwarder.utils.SmsUtils;
import com.idormy.sms.forwarder.utils.TimeUtils;
import com.idormy.sms.forwarder.utils.UmInitConfig;
import com.idormy.sms.forwarder.view.RefreshListView;
import com.idormy.sms.forwarder.view.StepBar;
import com.umeng.commonsdk.UMConfigure;
import java.util.ArrayList;
import java.util.List;
@SuppressWarnings("CommentedOutCode")
public class MainActivity extends BaseActivity implements RefreshListView.IRefreshListener {
private final String TAG = "MainActivity";
@ -77,11 +78,11 @@ public class MainActivity extends BaseActivity implements RefreshListView.IRefre
if (!MyApplication.allowPrivacyPolicy) return;
//短信&网络组件初始化
SmsUtil.init(this);
NetUtil.init(this);
SmsUtils.init(this);
NetUtils.init(this);
LogUtil.init(this);
RuleUtil.init(this);
LogUtils.init(this);
RuleUtils.init(this);
SenderUtil.init(this);
//前台服务
@ -103,7 +104,7 @@ public class MainActivity extends BaseActivity implements RefreshListView.IRefre
}
//后台播放无声音乐
if (SettingUtil.getPlaySilenceMusic()) {
if (SettingUtils.getPlaySilenceMusic()) {
try {
Intent musicServiceIntent = new Intent(this, MusicService.class);
musicServiceIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@ -114,7 +115,7 @@ public class MainActivity extends BaseActivity implements RefreshListView.IRefre
}
//1像素透明Activity保活 or 仅锁屏状态转发APP通知
if (SettingUtil.getOnePixelActivity() || SettingUtil.getSwitchNotUserPresent()) {
if (SettingUtils.getOnePixelActivity() || SettingUtils.getSwitchNotUserPresent()) {
try {
onePixelManager = new OnePixelManager();
onePixelManager.registerOnePixelReceiver(this);//注册广播接收者
@ -123,9 +124,9 @@ public class MainActivity extends BaseActivity implements RefreshListView.IRefre
}
}
HttpUtil.init(this);
HttpUtils.init(this);
//启用HttpServer
if (SettingUtil.getSwitchEnableHttpServer()) {
if (SettingUtils.getSwitchEnableHttpServer()) {
HttpServer.init(this);
try {
HttpServer.update();
@ -135,7 +136,7 @@ public class MainActivity extends BaseActivity implements RefreshListView.IRefre
}
//电池状态定时推送
if (SettingUtil.getSwitchEnableBatteryCron()) {
if (SettingUtils.getSwitchEnableBatteryCron()) {
try {
BatteryReportCronTask.getSingleton().updateTimer();
} catch (Exception e) {
@ -193,12 +194,12 @@ public class MainActivity extends BaseActivity implements RefreshListView.IRefre
ToastUtils.show(R.string.toast_granted_part);
}
}
SettingUtil.switchEnableSms(true);
SettingUtils.switchEnableSms(true);
//首次使用重要提醒
final SharedPreferencesHelper sharedPreferencesHelper = new SharedPreferencesHelper(MainActivity.this, "umeng");
boolean firstTime = sharedPreferencesHelper.getSharedPreference("firstTime", "true").equals("true");
if (firstTime && LogUtil.countLog("2", null, null) == 0) {
if (firstTime && LogUtils.countLog("2", null, null) == 0) {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this)
.setIcon(R.mipmap.ic_launcher)
.setTitle("首次使用重要提醒")
@ -227,7 +228,7 @@ public class MainActivity extends BaseActivity implements RefreshListView.IRefre
ToastUtils.show(R.string.toast_denied);
}
}
SettingUtil.switchEnableSms(false);
SettingUtils.switchEnableSms(false);
}
});
@ -242,7 +243,7 @@ public class MainActivity extends BaseActivity implements RefreshListView.IRefre
builder.setTitle(R.string.clear_logs_tips)
.setPositiveButton(R.string.confirm, (dialog, which) -> {
// TODO Auto-generated method stub
LogUtil.delLog(null, null);
LogUtils.delLog(null, null);
initTLogs();
adapter.add(logVos);
});
@ -285,7 +286,7 @@ public class MainActivity extends BaseActivity implements RefreshListView.IRefre
builder.setPositiveButton(R.string.confirm, (dialog, which) -> {
Long id1 = logVos.get(position - 1).getId();
Log.d(TAG, "id = " + id1);
LogUtil.delLog(id1, null);
LogUtils.delLog(id1, null);
initTLogs(); //初始化数据
showList(logVos);
ToastUtils.show(R.string.delete_log_toast);
@ -338,9 +339,9 @@ public class MainActivity extends BaseActivity implements RefreshListView.IRefre
}
//开启读取通知栏权限
if (SettingUtil.getSwitchEnableAppNotify() && !CommonUtil.isNotificationListenerServiceEnabled(this)) {
if (SettingUtils.getSwitchEnableAppNotify() && !CommonUtil.isNotificationListenerServiceEnabled(this)) {
CommonUtil.toggleNotificationListenerService(this);
SettingUtil.switchEnableAppNotify(false);
SettingUtils.switchEnableAppNotify(false);
ToastUtils.delayedShow(R.string.tips_notification_listener, 3000);
return;
}
@ -407,7 +408,7 @@ public class MainActivity extends BaseActivity implements RefreshListView.IRefre
// 初始化数据
private void initTLogs() {
logVos = LogUtil.getLog(null, null, currentType);
logVos = LogUtils.getLog(null, null, currentType);
}
private void showList(List<LogVo> logVosN) {
@ -442,15 +443,15 @@ public class MainActivity extends BaseActivity implements RefreshListView.IRefre
builder.setTitle(R.string.details);
String simInfo = logVo.getSimInfo();
if (simInfo != null) {
builder.setMessage(getString(R.string.from) + logVo.getFrom() + "\n\n" + getString(R.string.msg) + logVo.getContent() + "\n\n" + getString(R.string.slot) + logVo.getSimInfo() + "\n\n" + getString(R.string.rule) + logVo.getRule() + "\n\n" + getString(R.string.time) + TimeUtil.utc2Local(logVo.getTime()) + getString(R.string.result) + logVo.getForwardResponse());
builder.setMessage(getString(R.string.from) + logVo.getFrom() + "\n\n" + getString(R.string.msg) + logVo.getContent() + "\n\n" + getString(R.string.slot) + logVo.getSimInfo() + "\n\n" + getString(R.string.rule) + logVo.getRule() + "\n\n" + getString(R.string.time) + TimeUtils.utc2Local(logVo.getTime()) + getString(R.string.result) + logVo.getForwardResponse());
} else {
builder.setMessage(getString(R.string.from) + logVo.getFrom() + "\n\n" + getString(R.string.msg) + logVo.getContent() + "\n\n" + getString(R.string.rule) + logVo.getRule() + "\n\n" + getString(R.string.time) + TimeUtil.utc2Local(logVo.getTime()) + getString(R.string.result) + logVo.getForwardResponse());
builder.setMessage(getString(R.string.from) + logVo.getFrom() + "\n\n" + getString(R.string.msg) + logVo.getContent() + "\n\n" + getString(R.string.rule) + logVo.getRule() + "\n\n" + getString(R.string.time) + TimeUtils.utc2Local(logVo.getTime()) + getString(R.string.result) + logVo.getForwardResponse());
}
//删除
builder.setNegativeButton(R.string.del, (dialog, which) -> {
Long id = logVo.getId();
Log.d(TAG, "id = " + id);
LogUtil.delLog(id, null);
LogUtils.delLog(id, null);
initTLogs(); //初始化数据
showList(logVos);
ToastUtils.show(R.string.delete_log_toast);

@ -18,11 +18,13 @@ import com.idormy.sms.forwarder.sender.SendHistory;
import com.idormy.sms.forwarder.service.BatteryService;
import com.idormy.sms.forwarder.service.FrontService;
import com.idormy.sms.forwarder.service.MusicService;
import com.idormy.sms.forwarder.utils.CrashHandler;
import com.idormy.sms.forwarder.utils.Define;
import com.idormy.sms.forwarder.utils.PermissionInterceptor;
import com.idormy.sms.forwarder.utils.PhoneUtils;
import com.idormy.sms.forwarder.utils.SettingUtil;
import com.idormy.sms.forwarder.utils.SettingUtils;
import com.idormy.sms.forwarder.utils.SharedPreferencesHelper;
import com.idormy.sms.forwarder.utils.UmInitConfig;
import com.smailnet.emailkit.EmailKit;
import com.umeng.commonsdk.UMConfigure;
@ -91,13 +93,13 @@ public class MyApplication extends Application {
}
SendHistory.init(this);
SettingUtil.init(this);
SettingUtils.init(this);
EmailKit.initialize(this);
SharedPreferences sp = MyApplication.this.getSharedPreferences(Define.SP_CONFIG, Context.MODE_PRIVATE);
showHelpTip = sp.getBoolean(Define.SP_CONFIG_SWITCH_HELP_TIP, true);
if (SettingUtil.getExcludeFromRecents()) {
if (SettingUtils.getExcludeFromRecents()) {
ActivityManager am = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE);
if (am != null) {
List<ActivityManager.AppTask> appTasks = am.getAppTasks();
@ -112,7 +114,7 @@ public class MyApplication extends Application {
startService(batteryServiceIntent);
//后台播放无声音乐
if (SettingUtil.getPlaySilenceMusic()) {
if (SettingUtils.getPlaySilenceMusic()) {
startService(new Intent(context, MusicService.class));
}

@ -30,9 +30,9 @@ 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.CommonUtil;
import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.RuleUtil;
import com.idormy.sms.forwarder.utils.SettingUtil;
import com.idormy.sms.forwarder.utils.LogUtils;
import com.idormy.sms.forwarder.utils.RuleUtils;
import com.idormy.sms.forwarder.utils.SettingUtils;
import com.idormy.sms.forwarder.view.StepBar;
import java.util.ArrayList;
@ -66,8 +66,8 @@ public class RuleActivity extends BaseActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_rule);
LogUtil.init(this);
RuleUtil.init(this);
LogUtils.init(this);
RuleUtils.init(this);
SenderUtil.init(this);
}
@ -99,7 +99,7 @@ public class RuleActivity extends BaseActivity {
builder.setMessage(R.string.delete_rule_tips);
builder.setPositiveButton(R.string.confirm, (dialog, which) -> {
RuleUtil.delRule(ruleModels.get(position).getId());
RuleUtils.delRule(ruleModels.get(position).getId());
initRules();
adapter.del(ruleModels);
ToastUtils.show(R.string.delete_rule_toast);
@ -178,7 +178,7 @@ public class RuleActivity extends BaseActivity {
// 初始化数据
private void initRules() {
ruleModels = RuleUtil.getRule(null, null, currentType);
ruleModels = RuleUtils.getRule(null, null, currentType);
}
private void setRule(final RuleModel ruleModel, final boolean isClone) {
@ -288,7 +288,7 @@ public class RuleActivity extends BaseActivity {
newRuleModel.setRegexReplace(regexReplace);
newRuleModel.setSenderId(Long.valueOf(senderId.toString()));
newRuleModel.setStatus(switchRuleStatus.isChecked() ? STATUS_ON : STATUS_OFF);
RuleUtil.addRule(newRuleModel);
RuleUtils.addRule(newRuleModel);
initRules();
adapter.add(ruleModels);
} else {
@ -302,7 +302,7 @@ public class RuleActivity extends BaseActivity {
ruleModel.setRegexReplace(regexReplace);
ruleModel.setSenderId(Long.valueOf(senderId.toString()));
ruleModel.setStatus(switchRuleStatus.isChecked() ? STATUS_ON : STATUS_OFF);
RuleUtil.updateRule(ruleModel);
RuleUtils.updateRule(ruleModel);
initRules();
adapter.update(ruleModels);
}
@ -311,7 +311,7 @@ public class RuleActivity extends BaseActivity {
buttonRuleDel.setOnClickListener(view -> {
if (ruleModel != null) {
RuleUtil.delRule(ruleModel.getId());
RuleUtils.delRule(ruleModel.getId());
initRules();
adapter.del(ruleModels);
}
@ -576,9 +576,9 @@ public class RuleActivity extends BaseActivity {
String simSlot = RuleModel.getRuleSimSlotFromCheckId(radioGroupTestSimSlot.getCheckedRadioButtonId());
String simInfo;
if (simSlot.equals("SIM2")) {
simInfo = simSlot + "_" + SettingUtil.getAddExtraSim2();
simInfo = simSlot + "_" + SettingUtils.getAddExtraSim2();
} else {
simInfo = simSlot + "_" + SettingUtil.getAddExtraSim1();
simInfo = simSlot + "_" + SettingUtils.getAddExtraSim1();
}
SmsVo testSmsVo = new SmsVo(editTextTestPhone.getText().toString().trim(), editTextTestMsgContent.getText().toString().trim(), new Date(), simInfo);
SendUtil.sendMsgByRuleModelSenderId(handler, ruleModel, testSmsVo, senderId);

@ -77,8 +77,8 @@ import com.idormy.sms.forwarder.sender.SenderTelegramMsg;
import com.idormy.sms.forwarder.sender.SenderUtil;
import com.idormy.sms.forwarder.sender.SenderWebNotifyMsg;
import com.idormy.sms.forwarder.utils.CommonUtil;
import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.RuleUtil;
import com.idormy.sms.forwarder.utils.LogUtils;
import com.idormy.sms.forwarder.utils.RuleUtils;
import com.idormy.sms.forwarder.view.ClearEditText;
import com.idormy.sms.forwarder.view.StepBar;
@ -114,8 +114,8 @@ public class SenderActivity extends BaseActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sender);
LogUtil.init(this);
RuleUtil.init(this);
LogUtils.init(this);
RuleUtils.init(this);
SenderUtil.init(this);
}

@ -40,12 +40,12 @@ import com.idormy.sms.forwarder.service.MusicService;
import com.idormy.sms.forwarder.utils.CommonUtil;
import com.idormy.sms.forwarder.utils.DbHelper;
import com.idormy.sms.forwarder.utils.Define;
import com.idormy.sms.forwarder.utils.HttpUtil;
import com.idormy.sms.forwarder.utils.HttpUtils;
import com.idormy.sms.forwarder.utils.KeepAliveUtils;
import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.LogUtils;
import com.idormy.sms.forwarder.utils.OnePixelManager;
import com.idormy.sms.forwarder.utils.RuleUtil;
import com.idormy.sms.forwarder.utils.SettingUtil;
import com.idormy.sms.forwarder.utils.RuleUtils;
import com.idormy.sms.forwarder.utils.SettingUtils;
import com.idormy.sms.forwarder.view.StepBar;
import java.util.Arrays;
@ -67,8 +67,8 @@ public class SettingActivity extends BaseActivity {
context = SettingActivity.this;
setContentView(R.layout.activity_setting);
LogUtil.init(this);
RuleUtil.init(this);
LogUtils.init(this);
RuleUtils.init(this);
SenderUtil.init(this);
}
@ -142,7 +142,7 @@ public class SettingActivity extends BaseActivity {
//设置转发短信
@SuppressLint("UseSwitchCompatOrMaterialCode")
private void switchEnableSms(Switch switch_enable_sms) {
switch_enable_sms.setChecked(SettingUtil.getSwitchEnableSms());
switch_enable_sms.setChecked(SettingUtils.getSwitchEnableSms());
switch_enable_sms.setOnCheckedChangeListener((buttonView, isChecked) -> {
Log.d(TAG, "switchEnableSms:" + isChecked);
@ -166,7 +166,7 @@ public class SettingActivity extends BaseActivity {
} else {
ToastUtils.show(R.string.toast_granted_part);
}
SettingUtil.switchEnableSms(true);
SettingUtils.switchEnableSms(true);
}
@Override
@ -178,11 +178,11 @@ public class SettingActivity extends BaseActivity {
} else {
ToastUtils.show(R.string.toast_denied);
}
SettingUtil.switchEnableSms(false);
SettingUtils.switchEnableSms(false);
}
});
} else {
SettingUtil.switchEnableSms(false);
SettingUtils.switchEnableSms(false);
}
});
}
@ -190,15 +190,15 @@ public class SettingActivity extends BaseActivity {
//转发通话记录
@SuppressLint("UseSwitchCompatOrMaterialCode")
private void switchEnablePhone(Switch switch_enable_phone, CheckBox check_box_call_type_1, CheckBox check_box_call_type_2, CheckBox check_box_call_type_3) {
switch_enable_phone.setChecked(SettingUtil.getSwitchEnablePhone());
check_box_call_type_1.setChecked(SettingUtil.getSwitchCallType1());
check_box_call_type_2.setChecked(SettingUtil.getSwitchCallType2());
check_box_call_type_3.setChecked(SettingUtil.getSwitchCallType3());
switch_enable_phone.setChecked(SettingUtils.getSwitchEnablePhone());
check_box_call_type_1.setChecked(SettingUtils.getSwitchCallType1());
check_box_call_type_2.setChecked(SettingUtils.getSwitchCallType2());
check_box_call_type_3.setChecked(SettingUtils.getSwitchCallType3());
switch_enable_phone.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked && !SettingUtil.getSwitchCallType1() && !SettingUtil.getSwitchCallType2() && !SettingUtil.getSwitchCallType3()) {
if (isChecked && !SettingUtils.getSwitchCallType1() && !SettingUtils.getSwitchCallType2() && !SettingUtils.getSwitchCallType3()) {
ToastUtils.show(R.string.enable_phone_fw_tips);
SettingUtil.switchEnablePhone(false);
SettingUtils.switchEnablePhone(false);
return;
}
@ -225,7 +225,7 @@ public class SettingActivity extends BaseActivity {
} else {
ToastUtils.show(R.string.toast_granted_part);
}
SettingUtil.switchEnablePhone(true);
SettingUtils.switchEnablePhone(true);
}
@Override
@ -237,35 +237,35 @@ public class SettingActivity extends BaseActivity {
} else {
ToastUtils.show(R.string.toast_denied);
}
SettingUtil.switchEnablePhone(false);
SettingUtils.switchEnablePhone(false);
}
});
} else {
SettingUtil.switchEnablePhone(false);
SettingUtils.switchEnablePhone(false);
}
});
check_box_call_type_1.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingUtil.switchCallType1(isChecked);
if (!isChecked && !SettingUtil.getSwitchCallType1() && !SettingUtil.getSwitchCallType2() && !SettingUtil.getSwitchCallType3()) {
SettingUtils.switchCallType1(isChecked);
if (!isChecked && !SettingUtils.getSwitchCallType1() && !SettingUtils.getSwitchCallType2() && !SettingUtils.getSwitchCallType3()) {
ToastUtils.show(R.string.enable_phone_fw_tips);
SettingUtil.switchEnablePhone(false);
SettingUtils.switchEnablePhone(false);
}
});
check_box_call_type_2.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingUtil.switchCallType2(isChecked);
if (!isChecked && !SettingUtil.getSwitchCallType1() && !SettingUtil.getSwitchCallType2() && !SettingUtil.getSwitchCallType3()) {
SettingUtils.switchCallType2(isChecked);
if (!isChecked && !SettingUtils.getSwitchCallType1() && !SettingUtils.getSwitchCallType2() && !SettingUtils.getSwitchCallType3()) {
ToastUtils.show(R.string.enable_phone_fw_tips);
SettingUtil.switchEnablePhone(false);
SettingUtils.switchEnablePhone(false);
}
});
check_box_call_type_3.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingUtil.switchCallType3(isChecked);
if (!isChecked && !SettingUtil.getSwitchCallType1() && !SettingUtil.getSwitchCallType2() && !SettingUtil.getSwitchCallType3()) {
SettingUtils.switchCallType3(isChecked);
if (!isChecked && !SettingUtils.getSwitchCallType1() && !SettingUtils.getSwitchCallType2() && !SettingUtils.getSwitchCallType3()) {
ToastUtils.show(R.string.enable_phone_fw_tips);
SettingUtil.switchEnablePhone(false);
SettingUtils.switchEnablePhone(false);
}
});
}
@ -274,7 +274,7 @@ public class SettingActivity extends BaseActivity {
@SuppressLint("UseSwitchCompatOrMaterialCode")
private void switchEnableAppNotify(Switch switch_enable_app_notify, CheckBox checkbox_cancel_app_notify, CheckBox checkbox_not_user_present) {
final LinearLayout layout_cancel_app_notify = findViewById(R.id.layout_cancel_app_notify);
boolean isEnable = SettingUtil.getSwitchEnableAppNotify();
boolean isEnable = SettingUtils.getSwitchEnableAppNotify();
switch_enable_app_notify.setChecked(isEnable);
layout_cancel_app_notify.setVisibility(isEnable ? View.VISIBLE : View.GONE);
@ -291,24 +291,24 @@ public class SettingActivity extends BaseActivity {
CommonUtil.toggleNotificationListenerService(this);
}
}
SettingUtil.switchEnableAppNotify(isChecked);
SettingUtils.switchEnableAppNotify(isChecked);
Log.d(TAG, "switchEnableAppNotify:" + isChecked);
});
checkbox_cancel_app_notify.setChecked(SettingUtil.getSwitchCancelAppNotify());
checkbox_cancel_app_notify.setChecked(SettingUtils.getSwitchCancelAppNotify());
checkbox_cancel_app_notify.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingUtil.switchCancelAppNotify(isChecked);
SettingUtils.switchCancelAppNotify(isChecked);
Log.d(TAG, "switchCancelAppNotify:" + isChecked);
});
checkbox_not_user_present.setChecked(SettingUtil.getSwitchNotUserPresent());
checkbox_not_user_present.setChecked(SettingUtils.getSwitchNotUserPresent());
checkbox_not_user_present.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingUtil.switchNotUserPresent(isChecked);
SettingUtils.switchNotUserPresent(isChecked);
Log.d(TAG, "switchNotUserPresent:" + isChecked);
//1像素透明Activity保活 or 仅锁屏状态转发APP通知
OnePixelManager onePixelManager = new OnePixelManager();
if (SettingUtil.getOnePixelActivity() || SettingUtil.getSwitchNotUserPresent()) {
if (SettingUtils.getOnePixelActivity() || SettingUtils.getSwitchNotUserPresent()) {
onePixelManager.registerOnePixelReceiver(this);//注册广播接收者
} else {
onePixelManager.unregisterOnePixelReceiver(this);
@ -333,27 +333,27 @@ public class SettingActivity extends BaseActivity {
if (CommonUtil.isNotificationListenerServiceEnabled(this)) {
ToastUtils.show(R.string.notification_listener_service_enabled);
CommonUtil.toggleNotificationListenerService(this);
SettingUtil.switchEnableAppNotify(true);
SettingUtils.switchEnableAppNotify(true);
} else {
ToastUtils.show(R.string.notification_listener_service_disabled);
SettingUtil.switchEnableAppNotify(false);
SettingUtils.switchEnableAppNotify(false);
}
@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_enable_app_notify = findViewById(R.id.switch_enable_app_notify);
switch_enable_app_notify.setChecked(SettingUtil.getSwitchEnableAppNotify());
switch_enable_app_notify.setChecked(SettingUtils.getSwitchEnableAppNotify());
}
}
//HttpServer
@SuppressLint("UseSwitchCompatOrMaterialCode")
private void switchEnableHttpServer(Switch switch_enable_http_server) {
switch_enable_http_server.setChecked(SettingUtil.getSwitchEnableHttpServer());
switch_enable_http_server.setChecked(SettingUtils.getSwitchEnableHttpServer());
switch_enable_http_server.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingUtil.switchEnableHttpServer(isChecked);
SettingUtils.switchEnableHttpServer(isChecked);
Log.d(TAG, "switchEnableHttpServer:" + isChecked);
HttpUtil.init(this);
HttpUtils.init(this);
HttpServer.init(this);
HttpServer.update();
});
@ -362,18 +362,18 @@ public class SettingActivity extends BaseActivity {
//监听电池状态变化
@SuppressLint("UseSwitchCompatOrMaterialCode")
private void switchBatteryReceiver(Switch switch_battery_receiver) {
switch_battery_receiver.setChecked(SettingUtil.getSwitchEnableBatteryReceiver());
switch_battery_receiver.setChecked(SettingUtils.getSwitchEnableBatteryReceiver());
switch_battery_receiver.setOnCheckedChangeListener((buttonView, isChecked) -> {
//TODO:校验使用来电转发必备的权限
SettingUtil.switchEnableBatteryReceiver(isChecked);
SettingUtils.switchEnableBatteryReceiver(isChecked);
Log.d(TAG, "switchEnablePhone:" + isChecked);
});
}
//设置低电量报警
private void editBatteryLevelAlarm(final EditText et_battery_level_alarm_min, final EditText et_battery_level_alarm_max, CheckBox cb_battery_level_alarm_once) {
et_battery_level_alarm_min.setText(String.valueOf(SettingUtil.getBatteryLevelAlarmMin()));
et_battery_level_alarm_min.setText(String.valueOf(SettingUtils.getBatteryLevelAlarmMin()));
et_battery_level_alarm_min.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@ -387,14 +387,14 @@ public class SettingActivity extends BaseActivity {
public void afterTextChanged(Editable s) {
String batteryLevel = et_battery_level_alarm_min.getText().toString().trim();
if (!batteryLevel.isEmpty()) {
SettingUtil.setBatteryLevelAlarmMin(Integer.parseInt(batteryLevel));
SettingUtils.setBatteryLevelAlarmMin(Integer.parseInt(batteryLevel));
} else {
SettingUtil.setBatteryLevelAlarmMin(0);
SettingUtils.setBatteryLevelAlarmMin(0);
}
}
});
et_battery_level_alarm_max.setText(String.valueOf(SettingUtil.getBatteryLevelAlarmMax()));
et_battery_level_alarm_max.setText(String.valueOf(SettingUtils.getBatteryLevelAlarmMax()));
et_battery_level_alarm_max.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@ -408,19 +408,19 @@ public class SettingActivity extends BaseActivity {
public void afterTextChanged(Editable s) {
String batteryLevel = et_battery_level_alarm_max.getText().toString().trim();
if (!batteryLevel.isEmpty()) {
SettingUtil.setBatteryLevelAlarmMax(Integer.parseInt(batteryLevel));
SettingUtils.setBatteryLevelAlarmMax(Integer.parseInt(batteryLevel));
} else {
SettingUtil.setBatteryLevelAlarmMax(0);
SettingUtils.setBatteryLevelAlarmMax(0);
}
}
});
cb_battery_level_alarm_once.setChecked(SettingUtil.getBatteryLevelAlarmOnce());
cb_battery_level_alarm_once.setChecked(SettingUtils.getBatteryLevelAlarmOnce());
cb_battery_level_alarm_once.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingUtil.switchBatteryLevelAlarmOnce(isChecked);
if (isChecked && 0 == SettingUtil.getBatteryLevelAlarmMin() && 0 == SettingUtil.getBatteryLevelAlarmMax()) {
SettingUtils.switchBatteryLevelAlarmOnce(isChecked);
if (isChecked && 0 == SettingUtils.getBatteryLevelAlarmMin() && 0 == SettingUtils.getBatteryLevelAlarmMax()) {
ToastUtils.show(R.string.tips_battery_level_alarm_once);
SettingUtil.switchEnablePhone(false);
SettingUtils.switchEnablePhone(false);
}
});
}
@ -428,7 +428,7 @@ public class SettingActivity extends BaseActivity {
//定时推送电池状态
@SuppressLint("UseSwitchCompatOrMaterialCode")
private void switchBatteryCron(Switch switch_battery_cron) {
boolean isOn = SettingUtil.getSwitchEnableBatteryCron();
boolean isOn = SettingUtils.getSwitchEnableBatteryCron();
switch_battery_cron.setChecked(isOn);
final LinearLayout layout_battery_cron = findViewById(R.id.layout_battery_cron);
@ -437,14 +437,14 @@ public class SettingActivity extends BaseActivity {
switch_battery_cron.setOnCheckedChangeListener((buttonView, isChecked) -> {
Log.d(TAG, "onCheckedChanged:" + isChecked);
layout_battery_cron.setVisibility(isChecked ? View.VISIBLE : View.GONE);
SettingUtil.switchEnableBatteryCron(isChecked);
SettingUtils.switchEnableBatteryCron(isChecked);
BatteryReportCronTask.getSingleton().updateTimer();
});
}
//设置推送电池状态时机
private void editBatteryCronTiming(final EditText et_battery_cron_start_time, final EditText et_battery_cron_interval) {
et_battery_cron_start_time.setText(SettingUtil.getBatteryCronStartTime());
et_battery_cron_start_time.setText(SettingUtils.getBatteryCronStartTime());
Calendar calendar = Calendar.getInstance();
et_battery_cron_start_time.setOnClickListener(view -> {
@ -461,13 +461,13 @@ public class SettingActivity extends BaseActivity {
sb.append(minute);
String startTime = sb.toString();
et_battery_cron_start_time.setText(startTime);
SettingUtil.setBatteryCronStartTime(startTime);
SettingUtils.setBatteryCronStartTime(startTime);
BatteryReportCronTask.getSingleton().updateTimer();
}, calendar.get(Calendar.HOUR_OF_DAY) + 1, 0, true);
dialog.show();
});
et_battery_cron_interval.setText(String.valueOf(SettingUtil.getBatteryCronInterval()));
et_battery_cron_interval.setText(String.valueOf(SettingUtils.getBatteryCronInterval()));
et_battery_cron_interval.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@ -481,10 +481,10 @@ public class SettingActivity extends BaseActivity {
public void afterTextChanged(Editable s) {
String interval = et_battery_cron_interval.getText().toString().trim();
if (!interval.isEmpty() && Integer.parseInt(interval) > 0) {
SettingUtil.setBatteryCronInterval(Integer.parseInt(interval));
SettingUtils.setBatteryCronInterval(Integer.parseInt(interval));
BatteryReportCronTask.getSingleton().updateTimer();
} else {
SettingUtil.setBatteryCronInterval(60);
SettingUtils.setBatteryCronInterval(60);
}
}
});
@ -715,10 +715,10 @@ public class SettingActivity extends BaseActivity {
//不在最近任务列表中显示
@SuppressLint("ObsoleteSdkInt,UseSwitchCompatOrMaterialCode")
private void switchExcludeFromRecents(Switch switch_exclude_from_recents) {
switch_exclude_from_recents.setChecked(SettingUtil.getExcludeFromRecents());
switch_exclude_from_recents.setChecked(SettingUtils.getExcludeFromRecents());
switch_exclude_from_recents.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingUtil.switchExcludeFromRecents(isChecked);
SettingUtils.switchExcludeFromRecents(isChecked);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ActivityManager am = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE);
if (am != null) {
@ -735,10 +735,10 @@ public class SettingActivity extends BaseActivity {
//后台播放无声音乐
@SuppressLint("ObsoleteSdkInt,UseSwitchCompatOrMaterialCode")
private void switchPlaySilenceMusic(Switch switch_play_silence_music) {
switch_play_silence_music.setChecked(SettingUtil.getPlaySilenceMusic());
switch_play_silence_music.setChecked(SettingUtils.getPlaySilenceMusic());
switch_play_silence_music.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingUtil.switchPlaySilenceMusic(isChecked);
SettingUtils.switchPlaySilenceMusic(isChecked);
if (isChecked) {
startService(new Intent(context, MusicService.class));
@ -752,15 +752,15 @@ public class SettingActivity extends BaseActivity {
//1像素透明Activity保活
@SuppressLint("ObsoleteSdkInt,UseSwitchCompatOrMaterialCode")
private void switchOnePixelActivity(Switch switch_one_pixel_activity) {
switch_one_pixel_activity.setChecked(SettingUtil.getOnePixelActivity());
switch_one_pixel_activity.setChecked(SettingUtils.getOnePixelActivity());
switch_one_pixel_activity.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingUtil.switchOnePixelActivity(isChecked);
SettingUtils.switchOnePixelActivity(isChecked);
Log.d(TAG, "onCheckedChanged:" + isChecked);
//1像素透明Activity保活 or 仅锁屏状态转发APP通知
OnePixelManager onePixelManager = new OnePixelManager();
if (SettingUtil.getOnePixelActivity() || SettingUtil.getSwitchNotUserPresent()) {
if (SettingUtils.getOnePixelActivity() || SettingUtils.getSwitchNotUserPresent()) {
onePixelManager.registerOnePixelReceiver(this);//注册广播接收者
} else {
onePixelManager.unregisterOnePixelReceiver(this);
@ -770,7 +770,7 @@ public class SettingActivity extends BaseActivity {
//接口请求失败重试时间间隔
private void editRetryDelayTime(final EditText et_retry_times, final EditText et_delay_time) {
et_retry_times.setText(String.valueOf(SettingUtil.getRetryTimes()));
et_retry_times.setText(String.valueOf(SettingUtils.getRetryTimes()));
et_retry_times.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@ -784,14 +784,14 @@ public class SettingActivity extends BaseActivity {
public void afterTextChanged(Editable s) {
String retryTimes = et_retry_times.getText().toString().trim();
if (!retryTimes.isEmpty()) {
SettingUtil.setRetryTimes(Integer.parseInt(retryTimes));
SettingUtils.setRetryTimes(Integer.parseInt(retryTimes));
} else {
SettingUtil.setRetryTimes(0);
SettingUtils.setRetryTimes(0);
}
}
});
et_delay_time.setText(String.valueOf(SettingUtil.getDelayTime()));
et_delay_time.setText(String.valueOf(SettingUtils.getDelayTime()));
et_delay_time.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@ -805,9 +805,9 @@ public class SettingActivity extends BaseActivity {
public void afterTextChanged(Editable s) {
String delayTime = et_delay_time.getText().toString().trim();
if (!delayTime.isEmpty()) {
SettingUtil.setDelayTime(Integer.parseInt(delayTime));
SettingUtils.setDelayTime(Integer.parseInt(delayTime));
} else {
SettingUtil.setDelayTime(1);
SettingUtils.setDelayTime(1);
}
}
});
@ -815,7 +815,7 @@ public class SettingActivity extends BaseActivity {
//设置设备名称
private void editAddExtraDeviceMark(final EditText et_add_extra_device_mark) {
et_add_extra_device_mark.setText(SettingUtil.getAddExtraDeviceMark());
et_add_extra_device_mark.setText(SettingUtils.getAddExtraDeviceMark());
et_add_extra_device_mark.addTextChangedListener(new TextWatcher() {
@Override
@ -828,14 +828,14 @@ public class SettingActivity extends BaseActivity {
@Override
public void afterTextChanged(Editable s) {
SettingUtil.setAddExtraDeviceMark(et_add_extra_device_mark.getText().toString().trim());
SettingUtils.setAddExtraDeviceMark(et_add_extra_device_mark.getText().toString().trim());
}
});
}
//设置SIM1备注
private void editAddExtraSim1(final EditText et_add_extra_sim1) {
et_add_extra_sim1.setText(SettingUtil.getAddExtraSim1());
et_add_extra_sim1.setText(SettingUtils.getAddExtraSim1());
et_add_extra_sim1.addTextChangedListener(new TextWatcher() {
@Override
@ -848,14 +848,14 @@ public class SettingActivity extends BaseActivity {
@Override
public void afterTextChanged(Editable s) {
SettingUtil.setAddExtraSim1(et_add_extra_sim1.getText().toString().trim());
SettingUtils.setAddExtraSim1(et_add_extra_sim1.getText().toString().trim());
}
});
}
//设置SIM2备注
private void editAddExtraSim2(final EditText et_add_extra_sim2) {
et_add_extra_sim2.setText(SettingUtil.getAddExtraSim2());
et_add_extra_sim2.setText(SettingUtils.getAddExtraSim2());
et_add_extra_sim2.addTextChangedListener(new TextWatcher() {
@Override
@ -868,7 +868,7 @@ public class SettingActivity extends BaseActivity {
@Override
public void afterTextChanged(Editable s) {
SettingUtil.setAddExtraSim2(et_add_extra_sim2.getText().toString().trim());
SettingUtils.setAddExtraSim2(et_add_extra_sim2.getText().toString().trim());
}
});
}
@ -876,7 +876,7 @@ public class SettingActivity extends BaseActivity {
//设置转发时启用自定义模版
@SuppressLint({"UseSwitchCompatOrMaterialCode", "SetTextI18n"})
private void switchSmsTemplate(Switch switch_sms_template) {
boolean isOn = SettingUtil.getSwitchSmsTemplate();
boolean isOn = SettingUtils.getSwitchSmsTemplate();
switch_sms_template.setChecked(isOn);
final LinearLayout layout_sms_template = findViewById(R.id.layout_sms_template);
@ -886,7 +886,7 @@ public class SettingActivity extends BaseActivity {
switch_sms_template.setOnCheckedChangeListener((buttonView, isChecked) -> {
Log.d(TAG, "onCheckedChanged:" + isChecked);
layout_sms_template.setVisibility(isChecked ? View.VISIBLE : View.GONE);
SettingUtil.switchSmsTemplate(isChecked);
SettingUtils.switchSmsTemplate(isChecked);
if (!isChecked) {
textSmsTemplate.setText(getString(R.string.tag_from) + "\n" +
getString(R.string.tag_sms) + "\n" +
@ -899,7 +899,7 @@ public class SettingActivity extends BaseActivity {
//设置转发信息模版
private void editSmsTemplate(final EditText textSmsTemplate) {
textSmsTemplate.setText(SettingUtil.getSmsTemplate());
textSmsTemplate.setText(SettingUtils.getSmsTemplate());
textSmsTemplate.addTextChangedListener(new TextWatcher() {
@Override
@ -914,7 +914,7 @@ public class SettingActivity extends BaseActivity {
@Override
public void afterTextChanged(Editable s) {
SettingUtil.setSmsTemplate(textSmsTemplate.getText().toString().trim());
SettingUtils.setSmsTemplate(textSmsTemplate.getText().toString().trim());
}
});
}

@ -10,7 +10,7 @@ import android.widget.TextView;
import com.idormy.sms.forwarder.R;
import com.idormy.sms.forwarder.model.vo.LogVo;
import com.idormy.sms.forwarder.utils.TimeUtil;
import com.idormy.sms.forwarder.utils.TimeUtils;
import java.util.List;
@ -76,7 +76,7 @@ public class LogAdapter extends ArrayAdapter<LogVo> {
viewHolder.tLogFrom.setText(logVo.getFrom());
viewHolder.tLogContent.setText(logVo.getContent());
viewHolder.tLogRule.setText(logVo.getRule());
viewHolder.tLogTime.setText(TimeUtil.friendlyTime(logVo.getTime()));
viewHolder.tLogTime.setText(TimeUtils.friendlyTime(logVo.getTime()));
viewHolder.senderImage.setImageResource(logVo.getSenderImageId());
viewHolder.simImage.setImageResource(logVo.getSimImageId());
viewHolder.statusImage.setImageResource(logVo.getStatusImageId());

@ -0,0 +1,25 @@
package com.idormy.sms.forwarder.database;
import android.content.Context;
import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;
@Database(entities = {Config.class}, version = 2, exportSchema = false)
public abstract class AppDatabase extends RoomDatabase {
private static volatile AppDatabase instance;
public abstract ConfigDao configDao();
public static AppDatabase getInstance(Context context) {
if (instance == null) {
synchronized (AppDatabase.class) {
if (instance == null) {
instance = Room.databaseBuilder(context, AppDatabase.class, "sms_forwarder.db").build();
}
}
}
return instance;
}
}

@ -0,0 +1,94 @@
package com.idormy.sms.forwarder.database;
import androidx.annotation.NonNull;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;
import java.util.Objects;
@Entity
public class Config {
@PrimaryKey
@NonNull
private String uid;
private String name;
private String cfg;
@Ignore
private Boolean connecting;
@Ignore
public Config() {
}
@Ignore
public Config(String cfg) {
this.cfg = cfg;
}
public Config(@NonNull String uid, String name, String cfg) {
this.uid = uid;
this.name = name;
this.cfg = cfg;
}
@NonNull
public String getUid() {
return uid;
}
public Config setUid(@NonNull String uid) {
this.uid = uid;
return this;
}
public String getName() {
return name;
}
public Config setName(String name) {
this.name = name;
return this;
}
public Boolean getConnecting() {
return connecting;
}
public Config setConnecting(Boolean connecting) {
this.connecting = connecting;
return this;
}
public String getCfg() {
return cfg;
}
public Config setCfg(String cfg) {
this.cfg = cfg;
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Config config = (Config) o;
return Objects.equals(uid, config.uid);
}
@Override
public int hashCode() {
return Objects.hash(uid);
}
@Override
public String toString() {
return "Config{" +
"uid='" + uid + '\'' +
", cfg='" + cfg + '\'' +
'}';
}
}

@ -0,0 +1,30 @@
package com.idormy.sms.forwarder.database;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;
import java.util.List;
import io.reactivex.Completable;
import io.reactivex.Single;
@Dao
public interface ConfigDao {
@Query("SELECT * FROM config")
Single<List<Config>> getAll();
@Query("SELECT * FROM config where uid=:uid")
Single<Config> getConfigByUid(String uid);
@Update
Completable update(Config config);
@Insert
Completable insert(Config config);
@Delete
Completable delete(Config config);
}

@ -4,8 +4,8 @@ import androidx.annotation.NonNull;
import com.alibaba.fastjson.JSON;
import com.idormy.sms.forwarder.utils.PhoneUtils;
import com.idormy.sms.forwarder.utils.SettingUtil;
import com.idormy.sms.forwarder.utils.SimUtil;
import com.idormy.sms.forwarder.utils.SettingUtils;
import com.idormy.sms.forwarder.utils.SimUtils;
import java.io.Serializable;
import java.util.HashMap;
@ -28,7 +28,7 @@ public class SmsHubVo implements Serializable {
public SmsHubVo(Type type, Integer simId, String content, String target) {
this.msgId = UUID.randomUUID().toString();
if (simId != null) {
String simInfo = simId == 2 ? SettingUtil.getAddExtraSim2() : SettingUtil.getAddExtraSim1(); //自定义备注优先
String simInfo = simId == 2 ? SettingUtils.getAddExtraSim2() : SettingUtils.getAddExtraSim1(); //自定义备注优先
simInfo = "SIM" + simId + ":" + simInfo;
this.channel = simInfo;
}
@ -64,7 +64,7 @@ public class SmsHubVo implements Serializable {
SmsHubVo smsHubVo = new SmsHubVo();
HashMap<String, String> deviInfoMap = getDevInfoMap(false);
smsHubVo.setDeviceInfo(JSON.toJSONString(deviInfoMap));
smsHubVo.setChannel("SIM1:" + SimUtil.getSimInfo(1) + SettingUtil.getAddExtraSim1() + ";SIM2:" + SimUtil.getSimInfo(2) + SettingUtil.getAddExtraSim2());
smsHubVo.setChannel("SIM1:" + SimUtils.getSimInfo(1) + SettingUtils.getAddExtraSim1() + ";SIM2:" + SimUtils.getSimInfo(2) + SettingUtils.getAddExtraSim2());
smsHubVo.setTs(Long.toString(System.currentTimeMillis()));
smsHubVo.setAction(SmsHubVo.Action.heartbeat.code());
if (data != null && data.size() > 0) {
@ -80,12 +80,12 @@ public class SmsHubVo implements Serializable {
String key = "deviceInfo";
if (reflush || !cache.containsKey(key)) {
HashMap<String, String> deviInfoMap = new HashMap<>();
deviInfoMap.put("mark", SettingUtil.getAddExtraDeviceMark());
deviInfoMap.put("mark", SettingUtils.getAddExtraDeviceMark());
deviInfoMap.put("simOperatorName", PhoneUtils.getSimOperatorName());
deviInfoMap.put("phoneNumber", PhoneUtils.getPhoneNumber());
deviInfoMap.put("imei", PhoneUtils.getIMEI());
deviInfoMap.put("SDKVersion", PhoneUtils.getSDKVersion() + "");
deviInfoMap.put("Version", SettingUtil.getVersionName());
deviInfoMap.put("Version", SettingUtils.getVersionName());
cache.put(key, deviInfoMap);
return deviInfoMap;
}

@ -7,7 +7,7 @@ import androidx.annotation.NonNull;
import com.idormy.sms.forwarder.MyApplication;
import com.idormy.sms.forwarder.R;
import com.idormy.sms.forwarder.utils.SettingUtil;
import com.idormy.sms.forwarder.utils.SettingUtils;
import java.io.Serializable;
import java.text.SimpleDateFormat;
@ -47,8 +47,8 @@ public class SmsVo implements Serializable {
public String getTitleForSend(String titleTemplate, String regexReplace) {
if (titleTemplate == null || titleTemplate.isEmpty()) titleTemplate = getString(R.string.tag_from);
String deviceMark = SettingUtil.getAddExtraDeviceMark().trim();
String versionName = SettingUtil.getVersionName();
String deviceMark = SettingUtils.getAddExtraDeviceMark().trim();
String versionName = SettingUtils.getVersionName();
String titleForSend = titleTemplate.replace(getString(R.string.tag_from), mobile)
.replace(getString(R.string.tag_package_name), mobile)
.replace(getString(R.string.tag_sms), content)
@ -75,7 +75,7 @@ public class SmsVo implements Serializable {
@SuppressLint("SimpleDateFormat")
public String getSmsVoForSend(String ruleSmsTemplate, String regexReplace) {
String deviceMark = SettingUtil.getAddExtraDeviceMark().trim();
String deviceMark = SettingUtils.getAddExtraDeviceMark().trim();
String customSmsTemplate = getString(R.string.tag_from) + "\n" +
getString(R.string.tag_sms) + "\n" +
getString(R.string.tag_card_slot) + "\n" +
@ -86,14 +86,14 @@ public class SmsVo implements Serializable {
if (!ruleSmsTemplate.isEmpty()) {
customSmsTemplate = ruleSmsTemplate;
} else {
boolean switchSmsTemplate = SettingUtil.getSwitchSmsTemplate();
String smsTemplate = SettingUtil.getSmsTemplate().trim();
boolean switchSmsTemplate = SettingUtils.getSwitchSmsTemplate();
String smsTemplate = SettingUtils.getSmsTemplate().trim();
if (switchSmsTemplate && !smsTemplate.isEmpty()) {
customSmsTemplate = smsTemplate;
}
}
String versionName = SettingUtil.getVersionName();
String versionName = SettingUtils.getVersionName();
String smsVoForSend = customSmsTemplate.replace(getString(R.string.tag_from), mobile)
.replace(getString(R.string.tag_package_name), mobile)
.replace(getString(R.string.tag_sms), content)

@ -11,11 +11,11 @@ import com.idormy.sms.forwarder.model.LogModel;
import com.idormy.sms.forwarder.model.vo.ResVo;
import com.idormy.sms.forwarder.model.vo.SmsHubVo;
import com.idormy.sms.forwarder.utils.CloneUtils;
import com.idormy.sms.forwarder.utils.HttpUtil;
import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.SettingUtil;
import com.idormy.sms.forwarder.utils.SimUtil;
import com.idormy.sms.forwarder.utils.SmsUtil;
import com.idormy.sms.forwarder.utils.HttpUtils;
import com.idormy.sms.forwarder.utils.LogUtils;
import com.idormy.sms.forwarder.utils.SettingUtils;
import com.idormy.sms.forwarder.utils.SimUtils;
import com.idormy.sms.forwarder.utils.SmsUtils;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
@ -56,7 +56,7 @@ public class BaseServlet extends HttpServlet {
public BaseServlet(String path, Context context) {
this.path = path;
this.context = context;
SettingUtil.init(context);
SettingUtils.init(context);
}
public Context getContext() {
@ -226,17 +226,17 @@ public class BaseServlet extends HttpServlet {
if (SmsHubVo.Action.send.code().equals(vo.getAction())) {
vo.setType(SmsHubVo.Type.sms.code());
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP_MR1) {
int subscriptionIdBySimId = SimUtil.getSubscriptionIdBySimId(Integer.parseInt(vo.getChannel()) - 1);
msg = SmsUtil.sendSms(subscriptionIdBySimId, vo.getTarget(), vo.getContent());
int subscriptionIdBySimId = SimUtils.getSubscriptionIdBySimId(Integer.parseInt(vo.getChannel()) - 1);
msg = SmsUtils.sendSms(subscriptionIdBySimId, vo.getTarget(), vo.getContent());
String simInfo = "SIM" + (subscriptionIdBySimId + 1);
vo.setChannel(simInfo);
logId = LogUtil.addLog(new LogModel(vo.getType(), vo.getTarget(), vo.getContent(), simInfo, RULE_ID));
logId = LogUtils.addLog(new LogModel(vo.getType(), vo.getTarget(), vo.getContent(), simInfo, RULE_ID));
if (msg == null) {
failure = false;
HttpUtil.Toast(tag, "短信发送成功");
HttpUtils.Toast(tag, "短信发送成功");
Log.i(tag, "短信发送成功");
vo.setAction(SmsHubVo.Action.suessces.code());
LogUtil.updateLog(logId, 2, SmsHubVo.Action.suessces.code());
LogUtils.updateLog(logId, 2, SmsHubVo.Action.suessces.code());
}
} else {
msg = "api<22";
@ -248,12 +248,12 @@ public class BaseServlet extends HttpServlet {
}
if (failure) {
msg = "短信发送失败:" + msg;
HttpUtil.Toast(tag, msg);
HttpUtils.Toast(tag, msg);
Log.i(tag, msg);
vo.setAction(SmsHubVo.Action.failure.code());
vo.setErrMsg(msg);
if (logId != null) {
LogUtil.updateLog(logId, 0, msg);
LogUtils.updateLog(logId, 0, msg);
}
}
}

@ -15,8 +15,8 @@ import com.idormy.sms.forwarder.sender.SendUtil;
import com.idormy.sms.forwarder.utils.CommonUtil;
import com.idormy.sms.forwarder.utils.ContactHelper;
import com.idormy.sms.forwarder.utils.PhoneUtils;
import com.idormy.sms.forwarder.utils.SettingUtil;
import com.idormy.sms.forwarder.utils.SimUtil;
import com.idormy.sms.forwarder.utils.SettingUtils;
import com.idormy.sms.forwarder.utils.SimUtils;
import java.text.SimpleDateFormat;
import java.util.Date;
@ -30,7 +30,7 @@ public class PhoneStateReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (!SettingUtil.getSwitchEnablePhone()) {
if (!SettingUtils.getSwitchEnablePhone()) {
return;
}
@ -84,9 +84,9 @@ public class PhoneStateReceiver extends BroadcastReceiver {
if (callInfo == null) return;
int type = callInfo.getType();
if ((type == 1 && !SettingUtil.getSwitchCallType1())
|| (type == 2 && !SettingUtil.getSwitchCallType2())
|| (type == 3 && !SettingUtil.getSwitchCallType3())) {
if ((type == 1 && !SettingUtils.getSwitchCallType1())
|| (type == 2 && !SettingUtils.getSwitchCallType2())
|| (type == 3 && !SettingUtils.getSwitchCallType3())) {
Log.w(TAG, "Call record forwarding of this type is not enabled, no processing will be done!");
return;
}
@ -100,9 +100,9 @@ public class PhoneStateReceiver extends BroadcastReceiver {
int simId = 1;
Log.d(TAG, "getSubscriptionId = " + callInfo.getSubscriptionId()); //TODO:这里的SubscriptionId跟短信的不一样
if (callInfo.getSubscriptionId() != -1) {
simId = SimUtil.getSimIdBySubscriptionId(callInfo.getSubscriptionId());
simId = SimUtils.getSimIdBySubscriptionId(callInfo.getSubscriptionId());
}
simInfo = simId == 2 ? SettingUtil.getAddExtraSim2() : SettingUtil.getAddExtraSim1(); //自定义备注优先
simInfo = simId == 2 ? SettingUtils.getAddExtraSim2() : SettingUtils.getAddExtraSim1(); //自定义备注优先
simInfo = "SIM" + simId + "_" + simInfo;
if (TextUtils.isEmpty(name)) {
@ -116,14 +116,14 @@ public class PhoneStateReceiver extends BroadcastReceiver {
//TODO:同一卡槽同一秒的重复未接来电广播不再重复处理(部分机型会收到两条广播?)
String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINESE).format(new Date());
String prevHash = SettingUtil.getPrevNoticeHash(phoneNumber);
String prevHash = SettingUtils.getPrevNoticeHash(phoneNumber);
String currHash = CommonUtil.MD5(phoneNumber + simInfo + time);
Log.d(TAG, "prevHash=" + prevHash + " currHash=" + currHash);
if (prevHash != null && prevHash.equals(currHash)) {
Log.w(TAG, "Repeated missed call broadcasts of the same card slot in the same second are no longer processed repeatedly (some models will receive two broadcasts)");
return;
}
SettingUtil.setPrevNoticeHash(phoneNumber, currHash);
SettingUtils.setPrevNoticeHash(phoneNumber, currHash);
SmsVo smsVo = new SmsVo(phoneNumber, getTypeText(context, type, name, viaNumber), new Date(), simInfo);
Log.d(TAG, "send_msg" + smsVo);

@ -9,8 +9,8 @@ import android.util.Log;
import com.idormy.sms.forwarder.service.BatteryService;
import com.idormy.sms.forwarder.service.FrontService;
import com.idormy.sms.forwarder.service.MusicService;
import com.idormy.sms.forwarder.utils.InitUtil;
import com.idormy.sms.forwarder.utils.SettingUtil;
import com.idormy.sms.forwarder.utils.InitUtils;
import com.idormy.sms.forwarder.utils.SettingUtils;
public class RebootBroadcastReceiver extends BroadcastReceiver {
@ -20,7 +20,7 @@ public class RebootBroadcastReceiver extends BroadcastReceiver {
String TAG = "RebootBroadcastReceiver";
Log.d(TAG, "onReceive intent " + receiveAction);
if (receiveAction.equals("android.intent.action.BOOT_COMPLETED")) {
InitUtil.init(context);
InitUtils.init(context);
//前台服务
Intent frontServiceIntent = new Intent(context, FrontService.class);
@ -35,7 +35,7 @@ public class RebootBroadcastReceiver extends BroadcastReceiver {
context.startService(batteryServiceIntent);
//后台播放无声音乐
if (SettingUtil.getPlaySilenceMusic()) {
if (SettingUtils.getPlaySilenceMusic()) {
context.startService(new Intent(context, MusicService.class));
}
}

@ -7,7 +7,7 @@ import android.util.Log;
import com.idormy.sms.forwarder.MyApplication;
import com.idormy.sms.forwarder.utils.OnePixelManager;
import com.idormy.sms.forwarder.utils.SettingUtil;
import com.idormy.sms.forwarder.utils.SettingUtils;
//监听屏幕状态变换广播(开屏、锁屏、解锁)
public class ScreenBroadcastReceiver extends BroadcastReceiver {
@ -18,7 +18,7 @@ public class ScreenBroadcastReceiver extends BroadcastReceiver {
String action = intent.getAction();
//1像素透明Activity保活
if (SettingUtil.getOnePixelActivity()) {
if (SettingUtils.getOnePixelActivity()) {
OnePixelManager manager = new OnePixelManager();
if (Intent.ACTION_SCREEN_ON.equals(action)) {//如果亮屏则关闭1像素Activity
manager.finishOnePixelActivity();

@ -12,8 +12,8 @@ import androidx.annotation.RequiresApi;
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 com.idormy.sms.forwarder.utils.SettingUtils;
import com.idormy.sms.forwarder.utils.SimUtils;
import java.util.ArrayList;
import java.util.Date;
@ -37,7 +37,7 @@ public class SmsBroadcastReceiver extends BroadcastReceiver {
if (SMS_RECEIVED_ACTION.equals(receiveAction) || SMS_DELIVER_ACTION.equals(receiveAction)) {
try {
if (!SettingUtil.getSwitchEnableSms()) {
if (!SettingUtils.getSwitchEnableSms()) {
return;
}
@ -53,11 +53,11 @@ public class SmsBroadcastReceiver extends BroadcastReceiver {
if (extras.containsKey("simId")) {
simId = extras.getInt("simId");
} else if (extras.containsKey("subscription")) {
simId = SimUtil.getSimIdBySubscriptionId(extras.getInt("subscription"));
simId = SimUtils.getSimIdBySubscriptionId(extras.getInt("subscription"));
}
//自定义备注优先
simInfo = simId == 2 ? SettingUtil.getAddExtraSim2() : SettingUtil.getAddExtraSim1();
simInfo = simId == 2 ? SettingUtils.getAddExtraSim2() : SettingUtils.getAddExtraSim1();
simInfo = "SIM" + simId + "_" + simInfo;
} catch (Exception e) {
Log.e(TAG, "Failed to get the receiving phone number:" + e.getMessage());

@ -8,7 +8,7 @@ import android.util.Log;
import com.idormy.sms.forwarder.MyApplication;
import com.idormy.sms.forwarder.model.vo.SmsVo;
import com.idormy.sms.forwarder.utils.BatteryUtils;
import com.idormy.sms.forwarder.utils.SettingUtil;
import com.idormy.sms.forwarder.utils.SettingUtils;
import java.util.Calendar;
import java.util.Date;
@ -36,7 +36,7 @@ public class BatteryReportCronTask {
public void updateTimer() {
cancelTimer();
if (SettingUtil.getSwitchEnableBatteryCron()) {
if (SettingUtils.getSwitchEnableBatteryCron()) {
startTimer();
} else {
Log.d(TAG, "Cancel Task");
@ -51,8 +51,8 @@ public class BatteryReportCronTask {
}
private void startTimer() {
String startTime = SettingUtil.getBatteryCronStartTime();
int interval = SettingUtil.getBatteryCronInterval();
String startTime = SettingUtils.getBatteryCronStartTime();
int interval = SettingUtils.getBatteryCronInterval();
Log.i(TAG, "Task started, startTime: " + startTime + ", interval: " + interval);
int hour = Integer.parseInt(startTime.split(":")[0]);

@ -9,8 +9,8 @@ import com.idormy.sms.forwarder.R;
import com.idormy.sms.forwarder.model.vo.SmsHubVo;
import com.idormy.sms.forwarder.receiver.BaseServlet;
import com.idormy.sms.forwarder.utils.Define;
import com.idormy.sms.forwarder.utils.NetUtil;
import com.idormy.sms.forwarder.utils.SettingUtil;
import com.idormy.sms.forwarder.utils.NetUtils;
import com.idormy.sms.forwarder.utils.SettingUtils;
import org.eclipse.jetty.server.Server;
@ -58,7 +58,7 @@ public class HttpServer {
public synchronized static boolean update() {
//非WiFi网络下不可启用
if (NetUtil.NETWORK_WIFI != NetUtil.getNetWorkStatus()) {
if (NetUtils.NETWORK_WIFI != NetUtils.getNetWorkStatus()) {
ToastUtils.show(R.string.no_wifi_network);
if (asRunning()) stop();
return false;
@ -68,10 +68,10 @@ public class HttpServer {
ToastUtils.show(R.string.tips_wait_3_seconds);
return false;
}
if (asRunning().equals(SettingUtil.getSwitchEnableHttpServer())) {
if (asRunning().equals(SettingUtils.getSwitchEnableHttpServer())) {
return false;
}
if (SettingUtil.getSwitchEnableHttpServer()) {
if (SettingUtils.getSwitchEnableHttpServer()) {
SmsHubVo.getDevInfoMap(true);
start();
ts = System.currentTimeMillis();

@ -4,7 +4,7 @@ import android.util.Log;
import androidx.annotation.NonNull;
import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.LogUtils;
import java.io.IOException;
import java.io.InterruptedIOException;
@ -58,7 +58,7 @@ public class RetryIntercepter implements Interceptor {
response = chain.proceed(request);
} catch (Exception e) {
String resp = retryTimes > 0 ? "第" + retryTimes + "次重试:" + e.getMessage() : e.getMessage();
LogUtil.updateLog(logId, 1, resp);
LogUtils.updateLog(logId, 1, resp);
Log.w(TAG, resp);
}
return response;

@ -13,7 +13,7 @@ import com.idormy.sms.forwarder.model.LogModel;
import com.idormy.sms.forwarder.model.LogTable;
import com.idormy.sms.forwarder.utils.DbHelper;
import com.idormy.sms.forwarder.utils.Define;
import com.idormy.sms.forwarder.utils.SettingUtil;
import com.idormy.sms.forwarder.utils.SettingUtils;
import java.util.ArrayList;
import java.util.HashSet;
@ -43,7 +43,7 @@ public class SendHistory {
@SuppressLint("MutatingSharedPrefs")
public static void addHistory(String msg) {
//不保存转发消息
if (SettingUtil.saveMsgHistory()) return;
if (SettingUtils.saveMsgHistory()) return;
//保存
SharedPreferences sp = context.getSharedPreferences(Define.SP_MSG, Context.MODE_PRIVATE);
Set<String> msg_set_default = new HashSet<>();
@ -69,7 +69,7 @@ public class SendHistory {
public static long addHistoryDb(LogModel logModel) {
//不保存转发消息
if (SettingUtil.saveMsgHistory()) return 0;
if (SettingUtils.saveMsgHistory()) return 0;
// Gets the data repository in write mode
SQLiteDatabase db = dbHelper.getWritableDatabase();

@ -36,11 +36,11 @@ import com.idormy.sms.forwarder.model.vo.SmsSettingVo;
import com.idormy.sms.forwarder.model.vo.SmsVo;
import com.idormy.sms.forwarder.model.vo.TelegramSettingVo;
import com.idormy.sms.forwarder.model.vo.WebNotifySettingVo;
import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.NetUtil;
import com.idormy.sms.forwarder.utils.RuleUtil;
import com.idormy.sms.forwarder.utils.SettingUtil;
import com.idormy.sms.forwarder.utils.TimeUtil;
import com.idormy.sms.forwarder.utils.LogUtils;
import com.idormy.sms.forwarder.utils.NetUtils;
import com.idormy.sms.forwarder.utils.RuleUtils;
import com.idormy.sms.forwarder.utils.SettingUtils;
import com.idormy.sms.forwarder.utils.TimeUtils;
import java.text.ParseException;
import java.util.Date;
@ -58,11 +58,11 @@ public class SendUtil {
public static void send_msg(Context context, SmsVo smsVo, int simId, String type) {
Log.i(TAG, "send_msg smsVo:" + smsVo);
RuleUtil.init(context);
LogUtil.init(context);
RuleUtils.init(context);
LogUtils.init(context);
String key = "SIM" + simId;
List<RuleModel> ruleList = RuleUtil.getRule(null, key, type, "1"); //只取已启用的规则
List<RuleModel> ruleList = RuleUtils.getRule(null, key, type, "1"); //只取已启用的规则
if (!ruleList.isEmpty()) {
Log.d(TAG, ruleList.toString());
SenderUtil.init(context);
@ -73,7 +73,7 @@ public class SendUtil {
List<SenderModel> senderModels = SenderUtil.getSender(ruleModel.getSenderId(), null);
for (SenderModel senderModel : senderModels
) {
long logId = LogUtil.addLog(new LogModel(type, smsVo.getMobile(), smsVo.getContent(), smsVo.getSimInfo(), ruleModel.getId()));
long logId = LogUtils.addLog(new LogModel(type, smsVo.getMobile(), smsVo.getContent(), smsVo.getSimInfo(), ruleModel.getId()));
String smsTemplate = ruleModel.getSwitchSmsTemplate() ? ruleModel.getSmsTemplate() : "";
String regexReplace = ruleModel.getSwitchRegexReplace() ? ruleModel.getRegexReplace() : "";
SendUtil.senderSendMsgNoHandError(smsVo, senderModel, logId, smsTemplate, regexReplace);
@ -98,7 +98,7 @@ public class SendUtil {
Log.d(TAG, logVo.toString());
Date date = new Date();
try {
date = TimeUtil.utc2LocalDate(logVo.getTime());
date = TimeUtils.utc2LocalDate(logVo.getTime());
} catch (ParseException e) {
Log.e(TAG, "SimpleDateFormat parse error", e);
}
@ -114,8 +114,8 @@ public class SendUtil {
key = "SIM2";
}
RuleUtil.init(context);
List<RuleModel> ruleList = RuleUtil.getRule(null, key, logVo.getType(), "1"); //只取已启用的规则
RuleUtils.init(context);
List<RuleModel> ruleList = RuleUtils.getRule(null, key, logVo.getType(), "1"); //只取已启用的规则
if (!ruleList.isEmpty()) {
SenderUtil.init(context);
for (RuleModel ruleModel : ruleList) {
@ -168,8 +168,8 @@ public class SendUtil {
//网络请求+延时重试比较耗时,创建子线程处理
new Thread(() -> {
try {
int retryTimes = SettingUtil.getRetryTimes();
int delayTime = SettingUtil.getDelayTime();
int retryTimes = SettingUtils.getRetryTimes();
int delayTime = SettingUtils.getDelayTime();
RetryIntercepter retryInterceptor = retryTimes < 1 ? null : new RetryIntercepter.Builder().executionCount(retryTimes).retryInterval(delayTime).logId(logId).build();
SendUtil.senderSendMsg(null, retryInterceptor, smsVo, senderModel, logId, smsTemplate, regexReplace);
} catch (Exception e) {
@ -183,7 +183,7 @@ public class SendUtil {
Log.i(TAG, "senderSendMsg smsVo:" + smsVo.toString() + "senderModel:" + senderModel.toString());
if (senderModel.getStatus() == STATUS_OFF) {
LogUtil.updateLog(logId, 0, "发送通道已被禁用!");
LogUtils.updateLog(logId, 0, "发送通道已被禁用!");
Log.i(TAG, "发送通道已被禁用!");
return;
}
@ -197,7 +197,7 @@ public class SendUtil {
try {
SenderDingdingMsg.sendMsg(logId, handError, retryInterceptor, dingDingSettingVo.getToken(), dingDingSettingVo.getSecret(), dingDingSettingVo.getAtMobiles(), dingDingSettingVo.getAtAll(), smsVo.getSmsVoForSend(smsTemplate, regexReplace));
} catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage());
LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: dingding error " + e.getMessage());
}
}
@ -212,7 +212,7 @@ public class SendUtil {
try {
SenderMailMsg.sendEmail(logId, handError, emailSettingVo, smsVo.getTitleForSend(emailSettingVo.getTitle(), regexReplace), smsVo.getSmsVoForSend(smsTemplate, regexReplace));
} catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage());
LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: SenderMailMsg error " + e.getMessage());
}
}
@ -227,7 +227,7 @@ public class SendUtil {
try {
SenderBarkMsg.sendMsg(logId, handError, retryInterceptor, barkSettingVo, smsVo.getTitleForSend(barkSettingVo.getTitle()), smsVo.getSmsVoForSend(smsTemplate, regexReplace), senderModel.getName());
} catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage());
LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: SenderBarkMsg error " + e.getMessage());
}
}
@ -242,7 +242,7 @@ public class SendUtil {
try {
SenderWebNotifyMsg.sendMsg(logId, handError, retryInterceptor, webNotifySettingVo.getWebServer(), webNotifySettingVo.getWebParams(), webNotifySettingVo.getSecret(), webNotifySettingVo.getMethod(), webNotifySettingVo.getHeaders(), smsVo, smsTemplate, regexReplace);
} catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage());
LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: SenderWebNotifyMsg error " + e.getMessage());
}
}
@ -257,7 +257,7 @@ public class SendUtil {
try {
SenderQyWxGroupRobotMsg.sendMsg(logId, handError, retryInterceptor, qywxGroupRobotSettingVo.getWebHook(), smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate, regexReplace));
} catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage());
LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: SenderQyWxGroupRobotMsg error " + e.getMessage());
}
}
@ -272,7 +272,7 @@ public class SendUtil {
try {
SenderQyWxAppMsg.sendMsg(logId, handError, retryInterceptor, senderModel, qYWXAppSettingVo, smsVo.getSmsVoForSend(smsTemplate, regexReplace));
} catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage());
LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: qywx_app error " + e.getMessage());
}
}
@ -287,7 +287,7 @@ public class SendUtil {
try {
SenderServerChanMsg.sendMsg(logId, handError, retryInterceptor, serverChanSettingVo.getSendKey(), smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate, regexReplace));
} catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage());
LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: SenderServerChanMsg error " + e.getMessage());
}
}
@ -302,7 +302,7 @@ public class SendUtil {
try {
SenderTelegramMsg.sendMsg(logId, handError, retryInterceptor, telegramSettingVo, smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate, regexReplace), telegramSettingVo.getMethod());
} catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage());
LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: SenderTelegramMsg error " + e.getMessage());
}
}
@ -315,9 +315,9 @@ public class SendUtil {
SmsSettingVo smsSettingVo = JSON.parseObject(senderModel.getJsonSetting(), SmsSettingVo.class);
if (smsSettingVo != null) {
//仅当无网络时启用
if (smsSettingVo.getOnlyNoNetwork() && 0 != NetUtil.getNetWorkStatus()) {
String msg = "仅当无网络时启用,当前网络状态:" + NetUtil.getNetWorkStatus();
LogUtil.updateLog(logId, 0, msg);
if (smsSettingVo.getOnlyNoNetwork() && 0 != NetUtils.getNetWorkStatus()) {
String msg = "仅当无网络时启用,当前网络状态:" + NetUtils.getNetWorkStatus();
LogUtils.updateLog(logId, 0, msg);
Log.d(TAG, msg);
return;
}
@ -329,7 +329,7 @@ public class SendUtil {
}
SenderSmsMsg.sendMsg(logId, handError, simSlot, smsSettingVo.getMobiles(), smsSettingVo.getOnlyNoNetwork(), smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate, regexReplace));
} catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage());
LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: SenderSmsMsg error " + e.getMessage());
}
}
@ -344,7 +344,7 @@ public class SendUtil {
try {
SenderFeishuMsg.sendMsg(logId, handError, retryInterceptor, feiShuSettingVo.getWebhook(), feiShuSettingVo.getSecret(), feiShuSettingVo.getMsgType(), smsVo.getMobile(), smsVo.getDate(), smsVo.getTitleForSend(feiShuSettingVo.getTitleTemplate()), smsVo.getSmsVoForSend(smsTemplate, regexReplace));
} catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage());
LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: feishu error " + e.getMessage());
}
}
@ -359,7 +359,7 @@ public class SendUtil {
try {
SenderPushPlusMsg.sendMsg(logId, handError, retryInterceptor, pushPlusSettingVo, smsVo.getTitleForSend(pushPlusSettingVo.getTitleTemplate()), smsVo.getSmsVoForSend(smsTemplate, regexReplace));
} catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage());
LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: feishu error " + e.getMessage());
}
}
@ -374,7 +374,7 @@ public class SendUtil {
try {
SenderGotifyMsg.sendMsg(logId, handError, retryInterceptor, gotifySettingVo, smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate, regexReplace));
} catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage());
LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: gotify error " + e.getMessage());
}
}

@ -8,7 +8,7 @@ import androidx.annotation.NonNull;
import com.idormy.sms.forwarder.model.vo.BarkSettingVo;
import com.idormy.sms.forwarder.utils.Define;
import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.LogUtils;
import java.io.IOException;
import java.util.Objects;
@ -89,7 +89,7 @@ public class SenderBarkMsg extends SenderBaseMsg {
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(@NonNull Call call, @NonNull final IOException e) {
LogUtil.updateLog(logId, 0, e.getMessage());
LogUtils.updateLog(logId, 0, e.getMessage());
Toast(handError, TAG, "发送失败:" + e.getMessage());
}
@ -101,9 +101,9 @@ public class SenderBarkMsg extends SenderBaseMsg {
//TODO:粗略解析是否发送成功
if (responseStr.contains("\"message\":\"success\"")) {
LogUtil.updateLog(logId, 2, responseStr);
LogUtils.updateLog(logId, 2, responseStr);
} else {
LogUtil.updateLog(logId, 0, responseStr);
LogUtils.updateLog(logId, 0, responseStr);
}
}
});

@ -9,7 +9,7 @@ import androidx.annotation.NonNull;
import com.alibaba.fastjson.JSON;
import com.idormy.sms.forwarder.utils.Define;
import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.LogUtils;
import java.io.IOException;
import java.net.URLEncoder;
@ -110,7 +110,7 @@ public class SenderDingdingMsg extends SenderBaseMsg {
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(@NonNull Call call, @NonNull final IOException e) {
LogUtil.updateLog(logId, 0, e.getMessage());
LogUtils.updateLog(logId, 0, e.getMessage());
Toast(handError, TAG, "发送失败:" + e.getMessage());
}
@ -122,9 +122,9 @@ public class SenderDingdingMsg extends SenderBaseMsg {
//TODO:粗略解析是否发送成功
if (responseStr.contains("\"errcode\":0")) {
LogUtil.updateLog(logId, 2, responseStr);
LogUtils.updateLog(logId, 2, responseStr);
} else {
LogUtil.updateLog(logId, 0, responseStr);
LogUtils.updateLog(logId, 0, responseStr);
}
}
});

@ -8,7 +8,7 @@ import androidx.annotation.NonNull;
import com.alibaba.fastjson.JSON;
import com.idormy.sms.forwarder.utils.Define;
import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.LogUtils;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@ -151,7 +151,7 @@ public class SenderFeishuMsg extends SenderBaseMsg {
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(@NonNull Call call, @NonNull final IOException e) {
LogUtil.updateLog(logId, 0, e.getMessage());
LogUtils.updateLog(logId, 0, e.getMessage());
Toast(handError, TAG, "发送失败:" + e.getMessage());
}
@ -163,9 +163,9 @@ public class SenderFeishuMsg extends SenderBaseMsg {
//TODO:粗略解析是否发送成功
if (responseStr.contains("\"StatusCode\":0")) {
LogUtil.updateLog(logId, 2, responseStr);
LogUtils.updateLog(logId, 2, responseStr);
} else {
LogUtil.updateLog(logId, 0, responseStr);
LogUtils.updateLog(logId, 0, responseStr);
}
}
});
@ -173,7 +173,7 @@ public class SenderFeishuMsg extends SenderBaseMsg {
}
private static String buildMsg(String from, Date date, String title, String content) {
//if (TextUtils.isEmpty(title)) title = "【" + SettingUtil.getAddExtraDeviceMark().trim() + "】来自" + from + "的通知";
//if (TextUtils.isEmpty(title)) title = "【" + SettingUtils.getAddExtraDeviceMark().trim() + "】来自" + from + "的通知";
String msgTitle = jsonInnerStr(title);
String msgTime = jsonInnerStr(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()).format(date));
String msgFrom = jsonInnerStr(from);

@ -8,7 +8,7 @@ import androidx.annotation.NonNull;
import com.idormy.sms.forwarder.model.vo.GotifySettingVo;
import com.idormy.sms.forwarder.utils.CertUtils;
import com.idormy.sms.forwarder.utils.Define;
import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.LogUtils;
import java.io.IOException;
import java.util.Objects;
@ -58,7 +58,7 @@ public class SenderGotifyMsg extends SenderBaseMsg {
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(@NonNull Call call, @NonNull final IOException e) {
LogUtil.updateLog(logId, 0, e.getMessage());
LogUtils.updateLog(logId, 0, e.getMessage());
Toast(handError, TAG, "发送失败:" + e.getMessage());
}
@ -70,9 +70,9 @@ public class SenderGotifyMsg extends SenderBaseMsg {
//TODO:粗略解析是否发送成功
if (response.isSuccessful()) {
LogUtil.updateLog(logId, 2, responseStr);
LogUtils.updateLog(logId, 2, responseStr);
} else {
LogUtil.updateLog(logId, 0, responseStr);
LogUtils.updateLog(logId, 0, responseStr);
}
}
});

@ -7,7 +7,7 @@ import android.util.Log;
import com.idormy.sms.forwarder.MyApplication;
import com.idormy.sms.forwarder.R;
import com.idormy.sms.forwarder.model.vo.EmailSettingVo;
import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.LogUtils;
import com.smailnet.emailkit.Draft;
import com.smailnet.emailkit.EmailKit;
@ -55,13 +55,13 @@ public class SenderMailMsg extends SenderBaseMsg {
.send(draft, new EmailKit.GetSendCallback() {
@Override
public void onSuccess() {
LogUtil.updateLog(logId, 2, "发送成功");
LogUtils.updateLog(logId, 2, "发送成功");
Toast(handError, TAG, "发送成功");
}
@Override
public void onFailure(String errMsg) {
LogUtil.updateLog(logId, 0, errMsg);
LogUtils.updateLog(logId, 0, errMsg);
Toast(handError, TAG, "发送失败,错误:" + errMsg);
}
});
@ -70,7 +70,7 @@ public class SenderMailMsg extends SenderBaseMsg {
EmailKit.destroy();
} catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage());
LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, e.getMessage(), e);
Toast(handError, TAG, "发送失败:" + e.getMessage());
}

@ -8,7 +8,7 @@ import androidx.annotation.NonNull;
import com.alibaba.fastjson.JSON;
import com.idormy.sms.forwarder.model.vo.PushPlusSettingVo;
import com.idormy.sms.forwarder.utils.Define;
import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.LogUtils;
import java.io.IOException;
import java.util.HashMap;
@ -96,7 +96,7 @@ public class SenderPushPlusMsg extends SenderBaseMsg {
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(@NonNull Call call, @NonNull final IOException e) {
LogUtil.updateLog(logId, 0, e.getMessage());
LogUtils.updateLog(logId, 0, e.getMessage());
Toast(handError, TAG, "发送失败:" + e.getMessage());
}
@ -108,9 +108,9 @@ public class SenderPushPlusMsg extends SenderBaseMsg {
//TODO:粗略解析是否发送成功
if (responseStr.contains("\"code\":200")) {
LogUtil.updateLog(logId, 2, responseStr);
LogUtils.updateLog(logId, 2, responseStr);
} else {
LogUtil.updateLog(logId, 0, responseStr);
LogUtils.updateLog(logId, 0, responseStr);
}
}
});

@ -10,7 +10,7 @@ import com.alibaba.fastjson.JSONObject;
import com.idormy.sms.forwarder.model.SenderModel;
import com.idormy.sms.forwarder.model.vo.QYWXAppSettingVo;
import com.idormy.sms.forwarder.utils.Define;
import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.LogUtils;
import java.io.IOException;
import java.util.HashMap;
@ -74,7 +74,7 @@ public class SenderQyWxAppMsg extends SenderBaseMsg {
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(@NonNull Call call, @NonNull final IOException e) {
LogUtil.updateLog(logId, 0, e.getMessage());
LogUtils.updateLog(logId, 0, e.getMessage());
qYWXAppSettingVo.setAccessToken("");
qYWXAppSettingVo.setExpiresIn(0L);
if (senderModel != null) {
@ -107,7 +107,7 @@ public class SenderQyWxAppMsg extends SenderBaseMsg {
sendTextMsg(retryInterceptor, logId, handError, agentID, toUser, content, access_token);
} else {
String errmsg = jsonObject.getString("errmsg");
LogUtil.updateLog(logId, 0, errmsg);
LogUtils.updateLog(logId, 0, errmsg);
Log.d(TAG, "onFailure" + errmsg);
Toast(handError, TAG, "获取access_token失败" + errmsg);
}
@ -159,7 +159,7 @@ public class SenderQyWxAppMsg extends SenderBaseMsg {
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(@NonNull Call call, @NonNull final IOException e) {
LogUtil.updateLog(logId, 0, e.getMessage());
LogUtils.updateLog(logId, 0, e.getMessage());
Toast(handError, TAG, "发送失败:" + e.getMessage());
}
@ -171,9 +171,9 @@ public class SenderQyWxAppMsg extends SenderBaseMsg {
//TODO:粗略解析是否发送成功
if (responseStr.contains("\"errcode\":0")) {
LogUtil.updateLog(logId, 2, responseStr);
LogUtils.updateLog(logId, 2, responseStr);
} else {
LogUtil.updateLog(logId, 0, responseStr);
LogUtils.updateLog(logId, 0, responseStr);
}
}
});

@ -7,7 +7,7 @@ import androidx.annotation.NonNull;
import com.alibaba.fastjson.JSON;
import com.idormy.sms.forwarder.utils.Define;
import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.LogUtils;
import java.io.IOException;
import java.util.HashMap;
@ -66,7 +66,7 @@ public class SenderQyWxGroupRobotMsg extends SenderBaseMsg {
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(@NonNull Call call, @NonNull final IOException e) {
LogUtil.updateLog(logId, 0, e.getMessage());
LogUtils.updateLog(logId, 0, e.getMessage());
Toast(handError, TAG, "发送失败:" + e.getMessage());
}
@ -78,9 +78,9 @@ public class SenderQyWxGroupRobotMsg extends SenderBaseMsg {
//TODO:粗略解析是否发送成功
if (responseStr.contains("\"errcode\":0")) {
LogUtil.updateLog(logId, 2, responseStr);
LogUtils.updateLog(logId, 2, responseStr);
} else {
LogUtil.updateLog(logId, 0, responseStr);
LogUtils.updateLog(logId, 0, responseStr);
}
}
});

@ -6,7 +6,7 @@ import android.util.Log;
import androidx.annotation.NonNull;
import com.idormy.sms.forwarder.utils.Define;
import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.LogUtils;
import java.io.IOException;
import java.util.Objects;
@ -58,7 +58,7 @@ public class SenderServerChanMsg extends SenderBaseMsg {
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(@NonNull Call call, @NonNull final IOException e) {
LogUtil.updateLog(logId, 0, e.getMessage());
LogUtils.updateLog(logId, 0, e.getMessage());
Toast(handError, TAG, "发送失败:" + e.getMessage());
}
@ -70,9 +70,9 @@ public class SenderServerChanMsg extends SenderBaseMsg {
//TODO:粗略解析是否发送成功
if (responseStr.contains("\"code\":0")) {
LogUtil.updateLog(logId, 2, responseStr);
LogUtils.updateLog(logId, 2, responseStr);
} else {
LogUtil.updateLog(logId, 0, responseStr);
LogUtils.updateLog(logId, 0, responseStr);
}
}
});

@ -4,9 +4,9 @@ import android.annotation.SuppressLint;
import android.os.Handler;
import android.util.Log;
import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.SimUtil;
import com.idormy.sms.forwarder.utils.SmsUtil;
import com.idormy.sms.forwarder.utils.LogUtils;
import com.idormy.sms.forwarder.utils.SimUtils;
import com.idormy.sms.forwarder.utils.SmsUtils;
@SuppressWarnings("RedundantThrows")
public class SenderSmsMsg extends SenderBaseMsg {
@ -18,14 +18,14 @@ public class SenderSmsMsg extends SenderBaseMsg {
Log.i(TAG, "sendMsg simSlot:" + simSlot + " mobiles:" + mobiles + " onlyNoNetwork:" + onlyNoNetwork + " from:" + from + " text:" + text);
//TODOsimSlot转subId
final int subId = SimUtil.getSubscriptionIdBySimId(simSlot);
String res = SmsUtil.sendSms(subId, mobiles, text);
final int subId = SimUtils.getSubscriptionIdBySimId(simSlot);
String res = SmsUtils.sendSms(subId, mobiles, text);
//TODO:粗略解析是否发送成功
if (res == null) {
LogUtil.updateLog(logId, 2, "发送成功");
LogUtils.updateLog(logId, 2, "发送成功");
} else {
LogUtil.updateLog(logId, 0, res);
LogUtils.updateLog(logId, 0, res);
Toast(handError, TAG, "短信发送失败");
}

@ -9,7 +9,7 @@ import androidx.annotation.NonNull;
import com.alibaba.fastjson.JSON;
import com.idormy.sms.forwarder.model.vo.TelegramSettingVo;
import com.idormy.sms.forwarder.utils.Define;
import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.LogUtils;
import java.io.IOException;
import java.net.InetSocketAddress;
@ -112,7 +112,7 @@ public class SenderTelegramMsg extends SenderBaseMsg {
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(@NonNull Call call, @NonNull final IOException e) {
LogUtil.updateLog(logId, 0, e.getMessage());
LogUtils.updateLog(logId, 0, e.getMessage());
Toast(handError, TAG, "发送失败:" + e.getMessage());
}
@ -124,9 +124,9 @@ public class SenderTelegramMsg extends SenderBaseMsg {
//TODO:粗略解析是否发送成功
if (responseStr.contains("\"ok\":true")) {
LogUtil.updateLog(logId, 2, responseStr);
LogUtils.updateLog(logId, 2, responseStr);
} else {
LogUtil.updateLog(logId, 0, responseStr);
LogUtils.updateLog(logId, 0, responseStr);
}
}
});

@ -12,8 +12,8 @@ import com.alibaba.fastjson.JSON;
import com.idormy.sms.forwarder.model.vo.SmsVo;
import com.idormy.sms.forwarder.utils.CertUtils;
import com.idormy.sms.forwarder.utils.Define;
import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.SettingUtil;
import com.idormy.sms.forwarder.utils.LogUtils;
import com.idormy.sms.forwarder.utils.SettingUtils;
import java.io.IOException;
import java.net.URLEncoder;
@ -51,8 +51,8 @@ public class SenderWebNotifyMsg extends SenderBaseMsg {
Long timestamp = System.currentTimeMillis();
String orgContent = smsVo.getContent();
String deviceMark = SettingUtil.getAddExtraDeviceMark().trim();
String appVersion = SettingUtil.getVersionName();
String deviceMark = SettingUtils.getAddExtraDeviceMark().trim();
String appVersion = SettingUtils.getVersionName();
String simInfo = smsVo.getSimInfo();
@SuppressLint("SimpleDateFormat") String receiveTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(smsVo.getDate());
@ -160,7 +160,7 @@ public class SenderWebNotifyMsg extends SenderBaseMsg {
client.newCall(requestBuilder.build()).enqueue(new Callback() {
@Override
public void onFailure(@NonNull Call call, @NonNull final IOException e) {
LogUtil.updateLog(logId, 0, e.getMessage());
LogUtils.updateLog(logId, 0, e.getMessage());
Toast(handError, TAG, "发送失败:" + e.getMessage());
}
@ -172,9 +172,9 @@ public class SenderWebNotifyMsg extends SenderBaseMsg {
//返回http状态200即为成功
if (200 == response.code()) {
LogUtil.updateLog(logId, 2, responseStr);
LogUtils.updateLog(logId, 2, responseStr);
} else {
LogUtil.updateLog(logId, 0, responseStr);
LogUtils.updateLog(logId, 0, responseStr);
}
}
});

@ -13,7 +13,7 @@ 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.BatteryUtils;
import com.idormy.sms.forwarder.utils.SettingUtil;
import com.idormy.sms.forwarder.utils.SettingUtils;
import java.util.Date;
@ -70,26 +70,26 @@ public class BatteryService extends Service {
//电量发生变化
int levelCur = intent.getIntExtra("level", 0);
int levelPre = SettingUtil.getBatteryLevelCurrent();
int levelPre = SettingUtils.getBatteryLevelCurrent();
if (levelCur != levelPre) {
String msg = BatteryUtils.getBatteryInfo(intent);
SettingUtil.setBatteryLevelCurrent(levelCur);
SettingUtils.setBatteryLevelCurrent(levelCur);
int levelMin = SettingUtil.getBatteryLevelAlarmMin();
int levelMax = SettingUtil.getBatteryLevelAlarmMax();
if (SettingUtil.getBatteryLevelAlarmOnce() && levelMin > 0 && levelPre > levelCur && levelCur <= levelMin) { //电量下降到下限
int levelMin = SettingUtils.getBatteryLevelAlarmMin();
int levelMax = SettingUtils.getBatteryLevelAlarmMax();
if (SettingUtils.getBatteryLevelAlarmOnce() && levelMin > 0 && levelPre > levelCur && levelCur <= levelMin) { //电量下降到下限
msg = "【电量预警】已低于电量预警下限,请及时充电!" + msg;
sendMessage(context, msg);
return;
} else if (SettingUtil.getBatteryLevelAlarmOnce() && levelMax > 0 && levelPre < levelCur && levelCur >= levelMax) { //电量上升到上限
} else if (SettingUtils.getBatteryLevelAlarmOnce() && levelMax > 0 && levelPre < levelCur && levelCur >= levelMax) { //电量上升到上限
msg = "【电量预警】已高于电量预警上限,请拔掉充电器!" + msg;
sendMessage(context, msg);
return;
} else if (!SettingUtil.getBatteryLevelAlarmOnce() && levelMin > 0 && levelPre > levelCur && levelCur == levelMin) { //电量下降到下限
} else if (!SettingUtils.getBatteryLevelAlarmOnce() && levelMin > 0 && levelPre > levelCur && levelCur == levelMin) { //电量下降到下限
msg = "【电量预警】已到达电量预警下限,请及时充电!" + msg;
sendMessage(context, msg);
return;
} else if (!SettingUtil.getBatteryLevelAlarmOnce() && levelMax > 0 && levelPre < levelCur && levelCur == levelMax) { //电量上升到上限
} else if (!SettingUtils.getBatteryLevelAlarmOnce() && levelMax > 0 && levelPre < levelCur && levelCur == levelMax) { //电量上升到上限
msg = "【电量预警】已到达电量预警上限,请拔掉充电器!" + msg;
sendMessage(context, msg);
return;
@ -98,11 +98,11 @@ public class BatteryService extends Service {
//充电状态改变
int status = intent.getIntExtra("status", 0);
if (SettingUtil.getSwitchEnableBatteryReceiver()) {
int oldStatus = SettingUtil.getBatteryStatus();
if (SettingUtils.getSwitchEnableBatteryReceiver()) {
int oldStatus = SettingUtils.getBatteryStatus();
if (status != oldStatus) {
String msg = BatteryUtils.getBatteryInfo(intent);
SettingUtil.setBatteryStatus(status);
SettingUtils.setBatteryStatus(status);
msg = "【充电状态】发生变化:" + BatteryUtils.getStatus(oldStatus) + " → " + BatteryUtils.getStatus(status) + msg;
sendMessage(context, msg);
}

@ -6,31 +6,84 @@ import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.BitmapFactory;
import android.os.BatteryManager;
import android.os.Build;
import android.os.IBinder;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.lifecycle.Observer;
import com.idormy.sms.forwarder.MainActivity;
import com.idormy.sms.forwarder.MyApplication;
import com.idormy.sms.forwarder.R;
import com.idormy.sms.forwarder.database.AppDatabase;
import com.idormy.sms.forwarder.database.Config;
import com.idormy.sms.forwarder.utils.CommonUtil;
import com.idormy.sms.forwarder.utils.OSUtil;
import com.idormy.sms.forwarder.utils.Define;
import com.idormy.sms.forwarder.utils.OSUtils;
import com.idormy.sms.forwarder.utils.PhoneUtils;
import com.idormy.sms.forwarder.utils.SettingUtil;
import com.idormy.sms.forwarder.utils.SettingUtils;
import com.jeremyliao.liveeventbus.LiveEventBus;
import frpclib.Frpclib;
import io.reactivex.Single;
import io.reactivex.SingleObserver;
import io.reactivex.SingleSource;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;
public class FrontService extends Service {
private static final String TAG = "FrontService";
public static final int NOTIFY_ID = 0x1010;
private static final String CHANNEL_ONE_ID = "com.idormy.sms.forwarder";
private static final String CHANNEL_ONE_NAME = "com.idormy.sms.forwarderName";
private static final String ACTION_NOTIFICATION_LISTENER_SETTINGS = "android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS";
//Frc相关
public static final String INTENT_KEY_FILE = "INTENT_KEY_FILE";
private final CompositeDisposable compositeDisposable = new CompositeDisposable();
private final Observer<String> keyObserver = uid -> {
if (Frpclib.isRunning(uid)) {
return;
}
AppDatabase.getInstance(FrontService.this)
.configDao()
.getConfigByUid(uid)
.flatMap((Function<Config, SingleSource<String>>) config -> {
String error = Frpclib.runContent(config.getUid(), config.getCfg());
return Single.just(error);
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SingleObserver<>() {
public void onSubscribe(Disposable d) {
compositeDisposable.add(d);
}
@Override
public void onSuccess(String error) {
if (!TextUtils.isEmpty(error)) {
Toast.makeText(FrontService.this, error, Toast.LENGTH_SHORT).show();
LiveEventBus.get(Define.EVENT_RUNNING_ERROR, String.class).post(uid);
}
}
@Override
public void onError(Throwable e) {
}
});
};
@SuppressLint("IconColors")
@Override
public void onCreate() {
@ -40,50 +93,29 @@ public class FrontService extends Service {
//是否同意隐私协议
if (!MyApplication.allowPrivacyPolicy) return;
Notification.Builder builder = new Notification.Builder(this);
builder.setSmallIcon(R.drawable.ic_forwarder);
builder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher));
if (OSUtil.isMIUI()) {
builder.setContentTitle(getString(R.string.app_name));
}
builder.setContentText(getString(R.string.notification_content));
Intent intent = new Intent(this, MainActivity.class);
int flags = Build.VERSION.SDK_INT >= 30 ? PendingIntent.FLAG_IMMUTABLE : PendingIntent.FLAG_UPDATE_CURRENT;
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, flags);
builder.setContentIntent(pendingIntent);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
//修改安卓8.1以上系统报错
NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ONE_ID, CHANNEL_ONE_NAME, NotificationManager.IMPORTANCE_MIN);
notificationChannel.enableLights(false);//如果使用中的设备支持通知灯,则说明此通知通道是否应显示灯
notificationChannel.setShowBadge(false);//是否显示角标
notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
manager.createNotificationChannel(notificationChannel);
builder.setChannelId(CHANNEL_ONE_ID);
}
Notification notification = builder.build();
startForeground(1, notification);
//检查权限是否获取
//PackageManager pm = getPackageManager();
//PhoneUtils.CheckPermission(pm, this);
//开启通知栏
startForeground(NOTIFY_ID, createNotification());
//Android8.1以下尝试启动主界面,以便动态获取权限
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.O_MR1) {
Intent intent = new Intent(this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
// 手机重启未打开app时主动获取SIM卡信息
//手机重启未打开app时主动获取SIM卡信息
if (MyApplication.SimInfoList.isEmpty()) {
PhoneUtils.init(this);
MyApplication.SimInfoList = PhoneUtils.getSimMultiInfo();
}
if (SettingUtil.getSwitchEnableAppNotify() && CommonUtil.isNotificationListenerServiceEnabled(this)) {
//开关通知监听服务
if (SettingUtils.getSwitchEnableAppNotify() && CommonUtil.isNotificationListenerServiceEnabled(this)) {
CommonUtil.toggleNotificationListenerService(this);
}
//Frc内网穿透
LiveEventBus.get(INTENT_KEY_FILE, String.class).observeStickyForever(keyObserver);
}
@Override
@ -98,6 +130,8 @@ public class FrontService extends Service {
//重新开启服务
startService(intent);
stopForeground(true);
compositeDisposable.dispose();
}
@Override
@ -112,18 +146,32 @@ public class FrontService extends Service {
return null;
}
//获取当前电量
@SuppressLint("ObsoleteSdkInt")
private int getBatteryLevel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
BatteryManager batteryManager = (BatteryManager) getSystemService(BATTERY_SERVICE);
return batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
} else {
Intent intent = new ContextWrapper(getApplicationContext()).
registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
return (intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1) * 100) /
intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
//创建通知栏
private Notification createNotification() {
Notification.Builder builder = new Notification.Builder(this);
builder.setSmallIcon(R.drawable.ic_forwarder);
builder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher));
if (OSUtils.isMIUI()) {
builder.setContentTitle(getString(R.string.app_name));
}
builder.setContentText(getString(R.string.notification_content));
Intent intent = new Intent(this, MainActivity.class);
int flags = Build.VERSION.SDK_INT >= 30 ? PendingIntent.FLAG_IMMUTABLE : PendingIntent.FLAG_UPDATE_CURRENT;
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, flags);
builder.setContentIntent(pendingIntent);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
//修改安卓8.1以上系统报错
NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ONE_ID, CHANNEL_ONE_NAME, NotificationManager.IMPORTANCE_MIN);
notificationChannel.enableLights(false);//如果使用中的设备支持通知灯,则说明此通知通道是否应显示灯
notificationChannel.setShowBadge(false);//是否显示角标
notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
manager.createNotificationChannel(notificationChannel);
builder.setChannelId(CHANNEL_ONE_ID);
}
return builder.build();
}
}
}

@ -12,7 +12,7 @@ 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.CommonUtil;
import com.idormy.sms.forwarder.utils.SettingUtil;
import com.idormy.sms.forwarder.utils.SettingUtils;
import java.text.SimpleDateFormat;
import java.util.Date;
@ -35,13 +35,13 @@ public class NotifyService extends NotificationListenerService {
if (!MyApplication.allowPrivacyPolicy) return;
//未开启转发
if (!SettingUtil.getSwitchEnableAppNotify()) return;
if (!SettingUtils.getSwitchEnableAppNotify()) return;
//异常通知跳过
if (sbn.getNotification() == null) return;
if (sbn.getNotification().extras == null) return;
//仅锁屏状态转发APP通知
if (SettingUtil.getSwitchNotUserPresent() && MyApplication.isUserPresent) return;
if (SettingUtils.getSwitchNotUserPresent() && MyApplication.isUserPresent) return;
//推送通知的应用包名
String packageName = sbn.getPackageName();
@ -74,20 +74,20 @@ public class NotifyService extends NotificationListenerService {
);
//自动关闭通知
if (SettingUtil.getSwitchCancelAppNotify()) {
if (SettingUtils.getSwitchCancelAppNotify()) {
String key = sbn.getKey();
cancelNotification(key);
}
//重复通知不再处理
String prevHash = SettingUtil.getPrevNoticeHash(packageName);
String prevHash = SettingUtils.getPrevNoticeHash(packageName);
String currHash = CommonUtil.MD5(packageName + title + text + time);
Log.d(TAG, "prevHash=" + prevHash + " currHash=" + currHash);
if (prevHash != null && prevHash.equals(currHash)) {
Log.w(TAG, "重复通知不再处理");
return;
}
SettingUtil.setPrevNoticeHash(packageName, currHash);
SettingUtils.setPrevNoticeHash(packageName, currHash);
SmsVo smsVo = new SmsVo(packageName, text, new Date(), title);
Log.d(TAG, "send_msg" + smsVo);
@ -106,7 +106,7 @@ public class NotifyService extends NotificationListenerService {
@Override
public void onNotificationRemoved(StatusBarNotification sbn) {
//未开启转发
if (!SettingUtil.getSwitchEnableAppNotify()) return;
if (!SettingUtils.getSwitchEnableAppNotify()) return;
//异常通知跳过
if (sbn.getNotification() == null) return;
@ -119,7 +119,7 @@ public class NotifyService extends NotificationListenerService {
@Override
public void onListenerDisconnected() {
//未开启转发
if (!SettingUtil.getSwitchEnableAppNotify()) return;
if (!SettingUtils.getSwitchEnableAppNotify()) return;
Log.d(TAG, "通知侦听器断开连接 - 请求重新绑定");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {

@ -1,106 +1,106 @@
package com.idormy.sms.forwarder.utils;
import android.content.Context;
import android.os.Environment;
import java.io.File;
import java.math.BigDecimal;
public class CacheUtil {
/**
*
*
* @param context
* @return
*/
public static String getTotalCacheSize(Context context) {
long cacheSize = getFolderSize(context.getCacheDir());
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
cacheSize += getFolderSize(context.getExternalCacheDir());
}
return getFormatSize(cacheSize);
}
/***
*
* @param context
*/
public static void clearAllCache(Context context) {
deleteDir(context.getCacheDir());
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
deleteDir(context.getExternalCacheDir());
}
}
private static boolean deleteDir(File dir) {
if (dir != null && dir.isDirectory()) {
String[] children = dir.list();
assert children != null;
for (String child : children) {
boolean success = deleteDir(new File(dir, child));
if (!success) {
return false;
}
}
}
assert dir != null;
return dir.delete();
}
// 获取文件
//Context.getExternalFilesDir() --> SDCard/Android/data/你的应用的包名/files/ 目录,一般放一些长时间保存的数据
//Context.getExternalCacheDir() --> SDCard/Android/data/你的应用包名/cache/目录,一般存放临时缓存数据
public static long getFolderSize(File file) {
long size = 0;
try {
File[] fileList = file.listFiles();
assert fileList != null;
for (File value : fileList) {
// 如果下面还有文件
if (value.isDirectory()) {
size = size + getFolderSize(value);
} else {
size = size + value.length();
}
}
} catch (Exception e) {
e.printStackTrace();
}
return size;
}
/**
*
*
* @param size
* @return
*/
public static String getFormatSize(double size) {
double kiloByte = size / 1024;
if (kiloByte < 1) {
return "0KB";
}
double megaByte = kiloByte / 1024;
if (megaByte < 1) {
BigDecimal result1 = new BigDecimal(Double.toString(kiloByte));
return result1.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "KB";
}
double gigaByte = megaByte / 1024;
if (gigaByte < 1) {
BigDecimal result2 = new BigDecimal(Double.toString(megaByte));
return result2.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "MB";
}
double teraBytes = gigaByte / 1024;
if (teraBytes < 1) {
BigDecimal result3 = new BigDecimal(Double.toString(gigaByte));
return result3.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "GB";
}
BigDecimal result4 = new BigDecimal(teraBytes);
return result4.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "TB";
}
package com.idormy.sms.forwarder.utils;
import android.content.Context;
import android.os.Environment;
import java.io.File;
import java.math.BigDecimal;
public class CacheUtils {
/**
*
*
* @param context
* @return
*/
public static String getTotalCacheSize(Context context) {
long cacheSize = getFolderSize(context.getCacheDir());
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
cacheSize += getFolderSize(context.getExternalCacheDir());
}
return getFormatSize(cacheSize);
}
/***
*
* @param context
*/
public static void clearAllCache(Context context) {
deleteDir(context.getCacheDir());
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
deleteDir(context.getExternalCacheDir());
}
}
private static boolean deleteDir(File dir) {
if (dir != null && dir.isDirectory()) {
String[] children = dir.list();
assert children != null;
for (String child : children) {
boolean success = deleteDir(new File(dir, child));
if (!success) {
return false;
}
}
}
assert dir != null;
return dir.delete();
}
// 获取文件
//Context.getExternalFilesDir() --> SDCard/Android/data/你的应用的包名/files/ 目录,一般放一些长时间保存的数据
//Context.getExternalCacheDir() --> SDCard/Android/data/你的应用包名/cache/目录,一般存放临时缓存数据
public static long getFolderSize(File file) {
long size = 0;
try {
File[] fileList = file.listFiles();
assert fileList != null;
for (File value : fileList) {
// 如果下面还有文件
if (value.isDirectory()) {
size = size + getFolderSize(value);
} else {
size = size + value.length();
}
}
} catch (Exception e) {
e.printStackTrace();
}
return size;
}
/**
*
*
* @param size
* @return
*/
public static String getFormatSize(double size) {
double kiloByte = size / 1024;
if (kiloByte < 1) {
return "0KB";
}
double megaByte = kiloByte / 1024;
if (megaByte < 1) {
BigDecimal result1 = new BigDecimal(Double.toString(kiloByte));
return result1.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "KB";
}
double gigaByte = megaByte / 1024;
if (gigaByte < 1) {
BigDecimal result2 = new BigDecimal(Double.toString(megaByte));
return result2.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "MB";
}
double teraBytes = gigaByte / 1024;
if (teraBytes < 1) {
BigDecimal result3 = new BigDecimal(Double.toString(gigaByte));
return result3.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "GB";
}
BigDecimal result4 = new BigDecimal(teraBytes);
return result4.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "TB";
}
}

@ -17,24 +17,24 @@ public class CloneUtils {
public static String exportSettings() {
CloneInfoVo cloneInfo = new CloneInfoVo();
try {
cloneInfo.setVersionCode(SettingUtil.getVersionCode());
cloneInfo.setVersionName(SettingUtil.getVersionName());
cloneInfo.setEnableSms(SettingUtil.getSwitchEnableSms());
cloneInfo.setEnablePhone(SettingUtil.getSwitchEnablePhone());
cloneInfo.setCallType1(SettingUtil.getSwitchCallType1());
cloneInfo.setCallType2(SettingUtil.getSwitchCallType2());
cloneInfo.setCallType3(SettingUtil.getSwitchCallType3());
cloneInfo.setEnableAppNotify(SettingUtil.getSwitchEnableAppNotify());
cloneInfo.setCancelAppNotify(SettingUtil.getSwitchCancelAppNotify());
cloneInfo.setBatteryLevelAlarmMin(SettingUtil.getBatteryLevelAlarmMin());
cloneInfo.setBatteryLevelAlarmMax(SettingUtil.getBatteryLevelAlarmMax());
cloneInfo.setBatteryLevelAlarmOnce(SettingUtil.getBatteryLevelAlarmOnce());
cloneInfo.setRetryTimes(SettingUtil.getRetryTimes());
cloneInfo.setDelayTime(SettingUtil.getDelayTime());
cloneInfo.setEnableSmsTemplate(SettingUtil.getSwitchSmsTemplate());
cloneInfo.setSmsTemplate(SettingUtil.getSmsTemplate());
cloneInfo.setVersionCode(SettingUtils.getVersionCode());
cloneInfo.setVersionName(SettingUtils.getVersionName());
cloneInfo.setEnableSms(SettingUtils.getSwitchEnableSms());
cloneInfo.setEnablePhone(SettingUtils.getSwitchEnablePhone());
cloneInfo.setCallType1(SettingUtils.getSwitchCallType1());
cloneInfo.setCallType2(SettingUtils.getSwitchCallType2());
cloneInfo.setCallType3(SettingUtils.getSwitchCallType3());
cloneInfo.setEnableAppNotify(SettingUtils.getSwitchEnableAppNotify());
cloneInfo.setCancelAppNotify(SettingUtils.getSwitchCancelAppNotify());
cloneInfo.setBatteryLevelAlarmMin(SettingUtils.getBatteryLevelAlarmMin());
cloneInfo.setBatteryLevelAlarmMax(SettingUtils.getBatteryLevelAlarmMax());
cloneInfo.setBatteryLevelAlarmOnce(SettingUtils.getBatteryLevelAlarmOnce());
cloneInfo.setRetryTimes(SettingUtils.getRetryTimes());
cloneInfo.setDelayTime(SettingUtils.getDelayTime());
cloneInfo.setEnableSmsTemplate(SettingUtils.getSwitchSmsTemplate());
cloneInfo.setSmsTemplate(SettingUtils.getSmsTemplate());
cloneInfo.setSenderList(SenderUtil.getSender(null, null));
cloneInfo.setRuleList(RuleUtil.getRule(null, null));
cloneInfo.setRuleList(RuleUtils.getRule(null, null));
} catch (Exception e) {
e.printStackTrace();
}
@ -47,21 +47,21 @@ public class CloneUtils {
try {
//应用配置
//SettingUtil.init(context);
SettingUtil.switchEnableSms(cloneInfoVo.isEnableSms());
SettingUtil.switchEnablePhone(cloneInfoVo.isEnablePhone());
SettingUtil.switchCallType1(cloneInfoVo.isCallType1());
SettingUtil.switchCallType2(cloneInfoVo.isCallType2());
SettingUtil.switchCallType3(cloneInfoVo.isCallType3());
SettingUtil.switchEnableAppNotify(cloneInfoVo.isEnableAppNotify());
SettingUtil.switchCancelAppNotify(cloneInfoVo.isCancelAppNotify());
SettingUtil.setBatteryLevelAlarmMin(cloneInfoVo.getBatteryLevelAlarmMin());
SettingUtil.setBatteryLevelAlarmMax(cloneInfoVo.getBatteryLevelAlarmMax());
SettingUtil.switchBatteryLevelAlarmOnce(cloneInfoVo.isBatteryLevelAlarmOnce());
SettingUtil.setRetryTimes(cloneInfoVo.getRetryTimes());
SettingUtil.setDelayTime(cloneInfoVo.getDelayTime());
SettingUtil.switchSmsTemplate(cloneInfoVo.isEnableSmsTemplate());
SettingUtil.setSmsTemplate(cloneInfoVo.getSmsTemplate());
//SettingUtils.init(context);
SettingUtils.switchEnableSms(cloneInfoVo.isEnableSms());
SettingUtils.switchEnablePhone(cloneInfoVo.isEnablePhone());
SettingUtils.switchCallType1(cloneInfoVo.isCallType1());
SettingUtils.switchCallType2(cloneInfoVo.isCallType2());
SettingUtils.switchCallType3(cloneInfoVo.isCallType3());
SettingUtils.switchEnableAppNotify(cloneInfoVo.isEnableAppNotify());
SettingUtils.switchCancelAppNotify(cloneInfoVo.isCancelAppNotify());
SettingUtils.setBatteryLevelAlarmMin(cloneInfoVo.getBatteryLevelAlarmMin());
SettingUtils.setBatteryLevelAlarmMax(cloneInfoVo.getBatteryLevelAlarmMax());
SettingUtils.switchBatteryLevelAlarmOnce(cloneInfoVo.isBatteryLevelAlarmOnce());
SettingUtils.setRetryTimes(cloneInfoVo.getRetryTimes());
SettingUtils.setDelayTime(cloneInfoVo.getDelayTime());
SettingUtils.switchSmsTemplate(cloneInfoVo.isEnableSmsTemplate());
SettingUtils.setSmsTemplate(cloneInfoVo.getSmsTemplate());
SenderUtil.delSender(null);
List<SenderModel> senderList = cloneInfoVo.getSenderList();
@ -69,13 +69,13 @@ public class CloneUtils {
SenderUtil.addSender(senderModel);
}
RuleUtil.delRule(null);
RuleUtils.delRule(null);
List<RuleModel> ruleList = cloneInfoVo.getRuleList();
for (RuleModel ruleModel : ruleList) {
RuleUtil.addRule(ruleModel);
RuleUtils.addRule(ruleModel);
}
LogUtil.delLog(null, null);
LogUtils.delLog(null, null);
return true;
} catch (Exception e) {

@ -1,185 +1,186 @@
package com.idormy.sms.forwarder;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Looper;
import android.util.Log;
import androidx.annotation.NonNull;
import com.hjq.toast.ToastUtils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.Thread.UncaughtExceptionHandler;
import java.lang.reflect.Field;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
* UncaughtException,Uncaught,,
*/
public class CrashHandler implements UncaughtExceptionHandler {
private static final String TAG = "CrashHandler";
//系统默认的UncaughtException处理类
private Thread.UncaughtExceptionHandler mDefaultHandler;
//CrashHandler实例
@SuppressLint("StaticFieldLeak")
private static final CrashHandler INSTANCE = new CrashHandler();
//程序的Context对象
private Context mContext;
//用来存储设备信息和异常信息
private final Map<String, String> infos = new HashMap<>();
//用于格式化日期,作为日志文件名的一部分
@SuppressLint("SimpleDateFormat")
private final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
/**
* CrashHandler
*/
private CrashHandler() {
}
/**
* CrashHandler ,
*/
public static CrashHandler getInstance() {
return INSTANCE;
}
/**
*
*/
public void init(Context context) {
mContext = context;
//获取系统默认的UncaughtException处理器
mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
//设置该CrashHandler为程序的默认处理器
Thread.setDefaultUncaughtExceptionHandler(this);
}
/**
* UncaughtException
*/
@Override
public void uncaughtException(@NonNull Thread thread, @NonNull Throwable ex) {
if (!handleException(ex) && mDefaultHandler != null) {
//如果用户没有处理则让系统默认的异常处理器来处理
mDefaultHandler.uncaughtException(thread, ex);
} else {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
Log.e(TAG, "error : ", e);
} //退出程序
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(1);
}
}
/**
* ,
*
* @return true:;false.
*/
private boolean handleException(Throwable ex) {
if (ex == null) {
return false;
} //使用Toast来显示异常信息
new Thread() {
@Override
public void run() {
Looper.prepare();
ToastUtils.delayedShow(R.string.crash_tip, 3000);
Looper.loop();
}
}.start();
//收集设备参数信息
collectDeviceInfo(mContext);
//保存日志文件
saveCrashInfo2File(ex);
return true;
}
/**
*
*/
public void collectDeviceInfo(Context ctx) {
try {
PackageManager pm = ctx.getPackageManager();
PackageInfo pi = pm.getPackageInfo(ctx.getPackageName(), PackageManager.GET_ACTIVITIES);
if (pi != null) {
String versionName = pi.versionName == null ? "null" : pi.versionName;
String versionCode = pi.versionCode + "";
infos.put("versionName", versionName);
infos.put("versionCode", versionCode);
}
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "an error occured when collect package info", e);
}
Field[] fields = Build.class.getDeclaredFields();
for (Field field : fields) {
try {
field.setAccessible(true);
infos.put(field.getName(), Objects.requireNonNull(field.get(null)).toString());
Log.d(TAG, field.getName() + " : " + field.get(null));
} catch (Exception e) {
Log.e(TAG, "an error occured when collect crash info", e);
}
}
}
/**
*
*/
@SuppressWarnings({"ResultOfMethodCallIgnored", "UnusedReturnValue"})
private String saveCrashInfo2File(Throwable ex) {
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, String> entry : infos.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
sb.append(key).append("=").append(value).append("\n");
}
Writer writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
Throwable cause = ex.getCause();
while (cause != null) {
cause.printStackTrace(printWriter);
cause = cause.getCause();
}
printWriter.close();
String result = writer.toString();
sb.append(result);
try {
long timestamp = System.currentTimeMillis();
String time = formatter.format(new Date());
String fileName = "crash-" + time + "-" + timestamp + ".log";
String path = mContext.getCacheDir().getPath() + File.separator + "crash" + File.separator;
Log.e(TAG, path);
File dir = new File(path);
if (!dir.exists()) {
dir.mkdirs();
}
FileOutputStream fos = new FileOutputStream(path + fileName);
fos.write(sb.toString().getBytes());
fos.close();
return fileName;
} catch (Exception e) {
Log.e(TAG, "an error occured while writing file...", e);
}
return null;
}
package com.idormy.sms.forwarder.utils;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Looper;
import android.util.Log;
import androidx.annotation.NonNull;
import com.hjq.toast.ToastUtils;
import com.idormy.sms.forwarder.R;
import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.Thread.UncaughtExceptionHandler;
import java.lang.reflect.Field;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
* UncaughtException,Uncaught,,
*/
public class CrashHandler implements UncaughtExceptionHandler {
private static final String TAG = "CrashHandler";
//系统默认的UncaughtException处理类
private Thread.UncaughtExceptionHandler mDefaultHandler;
//CrashHandler实例
@SuppressLint("StaticFieldLeak")
private static final CrashHandler INSTANCE = new CrashHandler();
//程序的Context对象
private Context mContext;
//用来存储设备信息和异常信息
private final Map<String, String> infos = new HashMap<>();
//用于格式化日期,作为日志文件名的一部分
@SuppressLint("SimpleDateFormat")
private final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
/**
* CrashHandler
*/
private CrashHandler() {
}
/**
* CrashHandler ,
*/
public static CrashHandler getInstance() {
return INSTANCE;
}
/**
*
*/
public void init(Context context) {
mContext = context;
//获取系统默认的UncaughtException处理器
mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
//设置该CrashHandler为程序的默认处理器
Thread.setDefaultUncaughtExceptionHandler(this);
}
/**
* UncaughtException
*/
@Override
public void uncaughtException(@NonNull Thread thread, @NonNull Throwable ex) {
if (!handleException(ex) && mDefaultHandler != null) {
//如果用户没有处理则让系统默认的异常处理器来处理
mDefaultHandler.uncaughtException(thread, ex);
} else {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
Log.e(TAG, "error : ", e);
} //退出程序
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(1);
}
}
/**
* ,
*
* @return true:;false.
*/
private boolean handleException(Throwable ex) {
if (ex == null) {
return false;
} //使用Toast来显示异常信息
new Thread() {
@Override
public void run() {
Looper.prepare();
ToastUtils.delayedShow(R.string.crash_tip, 3000);
Looper.loop();
}
}.start();
//收集设备参数信息
collectDeviceInfo(mContext);
//保存日志文件
saveCrashInfo2File(ex);
return true;
}
/**
*
*/
public void collectDeviceInfo(Context ctx) {
try {
PackageManager pm = ctx.getPackageManager();
PackageInfo pi = pm.getPackageInfo(ctx.getPackageName(), PackageManager.GET_ACTIVITIES);
if (pi != null) {
String versionName = pi.versionName == null ? "null" : pi.versionName;
String versionCode = pi.versionCode + "";
infos.put("versionName", versionName);
infos.put("versionCode", versionCode);
}
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "an error occured when collect package info", e);
}
Field[] fields = Build.class.getDeclaredFields();
for (Field field : fields) {
try {
field.setAccessible(true);
infos.put(field.getName(), Objects.requireNonNull(field.get(null)).toString());
Log.d(TAG, field.getName() + " : " + field.get(null));
} catch (Exception e) {
Log.e(TAG, "an error occured when collect crash info", e);
}
}
}
/**
*
*/
@SuppressWarnings({"ResultOfMethodCallIgnored", "UnusedReturnValue"})
private String saveCrashInfo2File(Throwable ex) {
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, String> entry : infos.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
sb.append(key).append("=").append(value).append("\n");
}
Writer writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
Throwable cause = ex.getCause();
while (cause != null) {
cause.printStackTrace(printWriter);
cause = cause.getCause();
}
printWriter.close();
String result = writer.toString();
sb.append(result);
try {
long timestamp = System.currentTimeMillis();
String time = formatter.format(new Date());
String fileName = "crash-" + time + "-" + timestamp + ".log";
String path = mContext.getCacheDir().getPath() + File.separator + "crash" + File.separator;
Log.e(TAG, path);
File dir = new File(path);
if (!dir.exists()) {
dir.mkdirs();
}
FileOutputStream fos = new FileOutputStream(path + fileName);
fos.write(sb.toString().getBytes());
fos.close();
return fileName;
} catch (Exception e) {
Log.e(TAG, "an error occured while writing file...", e);
}
return null;
}
}

@ -42,4 +42,8 @@ public class Define {
public static final int REQUEST_TIMEOUT_SECONDS = 5;
//HttpServer 服务端口
public static final int HTTP_SERVER_PORT = 5000;
//FRPC相关
public static final String EVENT_UPDATE_CONFIG = "EVENT_UPDATE_CONFIG";
public static final String EVENT_RUNNING_ERROR = "EVENT_RUNNING_ERROR";
}

@ -26,10 +26,10 @@ import okhttp3.RequestBody;
import okhttp3.Response;
@SuppressWarnings("unchecked")
public class HttpUtil {
public class HttpUtils {
private static OkHttpClient client;
private static OkHttpClient retryClient;
private static final String TAG = "HttpUtil";
private static final String TAG = "HttpUtils";
private static Boolean hasInit = false;
@SuppressLint("StaticFieldLeak")
private static Context context;
@ -42,7 +42,7 @@ public class HttpUtil {
if (hasInit) return;
hasInit = true;
HttpUtil.context = context;
HttpUtils.context = context;
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
//设置读取超时时间
clientBuilder
@ -51,8 +51,8 @@ public class HttpUtil {
.connectTimeout(Define.REQUEST_TIMEOUT_SECONDS, TimeUnit.SECONDS);
client = clientBuilder.build();
//设置重试拦截器
int retryTimes = SettingUtil.getRetryTimes();
int delayTime = SettingUtil.getDelayTime();
int retryTimes = SettingUtils.getRetryTimes();
int delayTime = SettingUtils.getDelayTime();
if (retryTimes > 0)
clientBuilder.addInterceptor(new RetryIntercepter.Builder().executionCount(retryTimes).retryInterval(delayTime).build());
retryClient = clientBuilder.build();

@ -5,9 +5,9 @@ import android.content.Context;
import android.util.Log;
@SuppressWarnings("SynchronizeOnNonFinalField")
public class InitUtil {
public class InitUtils {
static Boolean hasInit = false;
private static final String TAG = "InitUtil";
private static final String TAG = "InitUtils";
@SuppressLint("StaticFieldLeak")
private static Context context = null;
@ -19,7 +19,7 @@ public class InitUtil {
hasInit = true;
context = context1;
Log.d(TAG, "init context");
SettingUtil.init(context);
SettingUtils.init(context);
}
}

@ -24,8 +24,8 @@ import java.util.List;
import java.util.Locale;
@SuppressWarnings("UnusedReturnValue")
public class LogUtil {
static final String TAG = "LogUtil";
public class LogUtils {
static final String TAG = "LogUtils";
static Boolean hasInit = false;
@SuppressLint("StaticFieldLeak")

@ -1,72 +1,72 @@
package com.idormy.sms.forwarder.utils;
import android.annotation.SuppressLint;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import com.hjq.toast.ToastUtils;
import com.idormy.sms.forwarder.R;
public class NetUtil {
//没有网络
public static final int NETWORK_NONE = 0;
//移动网络
public static final int NETWORK_MOBILE = 1;
//无线网络
public static final int NETWORK_WIFI = 2;
static Boolean hasInit = false;
@SuppressLint("StaticFieldLeak")
static Context context;
public static void init(Context context1) {
//noinspection SynchronizeOnNonFinalField
synchronized (hasInit) {
if (hasInit) return;
hasInit = true;
context = context1;
}
}
//获取网络启动
public static int getNetWorkStatus() {
//连接服务 CONNECTIVITY_SERVICE
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
//网络信息 NetworkInfo
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
if (activeNetworkInfo != null && activeNetworkInfo.isConnected()) {
//判断是否是wifi
if (activeNetworkInfo.getType() == (ConnectivityManager.TYPE_WIFI)) {
//返回无线网络
ToastUtils.show(R.string.on_wireless_network);
return NETWORK_WIFI;
//判断是否移动网络
} else if (activeNetworkInfo.getType() == (ConnectivityManager.TYPE_MOBILE)) {
ToastUtils.show(R.string.on_mobile_network);
//返回移动网络
return NETWORK_MOBILE;
}
} else {
//没有网络
ToastUtils.show(R.string.no_network);
return NETWORK_NONE;
}
//默认返回 没有网络
return NETWORK_NONE;
}
public static String getLocalIp(Context context) {
if (NETWORK_WIFI != getNetWorkStatus()) return context.getString(R.string.not_connected_wifi);
WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
int ipAddress = wifiInfo.getIpAddress();
if (ipAddress == 0) return context.getString(R.string.failed_to_get_ip);
return ((ipAddress & 0xff) + "." + (ipAddress >> 8 & 0xff) + "."
+ (ipAddress >> 16 & 0xff) + "." + (ipAddress >> 24 & 0xff));
}
}
package com.idormy.sms.forwarder.utils;
import android.annotation.SuppressLint;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import com.hjq.toast.ToastUtils;
import com.idormy.sms.forwarder.R;
public class NetUtils {
//没有网络
public static final int NETWORK_NONE = 0;
//移动网络
public static final int NETWORK_MOBILE = 1;
//无线网络
public static final int NETWORK_WIFI = 2;
static Boolean hasInit = false;
@SuppressLint("StaticFieldLeak")
static Context context;
public static void init(Context context1) {
//noinspection SynchronizeOnNonFinalField
synchronized (hasInit) {
if (hasInit) return;
hasInit = true;
context = context1;
}
}
//获取网络启动
public static int getNetWorkStatus() {
//连接服务 CONNECTIVITY_SERVICE
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
//网络信息 NetworkInfo
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
if (activeNetworkInfo != null && activeNetworkInfo.isConnected()) {
//判断是否是wifi
if (activeNetworkInfo.getType() == (ConnectivityManager.TYPE_WIFI)) {
//返回无线网络
ToastUtils.show(R.string.on_wireless_network);
return NETWORK_WIFI;
//判断是否移动网络
} else if (activeNetworkInfo.getType() == (ConnectivityManager.TYPE_MOBILE)) {
ToastUtils.show(R.string.on_mobile_network);
//返回移动网络
return NETWORK_MOBILE;
}
} else {
//没有网络
ToastUtils.show(R.string.no_network);
return NETWORK_NONE;
}
//默认返回 没有网络
return NETWORK_NONE;
}
public static String getLocalIp(Context context) {
if (NETWORK_WIFI != getNetWorkStatus()) return context.getString(R.string.not_connected_wifi);
WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
int ipAddress = wifiInfo.getIpAddress();
if (ipAddress == 0) return context.getString(R.string.failed_to_get_ip);
return ((ipAddress & 0xff) + "." + (ipAddress >> 8 & 0xff) + "."
+ (ipAddress >> 16 & 0xff) + "." + (ipAddress >> 24 & 0xff));
}
}

@ -1,132 +1,132 @@
package com.idormy.sms.forwarder.utils;
import android.os.Environment;
import android.text.TextUtils;
import com.alibaba.fastjson.util.IOUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
/**
* 使:
* OSUtil.ROM_TYPE romType = OSUtil.getRomType();
* ROM
* 使BuildPropertieskey,value(getProperty),build.prop
* ROMkey/value
* ROM_TYPEgetRomType
* YouAreMyShine
* https://www.jianshu.com/p/bb1f765a425f
*/
public class OSUtil {
/**
* MIUIhttp://blog.csdn.net/xx326664162/article/details/52438706
*
* @return
*/
@SuppressWarnings("unused")
public static boolean isMIUI() {
File file = new File(Environment.getRootDirectory(), "build.prop");
FileInputStream fis = null;
try {
fis = new FileInputStream(file);
String KEY_MIUI_VERSION_CODE = "ro.miui.ui.version.code";
String KEY_MIUI_VERSION_NAME = "ro.miui.ui.version.name";
String KEY_MIUI_INTERNAL_STORAGE = "ro.miui.internal.storage";
Properties prop = new Properties();
prop.load(fis);
return prop.getProperty(KEY_MIUI_VERSION_CODE, null) != null
|| prop.getProperty(KEY_MIUI_VERSION_NAME, null) != null
|| prop.getProperty(KEY_MIUI_INTERNAL_STORAGE, null) != null;
} catch (final IOException e) {
return false;
} finally {
IOUtils.close(fis);
}
}
/**
* MIUI ROM
* <p>
* "ro.miui.ui.version.code" -> "5"
* <p>
* "ro.miui.ui.version.name" -> "V7"
* <p>
* "ro.miui.has_handy_mode_sf" -> "1"
* <p>
* "ro.miui.has_real_blur" -> "1"
* <p>
* <p>
* <p>
* Flyme ROM
* <p>
* "ro.build.user" -> "flyme"
* <p>
* "persist.sys.use.flyme.icon" -> "true"
* <p>
* "ro.flyme.published" -> "true"
* <p>
* "ro.build.display.id" -> "Flyme OS 5.1.2.0U"
* <p>
* "ro.meizu.setupwizard.flyme" -> "true"
* <p>
* <p>
* <p>
* EMUI ROM
* <p>
* "ro.build.version.emui" -> "EmotionUI_1.6"
*/
//MIUI标识
private static final String KEY_MIUI_VERSION_CODE = "ro.miui.ui.version.code";
private static final String KEY_MIUI_VERSION_NAME = "ro.miui.ui.version.name";
//EMUI标识
private static final String KEY_EMUI_VERSION_CODE = "ro.build.version.emui";
//Flyme标识
private static final String KEY_FLYME_ID_FLAG_KEY = "ro.build.display.id";
private static final String KEY_FLYME_ID_FLAG_VALUE_KEYWORD = "Flyme";
private static final String KEY_FLYME_ICON_FLAG = "persist.sys.use.flyme.icon";
private static final String KEY_FLYME_SETUP_FLAG = "ro.meizu.setupwizard.flyme";
private static final String KEY_FLYME_PUBLISH_FLAG = "ro.flyme.published";
/**
* ROMMIUI_ROM, *FLYME_ROM, * EMUI_ROM, * OTHER_ROM
*
* @return ROM_TYPE ROM
*/
public static ROM_TYPE getRomType() {
ROM_TYPE rom_type = ROM_TYPE.OTHER_ROM;
try {
BuildProperties buildProperties = BuildProperties.getInstance();
if (buildProperties.containsKey(KEY_EMUI_VERSION_CODE)) {
return ROM_TYPE.EMUI_ROM;
}
if (buildProperties.containsKey(KEY_MIUI_VERSION_CODE) || buildProperties.containsKey(KEY_MIUI_VERSION_NAME)) {
return ROM_TYPE.MIUI_ROM;
}
if (buildProperties.containsKey(KEY_FLYME_ICON_FLAG) || buildProperties.containsKey(KEY_FLYME_SETUP_FLAG) || buildProperties.containsKey(KEY_FLYME_PUBLISH_FLAG)) {
return ROM_TYPE.FLYME_ROM;
}
if (buildProperties.containsKey(KEY_FLYME_ID_FLAG_KEY)) {
String romName = buildProperties.getProperty(KEY_FLYME_ID_FLAG_KEY);
if (!TextUtils.isEmpty(romName) && romName.contains(KEY_FLYME_ID_FLAG_VALUE_KEYWORD)) {
return ROM_TYPE.FLYME_ROM;
}
}
} catch (IOException e) {
e.printStackTrace();
}
return rom_type;
}
public enum ROM_TYPE {
MIUI_ROM,
FLYME_ROM,
EMUI_ROM,
OTHER_ROM
}
}
package com.idormy.sms.forwarder.utils;
import android.os.Environment;
import android.text.TextUtils;
import com.alibaba.fastjson.util.IOUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
/**
* 使:
* OSUtils.ROM_TYPE romType = OSUtils.getRomType();
* ROM
* 使BuildPropertieskey,value(getProperty),build.prop
* ROMkey/value
* ROM_TYPEgetRomType
* YouAreMyShine
* https://www.jianshu.com/p/bb1f765a425f
*/
public class OSUtils {
/**
* MIUIhttp://blog.csdn.net/xx326664162/article/details/52438706
*
* @return
*/
@SuppressWarnings("unused")
public static boolean isMIUI() {
File file = new File(Environment.getRootDirectory(), "build.prop");
FileInputStream fis = null;
try {
fis = new FileInputStream(file);
String KEY_MIUI_VERSION_CODE = "ro.miui.ui.version.code";
String KEY_MIUI_VERSION_NAME = "ro.miui.ui.version.name";
String KEY_MIUI_INTERNAL_STORAGE = "ro.miui.internal.storage";
Properties prop = new Properties();
prop.load(fis);
return prop.getProperty(KEY_MIUI_VERSION_CODE, null) != null
|| prop.getProperty(KEY_MIUI_VERSION_NAME, null) != null
|| prop.getProperty(KEY_MIUI_INTERNAL_STORAGE, null) != null;
} catch (final IOException e) {
return false;
} finally {
IOUtils.close(fis);
}
}
/**
* MIUI ROM
* <p>
* "ro.miui.ui.version.code" -> "5"
* <p>
* "ro.miui.ui.version.name" -> "V7"
* <p>
* "ro.miui.has_handy_mode_sf" -> "1"
* <p>
* "ro.miui.has_real_blur" -> "1"
* <p>
* <p>
* <p>
* Flyme ROM
* <p>
* "ro.build.user" -> "flyme"
* <p>
* "persist.sys.use.flyme.icon" -> "true"
* <p>
* "ro.flyme.published" -> "true"
* <p>
* "ro.build.display.id" -> "Flyme OS 5.1.2.0U"
* <p>
* "ro.meizu.setupwizard.flyme" -> "true"
* <p>
* <p>
* <p>
* EMUI ROM
* <p>
* "ro.build.version.emui" -> "EmotionUI_1.6"
*/
//MIUI标识
private static final String KEY_MIUI_VERSION_CODE = "ro.miui.ui.version.code";
private static final String KEY_MIUI_VERSION_NAME = "ro.miui.ui.version.name";
//EMUI标识
private static final String KEY_EMUI_VERSION_CODE = "ro.build.version.emui";
//Flyme标识
private static final String KEY_FLYME_ID_FLAG_KEY = "ro.build.display.id";
private static final String KEY_FLYME_ID_FLAG_VALUE_KEYWORD = "Flyme";
private static final String KEY_FLYME_ICON_FLAG = "persist.sys.use.flyme.icon";
private static final String KEY_FLYME_SETUP_FLAG = "ro.meizu.setupwizard.flyme";
private static final String KEY_FLYME_PUBLISH_FLAG = "ro.flyme.published";
/**
* ROMMIUI_ROM, *FLYME_ROM, * EMUI_ROM, * OTHER_ROM
*
* @return ROM_TYPE ROM
*/
public static ROM_TYPE getRomType() {
ROM_TYPE rom_type = ROM_TYPE.OTHER_ROM;
try {
BuildProperties buildProperties = BuildProperties.getInstance();
if (buildProperties.containsKey(KEY_EMUI_VERSION_CODE)) {
return ROM_TYPE.EMUI_ROM;
}
if (buildProperties.containsKey(KEY_MIUI_VERSION_CODE) || buildProperties.containsKey(KEY_MIUI_VERSION_NAME)) {
return ROM_TYPE.MIUI_ROM;
}
if (buildProperties.containsKey(KEY_FLYME_ICON_FLAG) || buildProperties.containsKey(KEY_FLYME_SETUP_FLAG) || buildProperties.containsKey(KEY_FLYME_PUBLISH_FLAG)) {
return ROM_TYPE.FLYME_ROM;
}
if (buildProperties.containsKey(KEY_FLYME_ID_FLAG_KEY)) {
String romName = buildProperties.getProperty(KEY_FLYME_ID_FLAG_KEY);
if (!TextUtils.isEmpty(romName) && romName.contains(KEY_FLYME_ID_FLAG_VALUE_KEYWORD)) {
return ROM_TYPE.FLYME_ROM;
}
}
} catch (IOException e) {
e.printStackTrace();
}
return rom_type;
}
public enum ROM_TYPE {
MIUI_ROM,
FLYME_ROM,
EMUI_ROM,
OTHER_ROM
}
}

@ -15,8 +15,8 @@ import java.util.ArrayList;
import java.util.List;
@SuppressWarnings({"UnusedReturnValue", "SynchronizeOnNonFinalField"})
public class RuleUtil {
static final String TAG = "RuleUtil";
public class RuleUtils {
static final String TAG = "RuleUtils";
static Boolean hasInit = false;
@SuppressLint("StaticFieldLeak")
static Context context;

@ -1,332 +1,332 @@
package com.idormy.sms.forwarder.utils;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.preference.PreferenceManager;
import android.util.Log;
import com.idormy.sms.forwarder.MyApplication;
import com.idormy.sms.forwarder.R;
@SuppressWarnings({"SynchronizeOnNonFinalField", "unused"})
public class SettingUtil {
static Boolean hasInit = false;
private static final String TAG = "SettingUtil";
private static SharedPreferences sp_setting = null;
@SuppressLint("StaticFieldLeak")
private static Context context = null;
public static void init(Context context1) {
synchronized (hasInit) {
if (hasInit) return;
hasInit = true;
context = context1;
Log.d(TAG, "SettingUtil init ");
sp_setting = PreferenceManager.getDefaultSharedPreferences(context1);
}
}
public static void switchAddExtra(Boolean switchAddExtra) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_SWITCH_ADD_EXTRA, switchAddExtra).apply();
}
public static boolean getSwitchAddExtra() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_SWITCH_ADD_EXTRA, false);
}
public static void switchAddDeviceName(Boolean switchAddDeviceName) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_NAME, switchAddDeviceName).apply();
}
public static boolean getSwitchAddDeviceName() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_NAME, false);
}
public static void switchEnableSms(Boolean enable) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_SMS, enable).apply();
}
public static boolean getSwitchEnableSms() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_SMS, false);
}
public static void switchEnablePhone(Boolean enable) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_PHONE, enable).apply();
}
public static boolean getSwitchEnablePhone() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_PHONE, false);
}
public static void switchEnableAppNotify(Boolean enable) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_APP_NOTIFY, enable).apply();
}
public static boolean getSwitchEnableAppNotify() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_APP_NOTIFY, false);
}
public static void switchCancelAppNotify(Boolean enable) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_CANCEL_APP_NOTIFY, enable).apply();
}
public static boolean getSwitchCancelAppNotify() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_CANCEL_APP_NOTIFY, false);
}
public static void switchNotUserPresent(Boolean enable) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_NOT_USER_PRESENT, enable).apply();
}
public static boolean getSwitchNotUserPresent() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_NOT_USER_PRESENT, false);
}
public static void switchEnableBatteryReceiver(Boolean enable) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_BATTERY_RECEIVER, enable).apply();
}
public static boolean getSwitchEnableBatteryReceiver() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_BATTERY_RECEIVER, false);
}
public static void switchExcludeFromRecents(Boolean enable) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_EXCLUDE_FROM_RECENTS, enable).apply();
}
public static boolean getExcludeFromRecents() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_EXCLUDE_FROM_RECENTS, false);
}
public static void switchPlaySilenceMusic(Boolean enable) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_PLAY_SILENCE_MUSIC, enable).apply();
}
public static boolean getPlaySilenceMusic() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_PLAY_SILENCE_MUSIC, false);
}
public static void switchOnePixelActivity(Boolean enable) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_ONE_PIXEL_ACTIVITY, enable).apply();
}
public static boolean getOnePixelActivity() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_ONE_PIXEL_ACTIVITY, false);
}
public static void switchSmsTemplate(Boolean 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() {
String res = sp_setting.getString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_MARK, "");
if (res == null || res.equals("")) {
res = android.os.Build.MODEL;
}
return res;
}
public static void setAddExtraDeviceMark(String addExtraDeviceMark) {
sp_setting.edit().putString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_MARK, addExtraDeviceMark).apply();
}
public static String getSmsTemplate() {
return sp_setting.getString(Define.SP_MSG_KEY_STRING_SMS_TEMPLATE,
getString(R.string.tag_from) + "\n" +
getString(R.string.tag_sms) + "\n" +
getString(R.string.tag_card_slot) + "\n" +
getString(R.string.tag_receive_time) + "\n" +
getString(R.string.tag_device_name));
}
public static void setSmsTemplate(String textSmsTemplate) {
sp_setting.edit().putString(Define.SP_MSG_KEY_STRING_SMS_TEMPLATE, textSmsTemplate).apply();
}
public static String getAddExtraSim1() {
String res = sp_setting.getString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM1, "");
if (res == null || res.equals("")) {
res = SimUtil.getSimInfo(1);
}
return res;
}
public static void setAddExtraSim1(String sim1) {
sp_setting.edit().putString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM1, sim1).apply();
}
public static String getAddExtraSim2() {
String res = sp_setting.getString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM2, "");
if (res == null || res.equals("")) {
res = SimUtil.getSimInfo(2);
}
return res;
}
public static void setAddExtraSim2(String sim2) {
sp_setting.edit().putString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM2, sim2).apply();
}
public static int getBatteryLevelAlarmMin() {
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM, 0);
}
public static void setBatteryLevelAlarmMin(int battery_level) {
sp_setting.edit().putInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM, battery_level).apply();
}
public static int getBatteryLevelAlarmMax() {
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_MAX, 0);
}
public static void switchBatteryLevelAlarmOnce(Boolean enable) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_ONCE, enable).apply();
}
public static boolean getBatteryLevelAlarmOnce() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_ONCE, false);
}
public static void setBatteryLevelAlarmMax(int battery_level) {
sp_setting.edit().putInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_MAX, battery_level).apply();
}
public static int getBatteryLevelCurrent() {
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_CURRENT, 0);
}
public static void setBatteryLevelCurrent(int battery_level) {
sp_setting.edit().putInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_CURRENT, battery_level).apply();
}
public static int getBatteryStatus() {
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_BATTERY_STATUS, 0);
}
public static void setBatteryStatus(int battery_status) {
sp_setting.edit().putInt(Define.SP_MSG_KEY_STRING_BATTERY_STATUS, battery_status).apply();
}
public static boolean saveMsgHistory() {
return !sp_setting.getBoolean("option_save_history_on", false);
}
public static String getPrevNoticeHash(String key) {
return sp_setting.getString(key, "");
}
public static void setPrevNoticeHash(String key, String value) {
sp_setting.edit().putString(key, value).apply();
}
public static void switchEnableHttpServer(Boolean enable) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_HTTP_SERVER, enable).apply();
}
public static boolean getSwitchEnableHttpServer() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_HTTP_SERVER, false);
}
public static void switchCallType1(Boolean switchCallType) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_CALL_TYPE_1, switchCallType).apply();
}
public static boolean getSwitchCallType1() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_CALL_TYPE_1, false);
}
public static void switchCallType2(Boolean switchCallType) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_CALL_TYPE_2, switchCallType).apply();
}
public static boolean getSwitchCallType2() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_CALL_TYPE_2, false);
}
public static void switchCallType3(Boolean switchCallType) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_CALL_TYPE_3, switchCallType).apply();
}
public static boolean getSwitchCallType3() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_CALL_TYPE_3, true);
}
public static int getRetryTimes() {
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_RETRY_TIMES, 0);
}
public static void setRetryTimes(int retry_times) {
sp_setting.edit().putInt(Define.SP_MSG_KEY_STRING_RETRY_TIMES, retry_times).apply();
}
public static int getDelayTime() {
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_DELAY_TIME, 1);
}
public static void setDelayTime(int delay_time) {
sp_setting.edit().putInt(Define.SP_MSG_KEY_STRING_DELAY_TIME, delay_time).apply();
}
public static void switchEnableBatteryCron(Boolean enable) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_BATTERY_CRON, enable).apply();
}
public static boolean getSwitchEnableBatteryCron() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_BATTERY_CRON, false);
}
public static void setBatteryCronStartTime(String startTime) {
sp_setting.edit().putString(Define.SP_MSG_KEY_STRING_BATTERY_CRON_START_TIME, startTime).apply();
}
public static String getBatteryCronStartTime() {
return sp_setting.getString(Define.SP_MSG_KEY_STRING_BATTERY_CRON_START_TIME, "00:00");
}
public static void setBatteryCronInterval(int interval) {
sp_setting.edit().putInt(Define.SP_MSG_KEY_STRING_BATTERY_CRON_INTERVAL, interval).apply();
}
public static int getBatteryCronInterval() {
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_BATTERY_CRON_INTERVAL, 60);
}
//获取当前版本名称
public static String getVersionName() {
// 获取PackageManager的实例
PackageManager packageManager = context.getPackageManager();
// getPackageName()是你当前类的包名0代表是获取版本信息
PackageInfo packInfo;
try {
packInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
return packInfo.versionName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
return "";
}
}
//获取应用的版本号
public static int getVersionCode() {
PackageManager manager = context.getPackageManager();
int code = 0;
try {
PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0);
code = info.versionCode;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return code;
}
private static String getString(int resId) {
return MyApplication.getContext().getString(resId);
}
}
package com.idormy.sms.forwarder.utils;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.preference.PreferenceManager;
import android.util.Log;
import com.idormy.sms.forwarder.MyApplication;
import com.idormy.sms.forwarder.R;
@SuppressWarnings({"SynchronizeOnNonFinalField", "unused"})
public class SettingUtils {
static Boolean hasInit = false;
private static final String TAG = "SettingUtils";
private static SharedPreferences sp_setting = null;
@SuppressLint("StaticFieldLeak")
private static Context context = null;
public static void init(Context context1) {
synchronized (hasInit) {
if (hasInit) return;
hasInit = true;
context = context1;
Log.d(TAG, "SettingUtils init ");
sp_setting = PreferenceManager.getDefaultSharedPreferences(context1);
}
}
public static void switchAddExtra(Boolean switchAddExtra) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_SWITCH_ADD_EXTRA, switchAddExtra).apply();
}
public static boolean getSwitchAddExtra() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_SWITCH_ADD_EXTRA, false);
}
public static void switchAddDeviceName(Boolean switchAddDeviceName) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_NAME, switchAddDeviceName).apply();
}
public static boolean getSwitchAddDeviceName() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_NAME, false);
}
public static void switchEnableSms(Boolean enable) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_SMS, enable).apply();
}
public static boolean getSwitchEnableSms() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_SMS, false);
}
public static void switchEnablePhone(Boolean enable) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_PHONE, enable).apply();
}
public static boolean getSwitchEnablePhone() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_PHONE, false);
}
public static void switchEnableAppNotify(Boolean enable) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_APP_NOTIFY, enable).apply();
}
public static boolean getSwitchEnableAppNotify() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_APP_NOTIFY, false);
}
public static void switchCancelAppNotify(Boolean enable) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_CANCEL_APP_NOTIFY, enable).apply();
}
public static boolean getSwitchCancelAppNotify() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_CANCEL_APP_NOTIFY, false);
}
public static void switchNotUserPresent(Boolean enable) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_NOT_USER_PRESENT, enable).apply();
}
public static boolean getSwitchNotUserPresent() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_NOT_USER_PRESENT, false);
}
public static void switchEnableBatteryReceiver(Boolean enable) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_BATTERY_RECEIVER, enable).apply();
}
public static boolean getSwitchEnableBatteryReceiver() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_BATTERY_RECEIVER, false);
}
public static void switchExcludeFromRecents(Boolean enable) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_EXCLUDE_FROM_RECENTS, enable).apply();
}
public static boolean getExcludeFromRecents() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_EXCLUDE_FROM_RECENTS, false);
}
public static void switchPlaySilenceMusic(Boolean enable) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_PLAY_SILENCE_MUSIC, enable).apply();
}
public static boolean getPlaySilenceMusic() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_PLAY_SILENCE_MUSIC, false);
}
public static void switchOnePixelActivity(Boolean enable) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_ONE_PIXEL_ACTIVITY, enable).apply();
}
public static boolean getOnePixelActivity() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_ONE_PIXEL_ACTIVITY, false);
}
public static void switchSmsTemplate(Boolean 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() {
String res = sp_setting.getString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_MARK, "");
if (res == null || res.equals("")) {
res = android.os.Build.MODEL;
}
return res;
}
public static void setAddExtraDeviceMark(String addExtraDeviceMark) {
sp_setting.edit().putString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_MARK, addExtraDeviceMark).apply();
}
public static String getSmsTemplate() {
return sp_setting.getString(Define.SP_MSG_KEY_STRING_SMS_TEMPLATE,
getString(R.string.tag_from) + "\n" +
getString(R.string.tag_sms) + "\n" +
getString(R.string.tag_card_slot) + "\n" +
getString(R.string.tag_receive_time) + "\n" +
getString(R.string.tag_device_name));
}
public static void setSmsTemplate(String textSmsTemplate) {
sp_setting.edit().putString(Define.SP_MSG_KEY_STRING_SMS_TEMPLATE, textSmsTemplate).apply();
}
public static String getAddExtraSim1() {
String res = sp_setting.getString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM1, "");
if (res == null || res.equals("")) {
res = SimUtils.getSimInfo(1);
}
return res;
}
public static void setAddExtraSim1(String sim1) {
sp_setting.edit().putString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM1, sim1).apply();
}
public static String getAddExtraSim2() {
String res = sp_setting.getString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM2, "");
if (res == null || res.equals("")) {
res = SimUtils.getSimInfo(2);
}
return res;
}
public static void setAddExtraSim2(String sim2) {
sp_setting.edit().putString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM2, sim2).apply();
}
public static int getBatteryLevelAlarmMin() {
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM, 0);
}
public static void setBatteryLevelAlarmMin(int battery_level) {
sp_setting.edit().putInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM, battery_level).apply();
}
public static int getBatteryLevelAlarmMax() {
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_MAX, 0);
}
public static void switchBatteryLevelAlarmOnce(Boolean enable) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_ONCE, enable).apply();
}
public static boolean getBatteryLevelAlarmOnce() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_ONCE, false);
}
public static void setBatteryLevelAlarmMax(int battery_level) {
sp_setting.edit().putInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_MAX, battery_level).apply();
}
public static int getBatteryLevelCurrent() {
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_CURRENT, 0);
}
public static void setBatteryLevelCurrent(int battery_level) {
sp_setting.edit().putInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_CURRENT, battery_level).apply();
}
public static int getBatteryStatus() {
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_BATTERY_STATUS, 0);
}
public static void setBatteryStatus(int battery_status) {
sp_setting.edit().putInt(Define.SP_MSG_KEY_STRING_BATTERY_STATUS, battery_status).apply();
}
public static boolean saveMsgHistory() {
return !sp_setting.getBoolean("option_save_history_on", false);
}
public static String getPrevNoticeHash(String key) {
return sp_setting.getString(key, "");
}
public static void setPrevNoticeHash(String key, String value) {
sp_setting.edit().putString(key, value).apply();
}
public static void switchEnableHttpServer(Boolean enable) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_HTTP_SERVER, enable).apply();
}
public static boolean getSwitchEnableHttpServer() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_HTTP_SERVER, false);
}
public static void switchCallType1(Boolean switchCallType) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_CALL_TYPE_1, switchCallType).apply();
}
public static boolean getSwitchCallType1() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_CALL_TYPE_1, false);
}
public static void switchCallType2(Boolean switchCallType) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_CALL_TYPE_2, switchCallType).apply();
}
public static boolean getSwitchCallType2() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_CALL_TYPE_2, false);
}
public static void switchCallType3(Boolean switchCallType) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_CALL_TYPE_3, switchCallType).apply();
}
public static boolean getSwitchCallType3() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_CALL_TYPE_3, true);
}
public static int getRetryTimes() {
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_RETRY_TIMES, 0);
}
public static void setRetryTimes(int retry_times) {
sp_setting.edit().putInt(Define.SP_MSG_KEY_STRING_RETRY_TIMES, retry_times).apply();
}
public static int getDelayTime() {
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_DELAY_TIME, 1);
}
public static void setDelayTime(int delay_time) {
sp_setting.edit().putInt(Define.SP_MSG_KEY_STRING_DELAY_TIME, delay_time).apply();
}
public static void switchEnableBatteryCron(Boolean enable) {
sp_setting.edit().putBoolean(Define.SP_MSG_KEY_STRING_BATTERY_CRON, enable).apply();
}
public static boolean getSwitchEnableBatteryCron() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_BATTERY_CRON, false);
}
public static void setBatteryCronStartTime(String startTime) {
sp_setting.edit().putString(Define.SP_MSG_KEY_STRING_BATTERY_CRON_START_TIME, startTime).apply();
}
public static String getBatteryCronStartTime() {
return sp_setting.getString(Define.SP_MSG_KEY_STRING_BATTERY_CRON_START_TIME, "00:00");
}
public static void setBatteryCronInterval(int interval) {
sp_setting.edit().putInt(Define.SP_MSG_KEY_STRING_BATTERY_CRON_INTERVAL, interval).apply();
}
public static int getBatteryCronInterval() {
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_BATTERY_CRON_INTERVAL, 60);
}
//获取当前版本名称
public static String getVersionName() {
// 获取PackageManager的实例
PackageManager packageManager = context.getPackageManager();
// getPackageName()是你当前类的包名0代表是获取版本信息
PackageInfo packInfo;
try {
packInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
return packInfo.versionName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
return "";
}
}
//获取应用的版本号
public static int getVersionCode() {
PackageManager manager = context.getPackageManager();
int code = 0;
try {
PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0);
code = info.versionCode;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return code;
}
private static String getString(int resId) {
return MyApplication.getContext().getString(resId);
}
}

@ -1,91 +1,91 @@
package com.idormy.sms.forwarder.utils;
import android.os.Bundle;
import android.util.Log;
import com.idormy.sms.forwarder.MyApplication;
@SuppressWarnings("unused")
public class SimUtil {
private static final String TAG = "SimUtil";
//获取卡槽信息ID
public static int getSimId(Bundle bundle) {
int whichSIM = -1;
if (bundle == null) {
return whichSIM;
}
if (bundle.containsKey("simId")) {
whichSIM = bundle.getInt("simId");
Log.d(TAG, "simId = " + whichSIM);
} else if (bundle.containsKey("com.android.phone.extra.slot")) {
whichSIM = bundle.getInt("com.android.phone.extra.slot");
Log.d(TAG, "com.android.phone.extra.slot = " + whichSIM);
} else {
String keyName = "";
for (String key : bundle.keySet()) {
if (key.contains("sim"))
keyName = key;
}
if (bundle.containsKey(keyName)) {
whichSIM = bundle.getInt(keyName);
}
}
Log.d(TAG, "Slot Number " + whichSIM);
return whichSIM + 1;
}
//通过SubscriptionId获取卡槽信息ID
public static int getSimIdBySubscriptionId(int subscriptionId) {
try {
Log.d(TAG, MyApplication.SimInfoList.toString());
for (PhoneUtils.SimInfo simInfo : MyApplication.SimInfoList) {
Log.d(TAG, simInfo.toString());
if (simInfo.mSubscriptionId == subscriptionId) {
return simInfo.mSimSlotIndex + 1;
}
}
} catch (Exception e) {
Log.d(TAG, "getSimExtra Fail: " + e.getMessage());
}
return 1;
}
//通过卡槽ID获取SubscriptionId
public static int getSubscriptionIdBySimId(int simId) {
try {
for (PhoneUtils.SimInfo simInfo : MyApplication.SimInfoList) {
Log.d(TAG, "mSimSlotIndex = " + simInfo.mSimSlotIndex);
if (simInfo.mSimSlotIndex != -1 && simInfo.mSimSlotIndex == simId) {
return simInfo.mSubscriptionId;
}
}
} catch (Exception e) {
Log.d(TAG, "getSimExtra Fail: " + e.getMessage());
}
return 0;
}
//获取卡槽备注
public static String getSimInfo(int simId) {
String res = "";
try {
for (PhoneUtils.SimInfo simInfo : MyApplication.SimInfoList) {
Log.d(TAG, String.valueOf(simInfo));
if (simInfo.mSimSlotIndex != -1 && simInfo.mSimSlotIndex + 1 == simId) {
res = simInfo.mCarrierName + "_" + simInfo.mNumber;
break;
}
}
} catch (Exception e) {
Log.d(TAG, "getSimExtra Fail: " + e.getMessage());
}
return res.replace("null", "unknown");
}
}
package com.idormy.sms.forwarder.utils;
import android.os.Bundle;
import android.util.Log;
import com.idormy.sms.forwarder.MyApplication;
@SuppressWarnings("unused")
public class SimUtils {
private static final String TAG = "SimUtils";
//获取卡槽信息ID
public static int getSimId(Bundle bundle) {
int whichSIM = -1;
if (bundle == null) {
return whichSIM;
}
if (bundle.containsKey("simId")) {
whichSIM = bundle.getInt("simId");
Log.d(TAG, "simId = " + whichSIM);
} else if (bundle.containsKey("com.android.phone.extra.slot")) {
whichSIM = bundle.getInt("com.android.phone.extra.slot");
Log.d(TAG, "com.android.phone.extra.slot = " + whichSIM);
} else {
String keyName = "";
for (String key : bundle.keySet()) {
if (key.contains("sim"))
keyName = key;
}
if (bundle.containsKey(keyName)) {
whichSIM = bundle.getInt(keyName);
}
}
Log.d(TAG, "Slot Number " + whichSIM);
return whichSIM + 1;
}
//通过SubscriptionId获取卡槽信息ID
public static int getSimIdBySubscriptionId(int subscriptionId) {
try {
Log.d(TAG, MyApplication.SimInfoList.toString());
for (PhoneUtils.SimInfo simInfo : MyApplication.SimInfoList) {
Log.d(TAG, simInfo.toString());
if (simInfo.mSubscriptionId == subscriptionId) {
return simInfo.mSimSlotIndex + 1;
}
}
} catch (Exception e) {
Log.d(TAG, "getSimExtra Fail: " + e.getMessage());
}
return 1;
}
//通过卡槽ID获取SubscriptionId
public static int getSubscriptionIdBySimId(int simId) {
try {
for (PhoneUtils.SimInfo simInfo : MyApplication.SimInfoList) {
Log.d(TAG, "mSimSlotIndex = " + simInfo.mSimSlotIndex);
if (simInfo.mSimSlotIndex != -1 && simInfo.mSimSlotIndex == simId) {
return simInfo.mSubscriptionId;
}
}
} catch (Exception e) {
Log.d(TAG, "getSimExtra Fail: " + e.getMessage());
}
return 0;
}
//获取卡槽备注
public static String getSimInfo(int simId) {
String res = "";
try {
for (PhoneUtils.SimInfo simInfo : MyApplication.SimInfoList) {
Log.d(TAG, String.valueOf(simInfo));
if (simInfo.mSimSlotIndex != -1 && simInfo.mSimSlotIndex + 1 == simId) {
res = simInfo.mCarrierName + "_" + simInfo.mNumber;
break;
}
}
} catch (Exception e) {
Log.d(TAG, "getSimExtra Fail: " + e.getMessage());
}
return res.replace("null", "unknown");
}
}

@ -14,8 +14,8 @@ import java.util.ArrayList;
import java.util.Objects;
@SuppressWarnings("SynchronizeOnNonFinalField")
public class SmsUtil {
static final String TAG = "SmsUtil";
public class SmsUtils {
static final String TAG = "SmsUtils";
static Boolean hasInit = false;
@SuppressLint("StaticFieldLeak")
static Context context;

@ -8,7 +8,7 @@ import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
public class TimeUtil {
public class TimeUtils {
//友好时间显示
public static String friendlyTime(String utcTime) {

@ -1,4 +1,4 @@
package com.idormy.sms.forwarder;
package com.idormy.sms.forwarder.utils;
import android.content.Context;

@ -1,4 +1,4 @@
package com.idormy.sms.forwarder;
package com.idormy.sms.forwarder.view;
import android.annotation.SuppressLint;
import android.content.Context;
@ -15,6 +15,8 @@ import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.idormy.sms.forwarder.R;
import java.text.SimpleDateFormat;
import java.util.Locale;

@ -18,9 +18,9 @@ import com.idormy.sms.forwarder.RuleActivity;
import com.idormy.sms.forwarder.SenderActivity;
import com.idormy.sms.forwarder.SettingActivity;
import com.idormy.sms.forwarder.sender.SenderUtil;
import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.RuleUtil;
import com.idormy.sms.forwarder.utils.SettingUtil;
import com.idormy.sms.forwarder.utils.LogUtils;
import com.idormy.sms.forwarder.utils.RuleUtils;
import com.idormy.sms.forwarder.utils.SettingUtils;
@SuppressWarnings("FieldCanBeLocal")
public class StepBar extends LinearLayout {
@ -165,15 +165,15 @@ public class StepBar extends LinearLayout {
@SuppressLint("UseCompatLoadingForDrawables")
public void setHighlight() {
SettingUtil.init(mContext);
SettingUtils.init(mContext);
SenderUtil.init(mContext);
RuleUtil.init(mContext);
LogUtil.init(mContext);
RuleUtils.init(mContext);
LogUtils.init(mContext);
boolean Step1 = SettingUtil.getSwitchEnableSms() || SettingUtil.getSwitchEnablePhone() || SettingUtil.getSwitchEnableAppNotify();
boolean Step1 = SettingUtils.getSwitchEnableSms() || SettingUtils.getSwitchEnablePhone() || SettingUtils.getSwitchEnableAppNotify();
boolean Step2 = SenderUtil.countSender("1", null) > 0;
boolean Step3 = RuleUtil.countRule("1", null, null) > 0;
boolean Step4 = LogUtil.countLog("2", null, null) > 0;
boolean Step3 = RuleUtils.countRule("1", null, null) > 0;
boolean Step4 = LogUtils.countLog("2", null, null) > 0;
//页面提示文本
if (txHelpTip != null) {

@ -76,7 +76,7 @@
</LinearLayout>
<com.idormy.sms.forwarder.RefreshListView
<com.idormy.sms.forwarder.view.RefreshListView
android:id="@+id/list_view_log"
android:layout_width="match_parent"
android:layout_height="match_parent"

@ -1,3 +1,3 @@
#Fri Jul 16 10:33:23 CST 2021
versionName=2.4.4
versionCode=37
versionName=2.5.0
versionCode=38

Loading…
Cancel
Save