整理:文件命名统一规范

新增:引入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/getActivity/XXPermissions (权限请求框架)
+ https://github.com/Xcreen/RestSMS 被动接收本地API方案 + https://github.com/Xcreen/RestSMS 被动接收本地API方案
+ ~~https://github.com/juancrescente/SMSHub 主动轮询远程API方案v2.5.0+删除)~~ + ~~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) + [<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/getActivity/XXPermissions (permission requiring)
+ https://github.com/Xcreen/RestSMS被动接收本地API方案 + https://github.com/Xcreen/RestSMS被动接收本地API方案
+ ~~https://github.com/juancrescente/SMSHub主动轮询远程API方案v2.5.0+删除)~~ + ~~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) + [<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 { lint {
checkReleaseBuilds false checkReleaseBuilds false
} }
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
} }
@ -150,7 +157,7 @@ dependencies {
implementation 'com.squareup.okio:okio:3.0.0' implementation 'com.squareup.okio:okio:3.0.0'
//fastjson //fastjson
implementation "com.alibaba:fastjson:1.2.79" implementation "com.alibaba:fastjson:1.2.80"
//XUpdate //XUpdate
implementation 'com.github.xuexiangjys:XUpdate:2.1.1' implementation 'com.github.xuexiangjys:XUpdate:2.1.1'
@ -179,11 +186,25 @@ dependencies {
implementation 'com.github.getActivity:XXPermissions:13.2' implementation 'com.github.getActivity:XXPermissions:13.2'
//jetty //jetty
implementation "org.eclipse.jetty:jetty-server:9.2.30.v20200428" def jetty_version = '9.2.30.v20200428'
implementation "org.eclipse.jetty:jetty-servlet: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 //SDK
implementation 'com.umeng.umsdk:common:9.4.7'// () implementation 'com.umeng.umsdk:common:9.4.7'// ()
implementation 'com.umeng.umsdk:asms:1.6.0'// 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.permissions.XXPermissions;
import com.hjq.toast.ToastUtils; import com.hjq.toast.ToastUtils;
import com.idormy.sms.forwarder.receiver.RebootBroadcastReceiver; 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.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.easy.EasyUpdate;
import com.xuexiang.xupdate.proxy.impl.DefaultUpdateChecker; import com.xuexiang.xupdate.proxy.impl.DefaultUpdateChecker;
@ -46,7 +46,7 @@ public class AboutActivity extends BaseActivity {
} else { } else {
ToastUtils.show(R.string.toast_granted_part); ToastUtils.show(R.string.toast_granted_part);
} }
SettingUtil.switchEnableSms(true); SettingUtils.switchEnableSms(true);
} }
@Override @Override
@ -58,7 +58,7 @@ public class AboutActivity extends BaseActivity {
} else { } else {
ToastUtils.show(R.string.toast_denied); 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); final TextView cache_size = findViewById(R.id.cache_size);
try { try {
cache_size.setText(CacheUtil.getTotalCacheSize(AboutActivity.this)); cache_size.setText(CacheUtils.getTotalCacheSize(AboutActivity.this));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
Button clear_all_cache = findViewById(R.id.clear_all_cache); Button clear_all_cache = findViewById(R.id.clear_all_cache);
clear_all_cache.setOnClickListener(v -> { clear_all_cache.setOnClickListener(v -> {
CacheUtil.clearAllCache(AboutActivity.this); CacheUtils.clearAllCache(AboutActivity.this);
try { try {
cache_size.setText(CacheUtil.getTotalCacheSize(AboutActivity.this)); cache_size.setText(CacheUtils.getTotalCacheSize(AboutActivity.this));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

@ -12,8 +12,6 @@ import java.lang.reflect.Method;
public class BaseActivity extends AppCompatActivity { public class BaseActivity extends AppCompatActivity {
private final String TAG = "BaseActivity";
//启用menu //启用menu
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
@ -37,8 +35,6 @@ public class BaseActivity extends AppCompatActivity {
intent = new Intent(this, AboutActivity.class); intent = new Intent(this, AboutActivity.class);
break; break;
case R.id.to_help: 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); intent = new Intent(this, HelpActivity.class);
break; break;
default: default:
@ -52,6 +48,7 @@ public class BaseActivity extends AppCompatActivity {
//设置menu图标显示 //设置menu图标显示
@Override @Override
public boolean onMenuOpened(int featureId, Menu menu) { public boolean onMenuOpened(int featureId, Menu menu) {
String TAG = "BaseActivity";
Log.d(TAG, "onMenuOpened, featureId=" + featureId); Log.d(TAG, "onMenuOpened, featureId=" + featureId);
if (menu != null) { if (menu != null) {
if (menu.getClass().getSimpleName().equals("MenuBuilder")) { 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.CloneUtils;
import com.idormy.sms.forwarder.utils.Define; import com.idormy.sms.forwarder.utils.Define;
import com.idormy.sms.forwarder.utils.FileUtils; import com.idormy.sms.forwarder.utils.FileUtils;
import com.idormy.sms.forwarder.utils.HttpUtil; import com.idormy.sms.forwarder.utils.HttpUtils;
import com.idormy.sms.forwarder.utils.NetUtil; import com.idormy.sms.forwarder.utils.NetUtils;
import com.idormy.sms.forwarder.utils.SettingUtil; import com.idormy.sms.forwarder.utils.SettingUtils;
import com.idormy.sms.forwarder.view.IPEditText; import com.idormy.sms.forwarder.view.IPEditText;
import java.io.File; import java.io.File;
@ -67,7 +67,7 @@ public class CloneActivity extends BaseActivity {
setContentView(R.layout.activity_clone); setContentView(R.layout.activity_clone);
Log.d(TAG, "onCreate: " + RebootBroadcastReceiver.class.getName()); Log.d(TAG, "onCreate: " + RebootBroadcastReceiver.class.getName());
HttpUtil.init(this); HttpUtils.init(this);
HttpServer.init(this); HttpServer.init(this);
} }
@ -120,7 +120,7 @@ public class CloneActivity extends BaseActivity {
receiveTxt = findViewById(R.id.receiveTxt); receiveTxt = findViewById(R.id.receiveTxt);
Button receiveBtn = findViewById(R.id.receiveBtn); Button receiveBtn = findViewById(R.id.receiveBtn);
serverIp = NetUtil.getLocalIp(CloneActivity.this); serverIp = NetUtils.getLocalIp(CloneActivity.this);
ipText.setText(serverIp); ipText.setText(serverIp);
if (HttpServer.asRunning()) { if (HttpServer.asRunning()) {
@ -134,14 +134,14 @@ public class CloneActivity extends BaseActivity {
//发送 //发送
sendBtn.setOnClickListener(v -> { 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)); ToastUtils.show(getString(R.string.no_wifi_network));
return; return;
} }
SettingUtil.switchEnableHttpServer(!SettingUtil.getSwitchEnableHttpServer()); SettingUtils.switchEnableHttpServer(!SettingUtils.getSwitchEnableHttpServer());
if (!HttpServer.update()) { if (!HttpServer.update()) {
SettingUtil.switchEnableHttpServer(!SettingUtil.getSwitchEnableHttpServer()); SettingUtils.switchEnableHttpServer(!SettingUtils.getSwitchEnableHttpServer());
return; return;
} }
if (!HttpServer.asRunning()) { if (!HttpServer.asRunning()) {
@ -163,7 +163,7 @@ public class CloneActivity extends BaseActivity {
return; return;
} }
if (NetUtil.NETWORK_WIFI != NetUtil.getNetWorkStatus()) { if (NetUtils.NETWORK_WIFI != NetUtils.getNetWorkStatus()) {
receiveTxt.setText(R.string.no_wifi_network); receiveTxt.setText(R.string.no_wifi_network);
ToastUtils.show(getString(R.string.no_wifi_network)); ToastUtils.show(getString(R.string.no_wifi_network));
return; return;
@ -185,8 +185,8 @@ public class CloneActivity extends BaseActivity {
.build(); .build();
Map msgMap = new HashMap(); Map msgMap = new HashMap();
msgMap.put("versionCode", SettingUtil.getVersionCode()); msgMap.put("versionCode", SettingUtils.getVersionCode());
msgMap.put("versionName", SettingUtil.getVersionName()); msgMap.put("versionName", SettingUtils.getVersionName());
String requestMsg = JSON.toJSONString(msgMap); String requestMsg = JSON.toJSONString(msgMap);
Log.i(TAG, "requestMsg:" + requestMsg); Log.i(TAG, "requestMsg:" + requestMsg);
@ -222,7 +222,7 @@ public class CloneActivity extends BaseActivity {
CloneInfoVo cloneInfoVo = JSON.parseObject(responseStr, CloneInfoVo.class); CloneInfoVo cloneInfoVo = JSON.parseObject(responseStr, CloneInfoVo.class);
Log.d(TAG, cloneInfoVo.toString()); 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)); ToastUtils.show(getString(R.string.tips_versions_inconsistent));
return; return;
} }
@ -268,7 +268,7 @@ public class CloneActivity extends BaseActivity {
CloneInfoVo cloneInfoVo = JSON.parseObject(responseStr, CloneInfoVo.class); CloneInfoVo cloneInfoVo = JSON.parseObject(responseStr, CloneInfoVo.class);
Log.d(TAG, Objects.requireNonNull(cloneInfoVo).toString()); 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)); ToastUtils.show(getString(R.string.tips_versions_inconsistent));
return; return;
} }
@ -292,7 +292,7 @@ public class CloneActivity extends BaseActivity {
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
serverIp = NetUtil.getLocalIp(CloneActivity.this); serverIp = NetUtils.getLocalIp(CloneActivity.this);
TextView ipText = findViewById(R.id.ipText); TextView ipText = findViewById(R.id.ipText);
ipText.setText(getString(R.string.local_ip) + serverIp); 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.FrontService;
import com.idormy.sms.forwarder.service.MusicService; import com.idormy.sms.forwarder.service.MusicService;
import com.idormy.sms.forwarder.utils.CommonUtil; 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.KeepAliveUtils;
import com.idormy.sms.forwarder.utils.LogUtil; import com.idormy.sms.forwarder.utils.LogUtils;
import com.idormy.sms.forwarder.utils.NetUtil; import com.idormy.sms.forwarder.utils.NetUtils;
import com.idormy.sms.forwarder.utils.OnePixelManager; import com.idormy.sms.forwarder.utils.OnePixelManager;
import com.idormy.sms.forwarder.utils.PhoneUtils; import com.idormy.sms.forwarder.utils.PhoneUtils;
import com.idormy.sms.forwarder.utils.RuleUtil; import com.idormy.sms.forwarder.utils.RuleUtils;
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.SharedPreferencesHelper;
import com.idormy.sms.forwarder.utils.SmsUtil; import com.idormy.sms.forwarder.utils.SmsUtils;
import com.idormy.sms.forwarder.utils.TimeUtil; 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.idormy.sms.forwarder.view.StepBar;
import com.umeng.commonsdk.UMConfigure; import com.umeng.commonsdk.UMConfigure;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@SuppressWarnings("CommentedOutCode")
public class MainActivity extends BaseActivity implements RefreshListView.IRefreshListener { public class MainActivity extends BaseActivity implements RefreshListView.IRefreshListener {
private final String TAG = "MainActivity"; private final String TAG = "MainActivity";
@ -77,11 +78,11 @@ public class MainActivity extends BaseActivity implements RefreshListView.IRefre
if (!MyApplication.allowPrivacyPolicy) return; if (!MyApplication.allowPrivacyPolicy) return;
//短信&网络组件初始化 //短信&网络组件初始化
SmsUtil.init(this); SmsUtils.init(this);
NetUtil.init(this); NetUtils.init(this);
LogUtil.init(this); LogUtils.init(this);
RuleUtil.init(this); RuleUtils.init(this);
SenderUtil.init(this); SenderUtil.init(this);
//前台服务 //前台服务
@ -103,7 +104,7 @@ public class MainActivity extends BaseActivity implements RefreshListView.IRefre
} }
//后台播放无声音乐 //后台播放无声音乐
if (SettingUtil.getPlaySilenceMusic()) { if (SettingUtils.getPlaySilenceMusic()) {
try { try {
Intent musicServiceIntent = new Intent(this, MusicService.class); Intent musicServiceIntent = new Intent(this, MusicService.class);
musicServiceIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); musicServiceIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@ -114,7 +115,7 @@ public class MainActivity extends BaseActivity implements RefreshListView.IRefre
} }
//1像素透明Activity保活 or 仅锁屏状态转发APP通知 //1像素透明Activity保活 or 仅锁屏状态转发APP通知
if (SettingUtil.getOnePixelActivity() || SettingUtil.getSwitchNotUserPresent()) { if (SettingUtils.getOnePixelActivity() || SettingUtils.getSwitchNotUserPresent()) {
try { try {
onePixelManager = new OnePixelManager(); onePixelManager = new OnePixelManager();
onePixelManager.registerOnePixelReceiver(this);//注册广播接收者 onePixelManager.registerOnePixelReceiver(this);//注册广播接收者
@ -123,9 +124,9 @@ public class MainActivity extends BaseActivity implements RefreshListView.IRefre
} }
} }
HttpUtil.init(this); HttpUtils.init(this);
//启用HttpServer //启用HttpServer
if (SettingUtil.getSwitchEnableHttpServer()) { if (SettingUtils.getSwitchEnableHttpServer()) {
HttpServer.init(this); HttpServer.init(this);
try { try {
HttpServer.update(); HttpServer.update();
@ -135,7 +136,7 @@ public class MainActivity extends BaseActivity implements RefreshListView.IRefre
} }
//电池状态定时推送 //电池状态定时推送
if (SettingUtil.getSwitchEnableBatteryCron()) { if (SettingUtils.getSwitchEnableBatteryCron()) {
try { try {
BatteryReportCronTask.getSingleton().updateTimer(); BatteryReportCronTask.getSingleton().updateTimer();
} catch (Exception e) { } catch (Exception e) {
@ -193,12 +194,12 @@ public class MainActivity extends BaseActivity implements RefreshListView.IRefre
ToastUtils.show(R.string.toast_granted_part); ToastUtils.show(R.string.toast_granted_part);
} }
} }
SettingUtil.switchEnableSms(true); SettingUtils.switchEnableSms(true);
//首次使用重要提醒 //首次使用重要提醒
final SharedPreferencesHelper sharedPreferencesHelper = new SharedPreferencesHelper(MainActivity.this, "umeng"); final SharedPreferencesHelper sharedPreferencesHelper = new SharedPreferencesHelper(MainActivity.this, "umeng");
boolean firstTime = sharedPreferencesHelper.getSharedPreference("firstTime", "true").equals("true"); 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) AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this)
.setIcon(R.mipmap.ic_launcher) .setIcon(R.mipmap.ic_launcher)
.setTitle("首次使用重要提醒") .setTitle("首次使用重要提醒")
@ -227,7 +228,7 @@ public class MainActivity extends BaseActivity implements RefreshListView.IRefre
ToastUtils.show(R.string.toast_denied); 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) builder.setTitle(R.string.clear_logs_tips)
.setPositiveButton(R.string.confirm, (dialog, which) -> { .setPositiveButton(R.string.confirm, (dialog, which) -> {
// TODO Auto-generated method stub // TODO Auto-generated method stub
LogUtil.delLog(null, null); LogUtils.delLog(null, null);
initTLogs(); initTLogs();
adapter.add(logVos); adapter.add(logVos);
}); });
@ -285,7 +286,7 @@ public class MainActivity extends BaseActivity implements RefreshListView.IRefre
builder.setPositiveButton(R.string.confirm, (dialog, which) -> { builder.setPositiveButton(R.string.confirm, (dialog, which) -> {
Long id1 = logVos.get(position - 1).getId(); Long id1 = logVos.get(position - 1).getId();
Log.d(TAG, "id = " + id1); Log.d(TAG, "id = " + id1);
LogUtil.delLog(id1, null); LogUtils.delLog(id1, null);
initTLogs(); //初始化数据 initTLogs(); //初始化数据
showList(logVos); showList(logVos);
ToastUtils.show(R.string.delete_log_toast); 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); CommonUtil.toggleNotificationListenerService(this);
SettingUtil.switchEnableAppNotify(false); SettingUtils.switchEnableAppNotify(false);
ToastUtils.delayedShow(R.string.tips_notification_listener, 3000); ToastUtils.delayedShow(R.string.tips_notification_listener, 3000);
return; return;
} }
@ -407,7 +408,7 @@ public class MainActivity extends BaseActivity implements RefreshListView.IRefre
// 初始化数据 // 初始化数据
private void initTLogs() { private void initTLogs() {
logVos = LogUtil.getLog(null, null, currentType); logVos = LogUtils.getLog(null, null, currentType);
} }
private void showList(List<LogVo> logVosN) { private void showList(List<LogVo> logVosN) {
@ -442,15 +443,15 @@ public class MainActivity extends BaseActivity implements RefreshListView.IRefre
builder.setTitle(R.string.details); builder.setTitle(R.string.details);
String simInfo = logVo.getSimInfo(); String simInfo = logVo.getSimInfo();
if (simInfo != null) { 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 { } 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) -> { builder.setNegativeButton(R.string.del, (dialog, which) -> {
Long id = logVo.getId(); Long id = logVo.getId();
Log.d(TAG, "id = " + id); Log.d(TAG, "id = " + id);
LogUtil.delLog(id, null); LogUtils.delLog(id, null);
initTLogs(); //初始化数据 initTLogs(); //初始化数据
showList(logVos); showList(logVos);
ToastUtils.show(R.string.delete_log_toast); 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.BatteryService;
import com.idormy.sms.forwarder.service.FrontService; import com.idormy.sms.forwarder.service.FrontService;
import com.idormy.sms.forwarder.service.MusicService; 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.Define;
import com.idormy.sms.forwarder.utils.PermissionInterceptor; import com.idormy.sms.forwarder.utils.PermissionInterceptor;
import com.idormy.sms.forwarder.utils.PhoneUtils; 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.SharedPreferencesHelper;
import com.idormy.sms.forwarder.utils.UmInitConfig;
import com.smailnet.emailkit.EmailKit; import com.smailnet.emailkit.EmailKit;
import com.umeng.commonsdk.UMConfigure; import com.umeng.commonsdk.UMConfigure;
@ -91,13 +93,13 @@ public class MyApplication extends Application {
} }
SendHistory.init(this); SendHistory.init(this);
SettingUtil.init(this); SettingUtils.init(this);
EmailKit.initialize(this); EmailKit.initialize(this);
SharedPreferences sp = MyApplication.this.getSharedPreferences(Define.SP_CONFIG, Context.MODE_PRIVATE); SharedPreferences sp = MyApplication.this.getSharedPreferences(Define.SP_CONFIG, Context.MODE_PRIVATE);
showHelpTip = sp.getBoolean(Define.SP_CONFIG_SWITCH_HELP_TIP, true); showHelpTip = sp.getBoolean(Define.SP_CONFIG_SWITCH_HELP_TIP, true);
if (SettingUtil.getExcludeFromRecents()) { if (SettingUtils.getExcludeFromRecents()) {
ActivityManager am = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE); ActivityManager am = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE);
if (am != null) { if (am != null) {
List<ActivityManager.AppTask> appTasks = am.getAppTasks(); List<ActivityManager.AppTask> appTasks = am.getAppTasks();
@ -112,7 +114,7 @@ public class MyApplication extends Application {
startService(batteryServiceIntent); startService(batteryServiceIntent);
//后台播放无声音乐 //后台播放无声音乐
if (SettingUtil.getPlaySilenceMusic()) { if (SettingUtils.getPlaySilenceMusic()) {
startService(new Intent(context, MusicService.class)); 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.SendUtil;
import com.idormy.sms.forwarder.sender.SenderUtil; import com.idormy.sms.forwarder.sender.SenderUtil;
import com.idormy.sms.forwarder.utils.CommonUtil; import com.idormy.sms.forwarder.utils.CommonUtil;
import com.idormy.sms.forwarder.utils.LogUtil; import com.idormy.sms.forwarder.utils.LogUtils;
import com.idormy.sms.forwarder.utils.RuleUtil; import com.idormy.sms.forwarder.utils.RuleUtils;
import com.idormy.sms.forwarder.utils.SettingUtil; import com.idormy.sms.forwarder.utils.SettingUtils;
import com.idormy.sms.forwarder.view.StepBar; import com.idormy.sms.forwarder.view.StepBar;
import java.util.ArrayList; import java.util.ArrayList;
@ -66,8 +66,8 @@ public class RuleActivity extends BaseActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_rule); setContentView(R.layout.activity_rule);
LogUtil.init(this); LogUtils.init(this);
RuleUtil.init(this); RuleUtils.init(this);
SenderUtil.init(this); SenderUtil.init(this);
} }
@ -99,7 +99,7 @@ public class RuleActivity extends BaseActivity {
builder.setMessage(R.string.delete_rule_tips); builder.setMessage(R.string.delete_rule_tips);
builder.setPositiveButton(R.string.confirm, (dialog, which) -> { builder.setPositiveButton(R.string.confirm, (dialog, which) -> {
RuleUtil.delRule(ruleModels.get(position).getId()); RuleUtils.delRule(ruleModels.get(position).getId());
initRules(); initRules();
adapter.del(ruleModels); adapter.del(ruleModels);
ToastUtils.show(R.string.delete_rule_toast); ToastUtils.show(R.string.delete_rule_toast);
@ -178,7 +178,7 @@ public class RuleActivity extends BaseActivity {
// 初始化数据 // 初始化数据
private void initRules() { private void initRules() {
ruleModels = RuleUtil.getRule(null, null, currentType); ruleModels = RuleUtils.getRule(null, null, currentType);
} }
private void setRule(final RuleModel ruleModel, final boolean isClone) { private void setRule(final RuleModel ruleModel, final boolean isClone) {
@ -288,7 +288,7 @@ public class RuleActivity extends BaseActivity {
newRuleModel.setRegexReplace(regexReplace); newRuleModel.setRegexReplace(regexReplace);
newRuleModel.setSenderId(Long.valueOf(senderId.toString())); newRuleModel.setSenderId(Long.valueOf(senderId.toString()));
newRuleModel.setStatus(switchRuleStatus.isChecked() ? STATUS_ON : STATUS_OFF); newRuleModel.setStatus(switchRuleStatus.isChecked() ? STATUS_ON : STATUS_OFF);
RuleUtil.addRule(newRuleModel); RuleUtils.addRule(newRuleModel);
initRules(); initRules();
adapter.add(ruleModels); adapter.add(ruleModels);
} else { } else {
@ -302,7 +302,7 @@ public class RuleActivity extends BaseActivity {
ruleModel.setRegexReplace(regexReplace); ruleModel.setRegexReplace(regexReplace);
ruleModel.setSenderId(Long.valueOf(senderId.toString())); ruleModel.setSenderId(Long.valueOf(senderId.toString()));
ruleModel.setStatus(switchRuleStatus.isChecked() ? STATUS_ON : STATUS_OFF); ruleModel.setStatus(switchRuleStatus.isChecked() ? STATUS_ON : STATUS_OFF);
RuleUtil.updateRule(ruleModel); RuleUtils.updateRule(ruleModel);
initRules(); initRules();
adapter.update(ruleModels); adapter.update(ruleModels);
} }
@ -311,7 +311,7 @@ public class RuleActivity extends BaseActivity {
buttonRuleDel.setOnClickListener(view -> { buttonRuleDel.setOnClickListener(view -> {
if (ruleModel != null) { if (ruleModel != null) {
RuleUtil.delRule(ruleModel.getId()); RuleUtils.delRule(ruleModel.getId());
initRules(); initRules();
adapter.del(ruleModels); adapter.del(ruleModels);
} }
@ -576,9 +576,9 @@ public class RuleActivity extends BaseActivity {
String simSlot = RuleModel.getRuleSimSlotFromCheckId(radioGroupTestSimSlot.getCheckedRadioButtonId()); String simSlot = RuleModel.getRuleSimSlotFromCheckId(radioGroupTestSimSlot.getCheckedRadioButtonId());
String simInfo; String simInfo;
if (simSlot.equals("SIM2")) { if (simSlot.equals("SIM2")) {
simInfo = simSlot + "_" + SettingUtil.getAddExtraSim2(); simInfo = simSlot + "_" + SettingUtils.getAddExtraSim2();
} else { } else {
simInfo = simSlot + "_" + SettingUtil.getAddExtraSim1(); simInfo = simSlot + "_" + SettingUtils.getAddExtraSim1();
} }
SmsVo testSmsVo = new SmsVo(editTextTestPhone.getText().toString().trim(), editTextTestMsgContent.getText().toString().trim(), new Date(), simInfo); SmsVo testSmsVo = new SmsVo(editTextTestPhone.getText().toString().trim(), editTextTestMsgContent.getText().toString().trim(), new Date(), simInfo);
SendUtil.sendMsgByRuleModelSenderId(handler, ruleModel, testSmsVo, senderId); 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.SenderUtil;
import com.idormy.sms.forwarder.sender.SenderWebNotifyMsg; import com.idormy.sms.forwarder.sender.SenderWebNotifyMsg;
import com.idormy.sms.forwarder.utils.CommonUtil; import com.idormy.sms.forwarder.utils.CommonUtil;
import com.idormy.sms.forwarder.utils.LogUtil; import com.idormy.sms.forwarder.utils.LogUtils;
import com.idormy.sms.forwarder.utils.RuleUtil; import com.idormy.sms.forwarder.utils.RuleUtils;
import com.idormy.sms.forwarder.view.ClearEditText; import com.idormy.sms.forwarder.view.ClearEditText;
import com.idormy.sms.forwarder.view.StepBar; import com.idormy.sms.forwarder.view.StepBar;
@ -114,8 +114,8 @@ public class SenderActivity extends BaseActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sender); setContentView(R.layout.activity_sender);
LogUtil.init(this); LogUtils.init(this);
RuleUtil.init(this); RuleUtils.init(this);
SenderUtil.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.CommonUtil;
import com.idormy.sms.forwarder.utils.DbHelper; import com.idormy.sms.forwarder.utils.DbHelper;
import com.idormy.sms.forwarder.utils.Define; 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.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.OnePixelManager;
import com.idormy.sms.forwarder.utils.RuleUtil; import com.idormy.sms.forwarder.utils.RuleUtils;
import com.idormy.sms.forwarder.utils.SettingUtil; import com.idormy.sms.forwarder.utils.SettingUtils;
import com.idormy.sms.forwarder.view.StepBar; import com.idormy.sms.forwarder.view.StepBar;
import java.util.Arrays; import java.util.Arrays;
@ -67,8 +67,8 @@ public class SettingActivity extends BaseActivity {
context = SettingActivity.this; context = SettingActivity.this;
setContentView(R.layout.activity_setting); setContentView(R.layout.activity_setting);
LogUtil.init(this); LogUtils.init(this);
RuleUtil.init(this); RuleUtils.init(this);
SenderUtil.init(this); SenderUtil.init(this);
} }
@ -142,7 +142,7 @@ public class SettingActivity extends BaseActivity {
//设置转发短信 //设置转发短信
@SuppressLint("UseSwitchCompatOrMaterialCode") @SuppressLint("UseSwitchCompatOrMaterialCode")
private void switchEnableSms(Switch switch_enable_sms) { 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) -> { switch_enable_sms.setOnCheckedChangeListener((buttonView, isChecked) -> {
Log.d(TAG, "switchEnableSms:" + isChecked); Log.d(TAG, "switchEnableSms:" + isChecked);
@ -166,7 +166,7 @@ public class SettingActivity extends BaseActivity {
} else { } else {
ToastUtils.show(R.string.toast_granted_part); ToastUtils.show(R.string.toast_granted_part);
} }
SettingUtil.switchEnableSms(true); SettingUtils.switchEnableSms(true);
} }
@Override @Override
@ -178,11 +178,11 @@ public class SettingActivity extends BaseActivity {
} else { } else {
ToastUtils.show(R.string.toast_denied); ToastUtils.show(R.string.toast_denied);
} }
SettingUtil.switchEnableSms(false); SettingUtils.switchEnableSms(false);
} }
}); });
} else { } else {
SettingUtil.switchEnableSms(false); SettingUtils.switchEnableSms(false);
} }
}); });
} }
@ -190,15 +190,15 @@ public class SettingActivity extends BaseActivity {
//转发通话记录 //转发通话记录
@SuppressLint("UseSwitchCompatOrMaterialCode") @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) { 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()); switch_enable_phone.setChecked(SettingUtils.getSwitchEnablePhone());
check_box_call_type_1.setChecked(SettingUtil.getSwitchCallType1()); check_box_call_type_1.setChecked(SettingUtils.getSwitchCallType1());
check_box_call_type_2.setChecked(SettingUtil.getSwitchCallType2()); check_box_call_type_2.setChecked(SettingUtils.getSwitchCallType2());
check_box_call_type_3.setChecked(SettingUtil.getSwitchCallType3()); check_box_call_type_3.setChecked(SettingUtils.getSwitchCallType3());
switch_enable_phone.setOnCheckedChangeListener((buttonView, isChecked) -> { 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); ToastUtils.show(R.string.enable_phone_fw_tips);
SettingUtil.switchEnablePhone(false); SettingUtils.switchEnablePhone(false);
return; return;
} }
@ -225,7 +225,7 @@ public class SettingActivity extends BaseActivity {
} else { } else {
ToastUtils.show(R.string.toast_granted_part); ToastUtils.show(R.string.toast_granted_part);
} }
SettingUtil.switchEnablePhone(true); SettingUtils.switchEnablePhone(true);
} }
@Override @Override
@ -237,35 +237,35 @@ public class SettingActivity extends BaseActivity {
} else { } else {
ToastUtils.show(R.string.toast_denied); ToastUtils.show(R.string.toast_denied);
} }
SettingUtil.switchEnablePhone(false); SettingUtils.switchEnablePhone(false);
} }
}); });
} else { } else {
SettingUtil.switchEnablePhone(false); SettingUtils.switchEnablePhone(false);
} }
}); });
check_box_call_type_1.setOnCheckedChangeListener((buttonView, isChecked) -> { check_box_call_type_1.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingUtil.switchCallType1(isChecked); SettingUtils.switchCallType1(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); ToastUtils.show(R.string.enable_phone_fw_tips);
SettingUtil.switchEnablePhone(false); SettingUtils.switchEnablePhone(false);
} }
}); });
check_box_call_type_2.setOnCheckedChangeListener((buttonView, isChecked) -> { check_box_call_type_2.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingUtil.switchCallType2(isChecked); SettingUtils.switchCallType2(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); ToastUtils.show(R.string.enable_phone_fw_tips);
SettingUtil.switchEnablePhone(false); SettingUtils.switchEnablePhone(false);
} }
}); });
check_box_call_type_3.setOnCheckedChangeListener((buttonView, isChecked) -> { check_box_call_type_3.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingUtil.switchCallType3(isChecked); SettingUtils.switchCallType3(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); 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") @SuppressLint("UseSwitchCompatOrMaterialCode")
private void switchEnableAppNotify(Switch switch_enable_app_notify, CheckBox checkbox_cancel_app_notify, CheckBox checkbox_not_user_present) { 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); 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); switch_enable_app_notify.setChecked(isEnable);
layout_cancel_app_notify.setVisibility(isEnable ? View.VISIBLE : View.GONE); layout_cancel_app_notify.setVisibility(isEnable ? View.VISIBLE : View.GONE);
@ -291,24 +291,24 @@ public class SettingActivity extends BaseActivity {
CommonUtil.toggleNotificationListenerService(this); CommonUtil.toggleNotificationListenerService(this);
} }
} }
SettingUtil.switchEnableAppNotify(isChecked); SettingUtils.switchEnableAppNotify(isChecked);
Log.d(TAG, "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) -> { checkbox_cancel_app_notify.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingUtil.switchCancelAppNotify(isChecked); SettingUtils.switchCancelAppNotify(isChecked);
Log.d(TAG, "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) -> { checkbox_not_user_present.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingUtil.switchNotUserPresent(isChecked); SettingUtils.switchNotUserPresent(isChecked);
Log.d(TAG, "switchNotUserPresent:" + isChecked); Log.d(TAG, "switchNotUserPresent:" + isChecked);
//1像素透明Activity保活 or 仅锁屏状态转发APP通知 //1像素透明Activity保活 or 仅锁屏状态转发APP通知
OnePixelManager onePixelManager = new OnePixelManager(); OnePixelManager onePixelManager = new OnePixelManager();
if (SettingUtil.getOnePixelActivity() || SettingUtil.getSwitchNotUserPresent()) { if (SettingUtils.getOnePixelActivity() || SettingUtils.getSwitchNotUserPresent()) {
onePixelManager.registerOnePixelReceiver(this);//注册广播接收者 onePixelManager.registerOnePixelReceiver(this);//注册广播接收者
} else { } else {
onePixelManager.unregisterOnePixelReceiver(this); onePixelManager.unregisterOnePixelReceiver(this);
@ -333,27 +333,27 @@ public class SettingActivity extends BaseActivity {
if (CommonUtil.isNotificationListenerServiceEnabled(this)) { if (CommonUtil.isNotificationListenerServiceEnabled(this)) {
ToastUtils.show(R.string.notification_listener_service_enabled); ToastUtils.show(R.string.notification_listener_service_enabled);
CommonUtil.toggleNotificationListenerService(this); CommonUtil.toggleNotificationListenerService(this);
SettingUtil.switchEnableAppNotify(true); SettingUtils.switchEnableAppNotify(true);
} else { } else {
ToastUtils.show(R.string.notification_listener_service_disabled); 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); @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 //HttpServer
@SuppressLint("UseSwitchCompatOrMaterialCode") @SuppressLint("UseSwitchCompatOrMaterialCode")
private void switchEnableHttpServer(Switch switch_enable_http_server) { 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) -> { switch_enable_http_server.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingUtil.switchEnableHttpServer(isChecked); SettingUtils.switchEnableHttpServer(isChecked);
Log.d(TAG, "switchEnableHttpServer:" + isChecked); Log.d(TAG, "switchEnableHttpServer:" + isChecked);
HttpUtil.init(this); HttpUtils.init(this);
HttpServer.init(this); HttpServer.init(this);
HttpServer.update(); HttpServer.update();
}); });
@ -362,18 +362,18 @@ public class SettingActivity extends BaseActivity {
//监听电池状态变化 //监听电池状态变化
@SuppressLint("UseSwitchCompatOrMaterialCode") @SuppressLint("UseSwitchCompatOrMaterialCode")
private void switchBatteryReceiver(Switch switch_battery_receiver) { 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) -> { switch_battery_receiver.setOnCheckedChangeListener((buttonView, isChecked) -> {
//TODO:校验使用来电转发必备的权限 //TODO:校验使用来电转发必备的权限
SettingUtil.switchEnableBatteryReceiver(isChecked); SettingUtils.switchEnableBatteryReceiver(isChecked);
Log.d(TAG, "switchEnablePhone:" + 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) { 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() { et_battery_level_alarm_min.addTextChangedListener(new TextWatcher() {
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { 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) { public void afterTextChanged(Editable s) {
String batteryLevel = et_battery_level_alarm_min.getText().toString().trim(); String batteryLevel = et_battery_level_alarm_min.getText().toString().trim();
if (!batteryLevel.isEmpty()) { if (!batteryLevel.isEmpty()) {
SettingUtil.setBatteryLevelAlarmMin(Integer.parseInt(batteryLevel)); SettingUtils.setBatteryLevelAlarmMin(Integer.parseInt(batteryLevel));
} else { } 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() { et_battery_level_alarm_max.addTextChangedListener(new TextWatcher() {
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { 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) { public void afterTextChanged(Editable s) {
String batteryLevel = et_battery_level_alarm_max.getText().toString().trim(); String batteryLevel = et_battery_level_alarm_max.getText().toString().trim();
if (!batteryLevel.isEmpty()) { if (!batteryLevel.isEmpty()) {
SettingUtil.setBatteryLevelAlarmMax(Integer.parseInt(batteryLevel)); SettingUtils.setBatteryLevelAlarmMax(Integer.parseInt(batteryLevel));
} else { } 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) -> { cb_battery_level_alarm_once.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingUtil.switchBatteryLevelAlarmOnce(isChecked); SettingUtils.switchBatteryLevelAlarmOnce(isChecked);
if (isChecked && 0 == SettingUtil.getBatteryLevelAlarmMin() && 0 == SettingUtil.getBatteryLevelAlarmMax()) { if (isChecked && 0 == SettingUtils.getBatteryLevelAlarmMin() && 0 == SettingUtils.getBatteryLevelAlarmMax()) {
ToastUtils.show(R.string.tips_battery_level_alarm_once); 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") @SuppressLint("UseSwitchCompatOrMaterialCode")
private void switchBatteryCron(Switch switch_battery_cron) { private void switchBatteryCron(Switch switch_battery_cron) {
boolean isOn = SettingUtil.getSwitchEnableBatteryCron(); boolean isOn = SettingUtils.getSwitchEnableBatteryCron();
switch_battery_cron.setChecked(isOn); switch_battery_cron.setChecked(isOn);
final LinearLayout layout_battery_cron = findViewById(R.id.layout_battery_cron); 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) -> { switch_battery_cron.setOnCheckedChangeListener((buttonView, isChecked) -> {
Log.d(TAG, "onCheckedChanged:" + isChecked); Log.d(TAG, "onCheckedChanged:" + isChecked);
layout_battery_cron.setVisibility(isChecked ? View.VISIBLE : View.GONE); layout_battery_cron.setVisibility(isChecked ? View.VISIBLE : View.GONE);
SettingUtil.switchEnableBatteryCron(isChecked); SettingUtils.switchEnableBatteryCron(isChecked);
BatteryReportCronTask.getSingleton().updateTimer(); BatteryReportCronTask.getSingleton().updateTimer();
}); });
} }
//设置推送电池状态时机 //设置推送电池状态时机
private void editBatteryCronTiming(final EditText et_battery_cron_start_time, final EditText et_battery_cron_interval) { 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(); Calendar calendar = Calendar.getInstance();
et_battery_cron_start_time.setOnClickListener(view -> { et_battery_cron_start_time.setOnClickListener(view -> {
@ -461,13 +461,13 @@ public class SettingActivity extends BaseActivity {
sb.append(minute); sb.append(minute);
String startTime = sb.toString(); String startTime = sb.toString();
et_battery_cron_start_time.setText(startTime); et_battery_cron_start_time.setText(startTime);
SettingUtil.setBatteryCronStartTime(startTime); SettingUtils.setBatteryCronStartTime(startTime);
BatteryReportCronTask.getSingleton().updateTimer(); BatteryReportCronTask.getSingleton().updateTimer();
}, calendar.get(Calendar.HOUR_OF_DAY) + 1, 0, true); }, calendar.get(Calendar.HOUR_OF_DAY) + 1, 0, true);
dialog.show(); 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() { et_battery_cron_interval.addTextChangedListener(new TextWatcher() {
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { 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) { public void afterTextChanged(Editable s) {
String interval = et_battery_cron_interval.getText().toString().trim(); String interval = et_battery_cron_interval.getText().toString().trim();
if (!interval.isEmpty() && Integer.parseInt(interval) > 0) { if (!interval.isEmpty() && Integer.parseInt(interval) > 0) {
SettingUtil.setBatteryCronInterval(Integer.parseInt(interval)); SettingUtils.setBatteryCronInterval(Integer.parseInt(interval));
BatteryReportCronTask.getSingleton().updateTimer(); BatteryReportCronTask.getSingleton().updateTimer();
} else { } else {
SettingUtil.setBatteryCronInterval(60); SettingUtils.setBatteryCronInterval(60);
} }
} }
}); });
@ -715,10 +715,10 @@ public class SettingActivity extends BaseActivity {
//不在最近任务列表中显示 //不在最近任务列表中显示
@SuppressLint("ObsoleteSdkInt,UseSwitchCompatOrMaterialCode") @SuppressLint("ObsoleteSdkInt,UseSwitchCompatOrMaterialCode")
private void switchExcludeFromRecents(Switch switch_exclude_from_recents) { 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) -> { switch_exclude_from_recents.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingUtil.switchExcludeFromRecents(isChecked); SettingUtils.switchExcludeFromRecents(isChecked);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ActivityManager am = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE); ActivityManager am = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE);
if (am != null) { if (am != null) {
@ -735,10 +735,10 @@ public class SettingActivity extends BaseActivity {
//后台播放无声音乐 //后台播放无声音乐
@SuppressLint("ObsoleteSdkInt,UseSwitchCompatOrMaterialCode") @SuppressLint("ObsoleteSdkInt,UseSwitchCompatOrMaterialCode")
private void switchPlaySilenceMusic(Switch switch_play_silence_music) { 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) -> { switch_play_silence_music.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingUtil.switchPlaySilenceMusic(isChecked); SettingUtils.switchPlaySilenceMusic(isChecked);
if (isChecked) { if (isChecked) {
startService(new Intent(context, MusicService.class)); startService(new Intent(context, MusicService.class));
@ -752,15 +752,15 @@ public class SettingActivity extends BaseActivity {
//1像素透明Activity保活 //1像素透明Activity保活
@SuppressLint("ObsoleteSdkInt,UseSwitchCompatOrMaterialCode") @SuppressLint("ObsoleteSdkInt,UseSwitchCompatOrMaterialCode")
private void switchOnePixelActivity(Switch switch_one_pixel_activity) { 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) -> { switch_one_pixel_activity.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingUtil.switchOnePixelActivity(isChecked); SettingUtils.switchOnePixelActivity(isChecked);
Log.d(TAG, "onCheckedChanged:" + isChecked); Log.d(TAG, "onCheckedChanged:" + isChecked);
//1像素透明Activity保活 or 仅锁屏状态转发APP通知 //1像素透明Activity保活 or 仅锁屏状态转发APP通知
OnePixelManager onePixelManager = new OnePixelManager(); OnePixelManager onePixelManager = new OnePixelManager();
if (SettingUtil.getOnePixelActivity() || SettingUtil.getSwitchNotUserPresent()) { if (SettingUtils.getOnePixelActivity() || SettingUtils.getSwitchNotUserPresent()) {
onePixelManager.registerOnePixelReceiver(this);//注册广播接收者 onePixelManager.registerOnePixelReceiver(this);//注册广播接收者
} else { } else {
onePixelManager.unregisterOnePixelReceiver(this); 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) { 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() { et_retry_times.addTextChangedListener(new TextWatcher() {
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { 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) { public void afterTextChanged(Editable s) {
String retryTimes = et_retry_times.getText().toString().trim(); String retryTimes = et_retry_times.getText().toString().trim();
if (!retryTimes.isEmpty()) { if (!retryTimes.isEmpty()) {
SettingUtil.setRetryTimes(Integer.parseInt(retryTimes)); SettingUtils.setRetryTimes(Integer.parseInt(retryTimes));
} else { } 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() { et_delay_time.addTextChangedListener(new TextWatcher() {
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { 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) { public void afterTextChanged(Editable s) {
String delayTime = et_delay_time.getText().toString().trim(); String delayTime = et_delay_time.getText().toString().trim();
if (!delayTime.isEmpty()) { if (!delayTime.isEmpty()) {
SettingUtil.setDelayTime(Integer.parseInt(delayTime)); SettingUtils.setDelayTime(Integer.parseInt(delayTime));
} else { } 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) { 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() { et_add_extra_device_mark.addTextChangedListener(new TextWatcher() {
@Override @Override
@ -828,14 +828,14 @@ public class SettingActivity extends BaseActivity {
@Override @Override
public void afterTextChanged(Editable s) { 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备注 //设置SIM1备注
private void editAddExtraSim1(final EditText et_add_extra_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() { et_add_extra_sim1.addTextChangedListener(new TextWatcher() {
@Override @Override
@ -848,14 +848,14 @@ public class SettingActivity extends BaseActivity {
@Override @Override
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
SettingUtil.setAddExtraSim1(et_add_extra_sim1.getText().toString().trim()); SettingUtils.setAddExtraSim1(et_add_extra_sim1.getText().toString().trim());
} }
}); });
} }
//设置SIM2备注 //设置SIM2备注
private void editAddExtraSim2(final EditText et_add_extra_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() { et_add_extra_sim2.addTextChangedListener(new TextWatcher() {
@Override @Override
@ -868,7 +868,7 @@ public class SettingActivity extends BaseActivity {
@Override @Override
public void afterTextChanged(Editable s) { 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"}) @SuppressLint({"UseSwitchCompatOrMaterialCode", "SetTextI18n"})
private void switchSmsTemplate(Switch switch_sms_template) { private void switchSmsTemplate(Switch switch_sms_template) {
boolean isOn = SettingUtil.getSwitchSmsTemplate(); boolean isOn = SettingUtils.getSwitchSmsTemplate();
switch_sms_template.setChecked(isOn); switch_sms_template.setChecked(isOn);
final LinearLayout layout_sms_template = findViewById(R.id.layout_sms_template); 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) -> { switch_sms_template.setOnCheckedChangeListener((buttonView, isChecked) -> {
Log.d(TAG, "onCheckedChanged:" + isChecked); Log.d(TAG, "onCheckedChanged:" + isChecked);
layout_sms_template.setVisibility(isChecked ? View.VISIBLE : View.GONE); layout_sms_template.setVisibility(isChecked ? View.VISIBLE : View.GONE);
SettingUtil.switchSmsTemplate(isChecked); SettingUtils.switchSmsTemplate(isChecked);
if (!isChecked) { if (!isChecked) {
textSmsTemplate.setText(getString(R.string.tag_from) + "\n" + textSmsTemplate.setText(getString(R.string.tag_from) + "\n" +
getString(R.string.tag_sms) + "\n" + getString(R.string.tag_sms) + "\n" +
@ -899,7 +899,7 @@ public class SettingActivity extends BaseActivity {
//设置转发信息模版 //设置转发信息模版
private void editSmsTemplate(final EditText textSmsTemplate) { private void editSmsTemplate(final EditText textSmsTemplate) {
textSmsTemplate.setText(SettingUtil.getSmsTemplate()); textSmsTemplate.setText(SettingUtils.getSmsTemplate());
textSmsTemplate.addTextChangedListener(new TextWatcher() { textSmsTemplate.addTextChangedListener(new TextWatcher() {
@Override @Override
@ -914,7 +914,7 @@ public class SettingActivity extends BaseActivity {
@Override @Override
public void afterTextChanged(Editable s) { 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.R;
import com.idormy.sms.forwarder.model.vo.LogVo; 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; import java.util.List;
@ -76,7 +76,7 @@ public class LogAdapter extends ArrayAdapter<LogVo> {
viewHolder.tLogFrom.setText(logVo.getFrom()); viewHolder.tLogFrom.setText(logVo.getFrom());
viewHolder.tLogContent.setText(logVo.getContent()); viewHolder.tLogContent.setText(logVo.getContent());
viewHolder.tLogRule.setText(logVo.getRule()); 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.senderImage.setImageResource(logVo.getSenderImageId());
viewHolder.simImage.setImageResource(logVo.getSimImageId()); viewHolder.simImage.setImageResource(logVo.getSimImageId());
viewHolder.statusImage.setImageResource(logVo.getStatusImageId()); 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.alibaba.fastjson.JSON;
import com.idormy.sms.forwarder.utils.PhoneUtils; 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.SimUtil; import com.idormy.sms.forwarder.utils.SimUtils;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
@ -28,7 +28,7 @@ public class SmsHubVo implements Serializable {
public SmsHubVo(Type type, Integer simId, String content, String target) { public SmsHubVo(Type type, Integer simId, String content, String target) {
this.msgId = UUID.randomUUID().toString(); this.msgId = UUID.randomUUID().toString();
if (simId != null) { if (simId != null) {
String simInfo = simId == 2 ? SettingUtil.getAddExtraSim2() : SettingUtil.getAddExtraSim1(); //自定义备注优先 String simInfo = simId == 2 ? SettingUtils.getAddExtraSim2() : SettingUtils.getAddExtraSim1(); //自定义备注优先
simInfo = "SIM" + simId + ":" + simInfo; simInfo = "SIM" + simId + ":" + simInfo;
this.channel = simInfo; this.channel = simInfo;
} }
@ -64,7 +64,7 @@ public class SmsHubVo implements Serializable {
SmsHubVo smsHubVo = new SmsHubVo(); SmsHubVo smsHubVo = new SmsHubVo();
HashMap<String, String> deviInfoMap = getDevInfoMap(false); HashMap<String, String> deviInfoMap = getDevInfoMap(false);
smsHubVo.setDeviceInfo(JSON.toJSONString(deviInfoMap)); 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.setTs(Long.toString(System.currentTimeMillis()));
smsHubVo.setAction(SmsHubVo.Action.heartbeat.code()); smsHubVo.setAction(SmsHubVo.Action.heartbeat.code());
if (data != null && data.size() > 0) { if (data != null && data.size() > 0) {
@ -80,12 +80,12 @@ public class SmsHubVo implements Serializable {
String key = "deviceInfo"; String key = "deviceInfo";
if (reflush || !cache.containsKey(key)) { if (reflush || !cache.containsKey(key)) {
HashMap<String, String> deviInfoMap = new HashMap<>(); HashMap<String, String> deviInfoMap = new HashMap<>();
deviInfoMap.put("mark", SettingUtil.getAddExtraDeviceMark()); deviInfoMap.put("mark", SettingUtils.getAddExtraDeviceMark());
deviInfoMap.put("simOperatorName", PhoneUtils.getSimOperatorName()); deviInfoMap.put("simOperatorName", PhoneUtils.getSimOperatorName());
deviInfoMap.put("phoneNumber", PhoneUtils.getPhoneNumber()); deviInfoMap.put("phoneNumber", PhoneUtils.getPhoneNumber());
deviInfoMap.put("imei", PhoneUtils.getIMEI()); deviInfoMap.put("imei", PhoneUtils.getIMEI());
deviInfoMap.put("SDKVersion", PhoneUtils.getSDKVersion() + ""); deviInfoMap.put("SDKVersion", PhoneUtils.getSDKVersion() + "");
deviInfoMap.put("Version", SettingUtil.getVersionName()); deviInfoMap.put("Version", SettingUtils.getVersionName());
cache.put(key, deviInfoMap); cache.put(key, deviInfoMap);
return deviInfoMap; return deviInfoMap;
} }

@ -7,7 +7,7 @@ import androidx.annotation.NonNull;
import com.idormy.sms.forwarder.MyApplication; import com.idormy.sms.forwarder.MyApplication;
import com.idormy.sms.forwarder.R; 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.io.Serializable;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -47,8 +47,8 @@ public class SmsVo implements Serializable {
public String getTitleForSend(String titleTemplate, String regexReplace) { public String getTitleForSend(String titleTemplate, String regexReplace) {
if (titleTemplate == null || titleTemplate.isEmpty()) titleTemplate = getString(R.string.tag_from); if (titleTemplate == null || titleTemplate.isEmpty()) titleTemplate = getString(R.string.tag_from);
String deviceMark = SettingUtil.getAddExtraDeviceMark().trim(); String deviceMark = SettingUtils.getAddExtraDeviceMark().trim();
String versionName = SettingUtil.getVersionName(); String versionName = SettingUtils.getVersionName();
String titleForSend = titleTemplate.replace(getString(R.string.tag_from), mobile) String titleForSend = titleTemplate.replace(getString(R.string.tag_from), mobile)
.replace(getString(R.string.tag_package_name), mobile) .replace(getString(R.string.tag_package_name), mobile)
.replace(getString(R.string.tag_sms), content) .replace(getString(R.string.tag_sms), content)
@ -75,7 +75,7 @@ public class SmsVo implements Serializable {
@SuppressLint("SimpleDateFormat") @SuppressLint("SimpleDateFormat")
public String getSmsVoForSend(String ruleSmsTemplate, String regexReplace) { 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" + String customSmsTemplate = getString(R.string.tag_from) + "\n" +
getString(R.string.tag_sms) + "\n" + getString(R.string.tag_sms) + "\n" +
getString(R.string.tag_card_slot) + "\n" + getString(R.string.tag_card_slot) + "\n" +
@ -86,14 +86,14 @@ public class SmsVo implements Serializable {
if (!ruleSmsTemplate.isEmpty()) { if (!ruleSmsTemplate.isEmpty()) {
customSmsTemplate = ruleSmsTemplate; customSmsTemplate = ruleSmsTemplate;
} else { } else {
boolean switchSmsTemplate = SettingUtil.getSwitchSmsTemplate(); boolean switchSmsTemplate = SettingUtils.getSwitchSmsTemplate();
String smsTemplate = SettingUtil.getSmsTemplate().trim(); String smsTemplate = SettingUtils.getSmsTemplate().trim();
if (switchSmsTemplate && !smsTemplate.isEmpty()) { if (switchSmsTemplate && !smsTemplate.isEmpty()) {
customSmsTemplate = smsTemplate; customSmsTemplate = smsTemplate;
} }
} }
String versionName = SettingUtil.getVersionName(); String versionName = SettingUtils.getVersionName();
String smsVoForSend = customSmsTemplate.replace(getString(R.string.tag_from), mobile) String smsVoForSend = customSmsTemplate.replace(getString(R.string.tag_from), mobile)
.replace(getString(R.string.tag_package_name), mobile) .replace(getString(R.string.tag_package_name), mobile)
.replace(getString(R.string.tag_sms), content) .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.ResVo;
import com.idormy.sms.forwarder.model.vo.SmsHubVo; import com.idormy.sms.forwarder.model.vo.SmsHubVo;
import com.idormy.sms.forwarder.utils.CloneUtils; import com.idormy.sms.forwarder.utils.CloneUtils;
import com.idormy.sms.forwarder.utils.HttpUtil; import com.idormy.sms.forwarder.utils.HttpUtils;
import com.idormy.sms.forwarder.utils.LogUtil; import com.idormy.sms.forwarder.utils.LogUtils;
import com.idormy.sms.forwarder.utils.SettingUtil; import com.idormy.sms.forwarder.utils.SettingUtils;
import com.idormy.sms.forwarder.utils.SimUtil; import com.idormy.sms.forwarder.utils.SimUtils;
import com.idormy.sms.forwarder.utils.SmsUtil; import com.idormy.sms.forwarder.utils.SmsUtils;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletContextHandler;
@ -56,7 +56,7 @@ public class BaseServlet extends HttpServlet {
public BaseServlet(String path, Context context) { public BaseServlet(String path, Context context) {
this.path = path; this.path = path;
this.context = context; this.context = context;
SettingUtil.init(context); SettingUtils.init(context);
} }
public Context getContext() { public Context getContext() {
@ -226,17 +226,17 @@ public class BaseServlet extends HttpServlet {
if (SmsHubVo.Action.send.code().equals(vo.getAction())) { if (SmsHubVo.Action.send.code().equals(vo.getAction())) {
vo.setType(SmsHubVo.Type.sms.code()); vo.setType(SmsHubVo.Type.sms.code());
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP_MR1) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP_MR1) {
int subscriptionIdBySimId = SimUtil.getSubscriptionIdBySimId(Integer.parseInt(vo.getChannel()) - 1); int subscriptionIdBySimId = SimUtils.getSubscriptionIdBySimId(Integer.parseInt(vo.getChannel()) - 1);
msg = SmsUtil.sendSms(subscriptionIdBySimId, vo.getTarget(), vo.getContent()); msg = SmsUtils.sendSms(subscriptionIdBySimId, vo.getTarget(), vo.getContent());
String simInfo = "SIM" + (subscriptionIdBySimId + 1); String simInfo = "SIM" + (subscriptionIdBySimId + 1);
vo.setChannel(simInfo); 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) { if (msg == null) {
failure = false; failure = false;
HttpUtil.Toast(tag, "短信发送成功"); HttpUtils.Toast(tag, "短信发送成功");
Log.i(tag, "短信发送成功"); Log.i(tag, "短信发送成功");
vo.setAction(SmsHubVo.Action.suessces.code()); vo.setAction(SmsHubVo.Action.suessces.code());
LogUtil.updateLog(logId, 2, SmsHubVo.Action.suessces.code()); LogUtils.updateLog(logId, 2, SmsHubVo.Action.suessces.code());
} }
} else { } else {
msg = "api<22"; msg = "api<22";
@ -248,12 +248,12 @@ public class BaseServlet extends HttpServlet {
} }
if (failure) { if (failure) {
msg = "短信发送失败:" + msg; msg = "短信发送失败:" + msg;
HttpUtil.Toast(tag, msg); HttpUtils.Toast(tag, msg);
Log.i(tag, msg); Log.i(tag, msg);
vo.setAction(SmsHubVo.Action.failure.code()); vo.setAction(SmsHubVo.Action.failure.code());
vo.setErrMsg(msg); vo.setErrMsg(msg);
if (logId != null) { 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.CommonUtil;
import com.idormy.sms.forwarder.utils.ContactHelper; import com.idormy.sms.forwarder.utils.ContactHelper;
import com.idormy.sms.forwarder.utils.PhoneUtils; 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.SimUtil; import com.idormy.sms.forwarder.utils.SimUtils;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
@ -30,7 +30,7 @@ public class PhoneStateReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
if (!SettingUtil.getSwitchEnablePhone()) { if (!SettingUtils.getSwitchEnablePhone()) {
return; return;
} }
@ -84,9 +84,9 @@ public class PhoneStateReceiver extends BroadcastReceiver {
if (callInfo == null) return; if (callInfo == null) return;
int type = callInfo.getType(); int type = callInfo.getType();
if ((type == 1 && !SettingUtil.getSwitchCallType1()) if ((type == 1 && !SettingUtils.getSwitchCallType1())
|| (type == 2 && !SettingUtil.getSwitchCallType2()) || (type == 2 && !SettingUtils.getSwitchCallType2())
|| (type == 3 && !SettingUtil.getSwitchCallType3())) { || (type == 3 && !SettingUtils.getSwitchCallType3())) {
Log.w(TAG, "Call record forwarding of this type is not enabled, no processing will be done!"); Log.w(TAG, "Call record forwarding of this type is not enabled, no processing will be done!");
return; return;
} }
@ -100,9 +100,9 @@ public class PhoneStateReceiver extends BroadcastReceiver {
int simId = 1; int simId = 1;
Log.d(TAG, "getSubscriptionId = " + callInfo.getSubscriptionId()); //TODO:这里的SubscriptionId跟短信的不一样 Log.d(TAG, "getSubscriptionId = " + callInfo.getSubscriptionId()); //TODO:这里的SubscriptionId跟短信的不一样
if (callInfo.getSubscriptionId() != -1) { 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; simInfo = "SIM" + simId + "_" + simInfo;
if (TextUtils.isEmpty(name)) { if (TextUtils.isEmpty(name)) {
@ -116,14 +116,14 @@ public class PhoneStateReceiver extends BroadcastReceiver {
//TODO:同一卡槽同一秒的重复未接来电广播不再重复处理(部分机型会收到两条广播?) //TODO:同一卡槽同一秒的重复未接来电广播不再重复处理(部分机型会收到两条广播?)
String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINESE).format(new Date()); 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); String currHash = CommonUtil.MD5(phoneNumber + simInfo + time);
Log.d(TAG, "prevHash=" + prevHash + " currHash=" + currHash); Log.d(TAG, "prevHash=" + prevHash + " currHash=" + currHash);
if (prevHash != null && prevHash.equals(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)"); 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; return;
} }
SettingUtil.setPrevNoticeHash(phoneNumber, currHash); SettingUtils.setPrevNoticeHash(phoneNumber, currHash);
SmsVo smsVo = new SmsVo(phoneNumber, getTypeText(context, type, name, viaNumber), new Date(), simInfo); SmsVo smsVo = new SmsVo(phoneNumber, getTypeText(context, type, name, viaNumber), new Date(), simInfo);
Log.d(TAG, "send_msg" + smsVo); 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.BatteryService;
import com.idormy.sms.forwarder.service.FrontService; import com.idormy.sms.forwarder.service.FrontService;
import com.idormy.sms.forwarder.service.MusicService; import com.idormy.sms.forwarder.service.MusicService;
import com.idormy.sms.forwarder.utils.InitUtil; import com.idormy.sms.forwarder.utils.InitUtils;
import com.idormy.sms.forwarder.utils.SettingUtil; import com.idormy.sms.forwarder.utils.SettingUtils;
public class RebootBroadcastReceiver extends BroadcastReceiver { public class RebootBroadcastReceiver extends BroadcastReceiver {
@ -20,7 +20,7 @@ public class RebootBroadcastReceiver extends BroadcastReceiver {
String TAG = "RebootBroadcastReceiver"; String TAG = "RebootBroadcastReceiver";
Log.d(TAG, "onReceive intent " + receiveAction); Log.d(TAG, "onReceive intent " + receiveAction);
if (receiveAction.equals("android.intent.action.BOOT_COMPLETED")) { if (receiveAction.equals("android.intent.action.BOOT_COMPLETED")) {
InitUtil.init(context); InitUtils.init(context);
//前台服务 //前台服务
Intent frontServiceIntent = new Intent(context, FrontService.class); Intent frontServiceIntent = new Intent(context, FrontService.class);
@ -35,7 +35,7 @@ public class RebootBroadcastReceiver extends BroadcastReceiver {
context.startService(batteryServiceIntent); context.startService(batteryServiceIntent);
//后台播放无声音乐 //后台播放无声音乐
if (SettingUtil.getPlaySilenceMusic()) { if (SettingUtils.getPlaySilenceMusic()) {
context.startService(new Intent(context, MusicService.class)); 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.MyApplication;
import com.idormy.sms.forwarder.utils.OnePixelManager; 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 { public class ScreenBroadcastReceiver extends BroadcastReceiver {
@ -18,7 +18,7 @@ public class ScreenBroadcastReceiver extends BroadcastReceiver {
String action = intent.getAction(); String action = intent.getAction();
//1像素透明Activity保活 //1像素透明Activity保活
if (SettingUtil.getOnePixelActivity()) { if (SettingUtils.getOnePixelActivity()) {
OnePixelManager manager = new OnePixelManager(); OnePixelManager manager = new OnePixelManager();
if (Intent.ACTION_SCREEN_ON.equals(action)) {//如果亮屏则关闭1像素Activity if (Intent.ACTION_SCREEN_ON.equals(action)) {//如果亮屏则关闭1像素Activity
manager.finishOnePixelActivity(); manager.finishOnePixelActivity();

@ -12,8 +12,8 @@ import androidx.annotation.RequiresApi;
import com.idormy.sms.forwarder.model.vo.SmsVo; import com.idormy.sms.forwarder.model.vo.SmsVo;
import com.idormy.sms.forwarder.sender.SendUtil; import com.idormy.sms.forwarder.sender.SendUtil;
import com.idormy.sms.forwarder.utils.SettingUtil; import com.idormy.sms.forwarder.utils.SettingUtils;
import com.idormy.sms.forwarder.utils.SimUtil; import com.idormy.sms.forwarder.utils.SimUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
@ -37,7 +37,7 @@ public class SmsBroadcastReceiver extends BroadcastReceiver {
if (SMS_RECEIVED_ACTION.equals(receiveAction) || SMS_DELIVER_ACTION.equals(receiveAction)) { if (SMS_RECEIVED_ACTION.equals(receiveAction) || SMS_DELIVER_ACTION.equals(receiveAction)) {
try { try {
if (!SettingUtil.getSwitchEnableSms()) { if (!SettingUtils.getSwitchEnableSms()) {
return; return;
} }
@ -53,11 +53,11 @@ public class SmsBroadcastReceiver extends BroadcastReceiver {
if (extras.containsKey("simId")) { if (extras.containsKey("simId")) {
simId = extras.getInt("simId"); simId = extras.getInt("simId");
} else if (extras.containsKey("subscription")) { } 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; simInfo = "SIM" + simId + "_" + simInfo;
} catch (Exception e) { } catch (Exception e) {
Log.e(TAG, "Failed to get the receiving phone number:" + e.getMessage()); 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.MyApplication;
import com.idormy.sms.forwarder.model.vo.SmsVo; import com.idormy.sms.forwarder.model.vo.SmsVo;
import com.idormy.sms.forwarder.utils.BatteryUtils; 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.Calendar;
import java.util.Date; import java.util.Date;
@ -36,7 +36,7 @@ public class BatteryReportCronTask {
public void updateTimer() { public void updateTimer() {
cancelTimer(); cancelTimer();
if (SettingUtil.getSwitchEnableBatteryCron()) { if (SettingUtils.getSwitchEnableBatteryCron()) {
startTimer(); startTimer();
} else { } else {
Log.d(TAG, "Cancel Task"); Log.d(TAG, "Cancel Task");
@ -51,8 +51,8 @@ public class BatteryReportCronTask {
} }
private void startTimer() { private void startTimer() {
String startTime = SettingUtil.getBatteryCronStartTime(); String startTime = SettingUtils.getBatteryCronStartTime();
int interval = SettingUtil.getBatteryCronInterval(); int interval = SettingUtils.getBatteryCronInterval();
Log.i(TAG, "Task started, startTime: " + startTime + ", interval: " + interval); Log.i(TAG, "Task started, startTime: " + startTime + ", interval: " + interval);
int hour = Integer.parseInt(startTime.split(":")[0]); 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.model.vo.SmsHubVo;
import com.idormy.sms.forwarder.receiver.BaseServlet; import com.idormy.sms.forwarder.receiver.BaseServlet;
import com.idormy.sms.forwarder.utils.Define; import com.idormy.sms.forwarder.utils.Define;
import com.idormy.sms.forwarder.utils.NetUtil; import com.idormy.sms.forwarder.utils.NetUtils;
import com.idormy.sms.forwarder.utils.SettingUtil; import com.idormy.sms.forwarder.utils.SettingUtils;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
@ -58,7 +58,7 @@ public class HttpServer {
public synchronized static boolean update() { public synchronized static boolean update() {
//非WiFi网络下不可启用 //非WiFi网络下不可启用
if (NetUtil.NETWORK_WIFI != NetUtil.getNetWorkStatus()) { if (NetUtils.NETWORK_WIFI != NetUtils.getNetWorkStatus()) {
ToastUtils.show(R.string.no_wifi_network); ToastUtils.show(R.string.no_wifi_network);
if (asRunning()) stop(); if (asRunning()) stop();
return false; return false;
@ -68,10 +68,10 @@ public class HttpServer {
ToastUtils.show(R.string.tips_wait_3_seconds); ToastUtils.show(R.string.tips_wait_3_seconds);
return false; return false;
} }
if (asRunning().equals(SettingUtil.getSwitchEnableHttpServer())) { if (asRunning().equals(SettingUtils.getSwitchEnableHttpServer())) {
return false; return false;
} }
if (SettingUtil.getSwitchEnableHttpServer()) { if (SettingUtils.getSwitchEnableHttpServer()) {
SmsHubVo.getDevInfoMap(true); SmsHubVo.getDevInfoMap(true);
start(); start();
ts = System.currentTimeMillis(); ts = System.currentTimeMillis();

@ -4,7 +4,7 @@ import android.util.Log;
import androidx.annotation.NonNull; 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.IOException;
import java.io.InterruptedIOException; import java.io.InterruptedIOException;
@ -58,7 +58,7 @@ public class RetryIntercepter implements Interceptor {
response = chain.proceed(request); response = chain.proceed(request);
} catch (Exception e) { } catch (Exception e) {
String resp = retryTimes > 0 ? "第" + retryTimes + "次重试:" + e.getMessage() : e.getMessage(); String resp = retryTimes > 0 ? "第" + retryTimes + "次重试:" + e.getMessage() : e.getMessage();
LogUtil.updateLog(logId, 1, resp); LogUtils.updateLog(logId, 1, resp);
Log.w(TAG, resp); Log.w(TAG, resp);
} }
return response; 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.model.LogTable;
import com.idormy.sms.forwarder.utils.DbHelper; import com.idormy.sms.forwarder.utils.DbHelper;
import com.idormy.sms.forwarder.utils.Define; 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.ArrayList;
import java.util.HashSet; import java.util.HashSet;
@ -43,7 +43,7 @@ public class SendHistory {
@SuppressLint("MutatingSharedPrefs") @SuppressLint("MutatingSharedPrefs")
public static void addHistory(String msg) { public static void addHistory(String msg) {
//不保存转发消息 //不保存转发消息
if (SettingUtil.saveMsgHistory()) return; if (SettingUtils.saveMsgHistory()) return;
//保存 //保存
SharedPreferences sp = context.getSharedPreferences(Define.SP_MSG, Context.MODE_PRIVATE); SharedPreferences sp = context.getSharedPreferences(Define.SP_MSG, Context.MODE_PRIVATE);
Set<String> msg_set_default = new HashSet<>(); Set<String> msg_set_default = new HashSet<>();
@ -69,7 +69,7 @@ public class SendHistory {
public static long addHistoryDb(LogModel logModel) { public static long addHistoryDb(LogModel logModel) {
//不保存转发消息 //不保存转发消息
if (SettingUtil.saveMsgHistory()) return 0; if (SettingUtils.saveMsgHistory()) return 0;
// Gets the data repository in write mode // Gets the data repository in write mode
SQLiteDatabase db = dbHelper.getWritableDatabase(); 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.SmsVo;
import com.idormy.sms.forwarder.model.vo.TelegramSettingVo; import com.idormy.sms.forwarder.model.vo.TelegramSettingVo;
import com.idormy.sms.forwarder.model.vo.WebNotifySettingVo; import com.idormy.sms.forwarder.model.vo.WebNotifySettingVo;
import com.idormy.sms.forwarder.utils.LogUtil; import com.idormy.sms.forwarder.utils.LogUtils;
import com.idormy.sms.forwarder.utils.NetUtil; import com.idormy.sms.forwarder.utils.NetUtils;
import com.idormy.sms.forwarder.utils.RuleUtil; import com.idormy.sms.forwarder.utils.RuleUtils;
import com.idormy.sms.forwarder.utils.SettingUtil; import com.idormy.sms.forwarder.utils.SettingUtils;
import com.idormy.sms.forwarder.utils.TimeUtil; import com.idormy.sms.forwarder.utils.TimeUtils;
import java.text.ParseException; import java.text.ParseException;
import java.util.Date; import java.util.Date;
@ -58,11 +58,11 @@ public class SendUtil {
public static void send_msg(Context context, SmsVo smsVo, int simId, String type) { public static void send_msg(Context context, SmsVo smsVo, int simId, String type) {
Log.i(TAG, "send_msg smsVo:" + smsVo); Log.i(TAG, "send_msg smsVo:" + smsVo);
RuleUtil.init(context); RuleUtils.init(context);
LogUtil.init(context); LogUtils.init(context);
String key = "SIM" + simId; 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()) { if (!ruleList.isEmpty()) {
Log.d(TAG, ruleList.toString()); Log.d(TAG, ruleList.toString());
SenderUtil.init(context); SenderUtil.init(context);
@ -73,7 +73,7 @@ public class SendUtil {
List<SenderModel> senderModels = SenderUtil.getSender(ruleModel.getSenderId(), null); List<SenderModel> senderModels = SenderUtil.getSender(ruleModel.getSenderId(), null);
for (SenderModel senderModel : senderModels 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 smsTemplate = ruleModel.getSwitchSmsTemplate() ? ruleModel.getSmsTemplate() : "";
String regexReplace = ruleModel.getSwitchRegexReplace() ? ruleModel.getRegexReplace() : ""; String regexReplace = ruleModel.getSwitchRegexReplace() ? ruleModel.getRegexReplace() : "";
SendUtil.senderSendMsgNoHandError(smsVo, senderModel, logId, smsTemplate, regexReplace); SendUtil.senderSendMsgNoHandError(smsVo, senderModel, logId, smsTemplate, regexReplace);
@ -98,7 +98,7 @@ public class SendUtil {
Log.d(TAG, logVo.toString()); Log.d(TAG, logVo.toString());
Date date = new Date(); Date date = new Date();
try { try {
date = TimeUtil.utc2LocalDate(logVo.getTime()); date = TimeUtils.utc2LocalDate(logVo.getTime());
} catch (ParseException e) { } catch (ParseException e) {
Log.e(TAG, "SimpleDateFormat parse error", e); Log.e(TAG, "SimpleDateFormat parse error", e);
} }
@ -114,8 +114,8 @@ public class SendUtil {
key = "SIM2"; key = "SIM2";
} }
RuleUtil.init(context); RuleUtils.init(context);
List<RuleModel> ruleList = RuleUtil.getRule(null, key, logVo.getType(), "1"); //只取已启用的规则 List<RuleModel> ruleList = RuleUtils.getRule(null, key, logVo.getType(), "1"); //只取已启用的规则
if (!ruleList.isEmpty()) { if (!ruleList.isEmpty()) {
SenderUtil.init(context); SenderUtil.init(context);
for (RuleModel ruleModel : ruleList) { for (RuleModel ruleModel : ruleList) {
@ -168,8 +168,8 @@ public class SendUtil {
//网络请求+延时重试比较耗时,创建子线程处理 //网络请求+延时重试比较耗时,创建子线程处理
new Thread(() -> { new Thread(() -> {
try { try {
int retryTimes = SettingUtil.getRetryTimes(); int retryTimes = SettingUtils.getRetryTimes();
int delayTime = SettingUtil.getDelayTime(); int delayTime = SettingUtils.getDelayTime();
RetryIntercepter retryInterceptor = retryTimes < 1 ? null : new RetryIntercepter.Builder().executionCount(retryTimes).retryInterval(delayTime).logId(logId).build(); RetryIntercepter retryInterceptor = retryTimes < 1 ? null : new RetryIntercepter.Builder().executionCount(retryTimes).retryInterval(delayTime).logId(logId).build();
SendUtil.senderSendMsg(null, retryInterceptor, smsVo, senderModel, logId, smsTemplate, regexReplace); SendUtil.senderSendMsg(null, retryInterceptor, smsVo, senderModel, logId, smsTemplate, regexReplace);
} catch (Exception e) { } catch (Exception e) {
@ -183,7 +183,7 @@ public class SendUtil {
Log.i(TAG, "senderSendMsg smsVo:" + smsVo.toString() + "senderModel:" + senderModel.toString()); Log.i(TAG, "senderSendMsg smsVo:" + smsVo.toString() + "senderModel:" + senderModel.toString());
if (senderModel.getStatus() == STATUS_OFF) { if (senderModel.getStatus() == STATUS_OFF) {
LogUtil.updateLog(logId, 0, "发送通道已被禁用!"); LogUtils.updateLog(logId, 0, "发送通道已被禁用!");
Log.i(TAG, "发送通道已被禁用!"); Log.i(TAG, "发送通道已被禁用!");
return; return;
} }
@ -197,7 +197,7 @@ public class SendUtil {
try { try {
SenderDingdingMsg.sendMsg(logId, handError, retryInterceptor, dingDingSettingVo.getToken(), dingDingSettingVo.getSecret(), dingDingSettingVo.getAtMobiles(), dingDingSettingVo.getAtAll(), smsVo.getSmsVoForSend(smsTemplate, regexReplace)); SenderDingdingMsg.sendMsg(logId, handError, retryInterceptor, dingDingSettingVo.getToken(), dingDingSettingVo.getSecret(), dingDingSettingVo.getAtMobiles(), dingDingSettingVo.getAtAll(), smsVo.getSmsVoForSend(smsTemplate, regexReplace));
} catch (Exception e) { } catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage()); LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: dingding error " + e.getMessage()); Log.e(TAG, "senderSendMsg: dingding error " + e.getMessage());
} }
} }
@ -212,7 +212,7 @@ public class SendUtil {
try { try {
SenderMailMsg.sendEmail(logId, handError, emailSettingVo, smsVo.getTitleForSend(emailSettingVo.getTitle(), regexReplace), smsVo.getSmsVoForSend(smsTemplate, regexReplace)); SenderMailMsg.sendEmail(logId, handError, emailSettingVo, smsVo.getTitleForSend(emailSettingVo.getTitle(), regexReplace), smsVo.getSmsVoForSend(smsTemplate, regexReplace));
} catch (Exception e) { } catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage()); LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: SenderMailMsg error " + e.getMessage()); Log.e(TAG, "senderSendMsg: SenderMailMsg error " + e.getMessage());
} }
} }
@ -227,7 +227,7 @@ public class SendUtil {
try { try {
SenderBarkMsg.sendMsg(logId, handError, retryInterceptor, barkSettingVo, smsVo.getTitleForSend(barkSettingVo.getTitle()), smsVo.getSmsVoForSend(smsTemplate, regexReplace), senderModel.getName()); SenderBarkMsg.sendMsg(logId, handError, retryInterceptor, barkSettingVo, smsVo.getTitleForSend(barkSettingVo.getTitle()), smsVo.getSmsVoForSend(smsTemplate, regexReplace), senderModel.getName());
} catch (Exception e) { } catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage()); LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: SenderBarkMsg error " + e.getMessage()); Log.e(TAG, "senderSendMsg: SenderBarkMsg error " + e.getMessage());
} }
} }
@ -242,7 +242,7 @@ public class SendUtil {
try { try {
SenderWebNotifyMsg.sendMsg(logId, handError, retryInterceptor, webNotifySettingVo.getWebServer(), webNotifySettingVo.getWebParams(), webNotifySettingVo.getSecret(), webNotifySettingVo.getMethod(), webNotifySettingVo.getHeaders(), smsVo, smsTemplate, regexReplace); SenderWebNotifyMsg.sendMsg(logId, handError, retryInterceptor, webNotifySettingVo.getWebServer(), webNotifySettingVo.getWebParams(), webNotifySettingVo.getSecret(), webNotifySettingVo.getMethod(), webNotifySettingVo.getHeaders(), smsVo, smsTemplate, regexReplace);
} catch (Exception e) { } catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage()); LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: SenderWebNotifyMsg error " + e.getMessage()); Log.e(TAG, "senderSendMsg: SenderWebNotifyMsg error " + e.getMessage());
} }
} }
@ -257,7 +257,7 @@ public class SendUtil {
try { try {
SenderQyWxGroupRobotMsg.sendMsg(logId, handError, retryInterceptor, qywxGroupRobotSettingVo.getWebHook(), smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate, regexReplace)); SenderQyWxGroupRobotMsg.sendMsg(logId, handError, retryInterceptor, qywxGroupRobotSettingVo.getWebHook(), smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate, regexReplace));
} catch (Exception e) { } catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage()); LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: SenderQyWxGroupRobotMsg error " + e.getMessage()); Log.e(TAG, "senderSendMsg: SenderQyWxGroupRobotMsg error " + e.getMessage());
} }
} }
@ -272,7 +272,7 @@ public class SendUtil {
try { try {
SenderQyWxAppMsg.sendMsg(logId, handError, retryInterceptor, senderModel, qYWXAppSettingVo, smsVo.getSmsVoForSend(smsTemplate, regexReplace)); SenderQyWxAppMsg.sendMsg(logId, handError, retryInterceptor, senderModel, qYWXAppSettingVo, smsVo.getSmsVoForSend(smsTemplate, regexReplace));
} catch (Exception e) { } catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage()); LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: qywx_app error " + e.getMessage()); Log.e(TAG, "senderSendMsg: qywx_app error " + e.getMessage());
} }
} }
@ -287,7 +287,7 @@ public class SendUtil {
try { try {
SenderServerChanMsg.sendMsg(logId, handError, retryInterceptor, serverChanSettingVo.getSendKey(), smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate, regexReplace)); SenderServerChanMsg.sendMsg(logId, handError, retryInterceptor, serverChanSettingVo.getSendKey(), smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate, regexReplace));
} catch (Exception e) { } catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage()); LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: SenderServerChanMsg error " + e.getMessage()); Log.e(TAG, "senderSendMsg: SenderServerChanMsg error " + e.getMessage());
} }
} }
@ -302,7 +302,7 @@ public class SendUtil {
try { try {
SenderTelegramMsg.sendMsg(logId, handError, retryInterceptor, telegramSettingVo, smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate, regexReplace), telegramSettingVo.getMethod()); SenderTelegramMsg.sendMsg(logId, handError, retryInterceptor, telegramSettingVo, smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate, regexReplace), telegramSettingVo.getMethod());
} catch (Exception e) { } catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage()); LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: SenderTelegramMsg error " + 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); SmsSettingVo smsSettingVo = JSON.parseObject(senderModel.getJsonSetting(), SmsSettingVo.class);
if (smsSettingVo != null) { if (smsSettingVo != null) {
//仅当无网络时启用 //仅当无网络时启用
if (smsSettingVo.getOnlyNoNetwork() && 0 != NetUtil.getNetWorkStatus()) { if (smsSettingVo.getOnlyNoNetwork() && 0 != NetUtils.getNetWorkStatus()) {
String msg = "仅当无网络时启用,当前网络状态:" + NetUtil.getNetWorkStatus(); String msg = "仅当无网络时启用,当前网络状态:" + NetUtils.getNetWorkStatus();
LogUtil.updateLog(logId, 0, msg); LogUtils.updateLog(logId, 0, msg);
Log.d(TAG, msg); Log.d(TAG, msg);
return; return;
} }
@ -329,7 +329,7 @@ public class SendUtil {
} }
SenderSmsMsg.sendMsg(logId, handError, simSlot, smsSettingVo.getMobiles(), smsSettingVo.getOnlyNoNetwork(), smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate, regexReplace)); SenderSmsMsg.sendMsg(logId, handError, simSlot, smsSettingVo.getMobiles(), smsSettingVo.getOnlyNoNetwork(), smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate, regexReplace));
} catch (Exception e) { } catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage()); LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: SenderSmsMsg error " + e.getMessage()); Log.e(TAG, "senderSendMsg: SenderSmsMsg error " + e.getMessage());
} }
} }
@ -344,7 +344,7 @@ public class SendUtil {
try { try {
SenderFeishuMsg.sendMsg(logId, handError, retryInterceptor, feiShuSettingVo.getWebhook(), feiShuSettingVo.getSecret(), feiShuSettingVo.getMsgType(), smsVo.getMobile(), smsVo.getDate(), smsVo.getTitleForSend(feiShuSettingVo.getTitleTemplate()), smsVo.getSmsVoForSend(smsTemplate, regexReplace)); 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) { } catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage()); LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: feishu error " + e.getMessage()); Log.e(TAG, "senderSendMsg: feishu error " + e.getMessage());
} }
} }
@ -359,7 +359,7 @@ public class SendUtil {
try { try {
SenderPushPlusMsg.sendMsg(logId, handError, retryInterceptor, pushPlusSettingVo, smsVo.getTitleForSend(pushPlusSettingVo.getTitleTemplate()), smsVo.getSmsVoForSend(smsTemplate, regexReplace)); SenderPushPlusMsg.sendMsg(logId, handError, retryInterceptor, pushPlusSettingVo, smsVo.getTitleForSend(pushPlusSettingVo.getTitleTemplate()), smsVo.getSmsVoForSend(smsTemplate, regexReplace));
} catch (Exception e) { } catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage()); LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: feishu error " + e.getMessage()); Log.e(TAG, "senderSendMsg: feishu error " + e.getMessage());
} }
} }
@ -374,7 +374,7 @@ public class SendUtil {
try { try {
SenderGotifyMsg.sendMsg(logId, handError, retryInterceptor, gotifySettingVo, smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate, regexReplace)); SenderGotifyMsg.sendMsg(logId, handError, retryInterceptor, gotifySettingVo, smsVo.getMobile(), smsVo.getSmsVoForSend(smsTemplate, regexReplace));
} catch (Exception e) { } catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage()); LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: gotify error " + 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.model.vo.BarkSettingVo;
import com.idormy.sms.forwarder.utils.Define; 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.io.IOException;
import java.util.Objects; import java.util.Objects;
@ -89,7 +89,7 @@ public class SenderBarkMsg extends SenderBaseMsg {
client.newCall(request).enqueue(new Callback() { client.newCall(request).enqueue(new Callback() {
@Override @Override
public void onFailure(@NonNull Call call, @NonNull final IOException e) { 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()); Toast(handError, TAG, "发送失败:" + e.getMessage());
} }
@ -101,9 +101,9 @@ public class SenderBarkMsg extends SenderBaseMsg {
//TODO:粗略解析是否发送成功 //TODO:粗略解析是否发送成功
if (responseStr.contains("\"message\":\"success\"")) { if (responseStr.contains("\"message\":\"success\"")) {
LogUtil.updateLog(logId, 2, responseStr); LogUtils.updateLog(logId, 2, responseStr);
} else { } 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.alibaba.fastjson.JSON;
import com.idormy.sms.forwarder.utils.Define; 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.io.IOException;
import java.net.URLEncoder; import java.net.URLEncoder;
@ -110,7 +110,7 @@ public class SenderDingdingMsg extends SenderBaseMsg {
client.newCall(request).enqueue(new Callback() { client.newCall(request).enqueue(new Callback() {
@Override @Override
public void onFailure(@NonNull Call call, @NonNull final IOException e) { 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()); Toast(handError, TAG, "发送失败:" + e.getMessage());
} }
@ -122,9 +122,9 @@ public class SenderDingdingMsg extends SenderBaseMsg {
//TODO:粗略解析是否发送成功 //TODO:粗略解析是否发送成功
if (responseStr.contains("\"errcode\":0")) { if (responseStr.contains("\"errcode\":0")) {
LogUtil.updateLog(logId, 2, responseStr); LogUtils.updateLog(logId, 2, responseStr);
} else { } 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.alibaba.fastjson.JSON;
import com.idormy.sms.forwarder.utils.Define; 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.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
@ -151,7 +151,7 @@ public class SenderFeishuMsg extends SenderBaseMsg {
client.newCall(request).enqueue(new Callback() { client.newCall(request).enqueue(new Callback() {
@Override @Override
public void onFailure(@NonNull Call call, @NonNull final IOException e) { 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()); Toast(handError, TAG, "发送失败:" + e.getMessage());
} }
@ -163,9 +163,9 @@ public class SenderFeishuMsg extends SenderBaseMsg {
//TODO:粗略解析是否发送成功 //TODO:粗略解析是否发送成功
if (responseStr.contains("\"StatusCode\":0")) { if (responseStr.contains("\"StatusCode\":0")) {
LogUtil.updateLog(logId, 2, responseStr); LogUtils.updateLog(logId, 2, responseStr);
} else { } 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) { 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 msgTitle = jsonInnerStr(title);
String msgTime = jsonInnerStr(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()).format(date)); String msgTime = jsonInnerStr(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()).format(date));
String msgFrom = jsonInnerStr(from); 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.model.vo.GotifySettingVo;
import com.idormy.sms.forwarder.utils.CertUtils; import com.idormy.sms.forwarder.utils.CertUtils;
import com.idormy.sms.forwarder.utils.Define; 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.io.IOException;
import java.util.Objects; import java.util.Objects;
@ -58,7 +58,7 @@ public class SenderGotifyMsg extends SenderBaseMsg {
client.newCall(request).enqueue(new Callback() { client.newCall(request).enqueue(new Callback() {
@Override @Override
public void onFailure(@NonNull Call call, @NonNull final IOException e) { 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()); Toast(handError, TAG, "发送失败:" + e.getMessage());
} }
@ -70,9 +70,9 @@ public class SenderGotifyMsg extends SenderBaseMsg {
//TODO:粗略解析是否发送成功 //TODO:粗略解析是否发送成功
if (response.isSuccessful()) { if (response.isSuccessful()) {
LogUtil.updateLog(logId, 2, responseStr); LogUtils.updateLog(logId, 2, responseStr);
} else { } 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.MyApplication;
import com.idormy.sms.forwarder.R; import com.idormy.sms.forwarder.R;
import com.idormy.sms.forwarder.model.vo.EmailSettingVo; 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.Draft;
import com.smailnet.emailkit.EmailKit; import com.smailnet.emailkit.EmailKit;
@ -55,13 +55,13 @@ public class SenderMailMsg extends SenderBaseMsg {
.send(draft, new EmailKit.GetSendCallback() { .send(draft, new EmailKit.GetSendCallback() {
@Override @Override
public void onSuccess() { public void onSuccess() {
LogUtil.updateLog(logId, 2, "发送成功"); LogUtils.updateLog(logId, 2, "发送成功");
Toast(handError, TAG, "发送成功"); Toast(handError, TAG, "发送成功");
} }
@Override @Override
public void onFailure(String errMsg) { public void onFailure(String errMsg) {
LogUtil.updateLog(logId, 0, errMsg); LogUtils.updateLog(logId, 0, errMsg);
Toast(handError, TAG, "发送失败,错误:" + errMsg); Toast(handError, TAG, "发送失败,错误:" + errMsg);
} }
}); });
@ -70,7 +70,7 @@ public class SenderMailMsg extends SenderBaseMsg {
EmailKit.destroy(); EmailKit.destroy();
} catch (Exception e) { } catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage()); LogUtils.updateLog(logId, 0, e.getMessage());
Log.e(TAG, e.getMessage(), e); Log.e(TAG, e.getMessage(), e);
Toast(handError, TAG, "发送失败:" + e.getMessage()); Toast(handError, TAG, "发送失败:" + e.getMessage());
} }

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

@ -6,7 +6,7 @@ import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.idormy.sms.forwarder.utils.Define; 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.io.IOException;
import java.util.Objects; import java.util.Objects;
@ -58,7 +58,7 @@ public class SenderServerChanMsg extends SenderBaseMsg {
client.newCall(request).enqueue(new Callback() { client.newCall(request).enqueue(new Callback() {
@Override @Override
public void onFailure(@NonNull Call call, @NonNull final IOException e) { 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()); Toast(handError, TAG, "发送失败:" + e.getMessage());
} }
@ -70,9 +70,9 @@ public class SenderServerChanMsg extends SenderBaseMsg {
//TODO:粗略解析是否发送成功 //TODO:粗略解析是否发送成功
if (responseStr.contains("\"code\":0")) { if (responseStr.contains("\"code\":0")) {
LogUtil.updateLog(logId, 2, responseStr); LogUtils.updateLog(logId, 2, responseStr);
} else { } 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.os.Handler;
import android.util.Log; import android.util.Log;
import com.idormy.sms.forwarder.utils.LogUtil; import com.idormy.sms.forwarder.utils.LogUtils;
import com.idormy.sms.forwarder.utils.SimUtil; import com.idormy.sms.forwarder.utils.SimUtils;
import com.idormy.sms.forwarder.utils.SmsUtil; import com.idormy.sms.forwarder.utils.SmsUtils;
@SuppressWarnings("RedundantThrows") @SuppressWarnings("RedundantThrows")
public class SenderSmsMsg extends SenderBaseMsg { 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); Log.i(TAG, "sendMsg simSlot:" + simSlot + " mobiles:" + mobiles + " onlyNoNetwork:" + onlyNoNetwork + " from:" + from + " text:" + text);
//TODOsimSlot转subId //TODOsimSlot转subId
final int subId = SimUtil.getSubscriptionIdBySimId(simSlot); final int subId = SimUtils.getSubscriptionIdBySimId(simSlot);
String res = SmsUtil.sendSms(subId, mobiles, text); String res = SmsUtils.sendSms(subId, mobiles, text);
//TODO:粗略解析是否发送成功 //TODO:粗略解析是否发送成功
if (res == null) { if (res == null) {
LogUtil.updateLog(logId, 2, "发送成功"); LogUtils.updateLog(logId, 2, "发送成功");
} else { } else {
LogUtil.updateLog(logId, 0, res); LogUtils.updateLog(logId, 0, res);
Toast(handError, TAG, "短信发送失败"); Toast(handError, TAG, "短信发送失败");
} }

@ -9,7 +9,7 @@ import androidx.annotation.NonNull;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.idormy.sms.forwarder.model.vo.TelegramSettingVo; import com.idormy.sms.forwarder.model.vo.TelegramSettingVo;
import com.idormy.sms.forwarder.utils.Define; 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.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
@ -112,7 +112,7 @@ public class SenderTelegramMsg extends SenderBaseMsg {
client.newCall(request).enqueue(new Callback() { client.newCall(request).enqueue(new Callback() {
@Override @Override
public void onFailure(@NonNull Call call, @NonNull final IOException e) { 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()); Toast(handError, TAG, "发送失败:" + e.getMessage());
} }
@ -124,9 +124,9 @@ public class SenderTelegramMsg extends SenderBaseMsg {
//TODO:粗略解析是否发送成功 //TODO:粗略解析是否发送成功
if (responseStr.contains("\"ok\":true")) { if (responseStr.contains("\"ok\":true")) {
LogUtil.updateLog(logId, 2, responseStr); LogUtils.updateLog(logId, 2, responseStr);
} else { } 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.model.vo.SmsVo;
import com.idormy.sms.forwarder.utils.CertUtils; import com.idormy.sms.forwarder.utils.CertUtils;
import com.idormy.sms.forwarder.utils.Define; import com.idormy.sms.forwarder.utils.Define;
import com.idormy.sms.forwarder.utils.LogUtil; import com.idormy.sms.forwarder.utils.LogUtils;
import com.idormy.sms.forwarder.utils.SettingUtil; import com.idormy.sms.forwarder.utils.SettingUtils;
import java.io.IOException; import java.io.IOException;
import java.net.URLEncoder; import java.net.URLEncoder;
@ -51,8 +51,8 @@ public class SenderWebNotifyMsg extends SenderBaseMsg {
Long timestamp = System.currentTimeMillis(); Long timestamp = System.currentTimeMillis();
String orgContent = smsVo.getContent(); String orgContent = smsVo.getContent();
String deviceMark = SettingUtil.getAddExtraDeviceMark().trim(); String deviceMark = SettingUtils.getAddExtraDeviceMark().trim();
String appVersion = SettingUtil.getVersionName(); String appVersion = SettingUtils.getVersionName();
String simInfo = smsVo.getSimInfo(); String simInfo = smsVo.getSimInfo();
@SuppressLint("SimpleDateFormat") String receiveTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(smsVo.getDate()); @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() { client.newCall(requestBuilder.build()).enqueue(new Callback() {
@Override @Override
public void onFailure(@NonNull Call call, @NonNull final IOException e) { 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()); Toast(handError, TAG, "发送失败:" + e.getMessage());
} }
@ -172,9 +172,9 @@ public class SenderWebNotifyMsg extends SenderBaseMsg {
//返回http状态200即为成功 //返回http状态200即为成功
if (200 == response.code()) { if (200 == response.code()) {
LogUtil.updateLog(logId, 2, responseStr); LogUtils.updateLog(logId, 2, responseStr);
} else { } 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.model.vo.SmsVo;
import com.idormy.sms.forwarder.sender.SendUtil; import com.idormy.sms.forwarder.sender.SendUtil;
import com.idormy.sms.forwarder.utils.BatteryUtils; 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; import java.util.Date;
@ -70,26 +70,26 @@ public class BatteryService extends Service {
//电量发生变化 //电量发生变化
int levelCur = intent.getIntExtra("level", 0); int levelCur = intent.getIntExtra("level", 0);
int levelPre = SettingUtil.getBatteryLevelCurrent(); int levelPre = SettingUtils.getBatteryLevelCurrent();
if (levelCur != levelPre) { if (levelCur != levelPre) {
String msg = BatteryUtils.getBatteryInfo(intent); String msg = BatteryUtils.getBatteryInfo(intent);
SettingUtil.setBatteryLevelCurrent(levelCur); SettingUtils.setBatteryLevelCurrent(levelCur);
int levelMin = SettingUtil.getBatteryLevelAlarmMin(); int levelMin = SettingUtils.getBatteryLevelAlarmMin();
int levelMax = SettingUtil.getBatteryLevelAlarmMax(); int levelMax = SettingUtils.getBatteryLevelAlarmMax();
if (SettingUtil.getBatteryLevelAlarmOnce() && levelMin > 0 && levelPre > levelCur && levelCur <= levelMin) { //电量下降到下限 if (SettingUtils.getBatteryLevelAlarmOnce() && levelMin > 0 && levelPre > levelCur && levelCur <= levelMin) { //电量下降到下限
msg = "【电量预警】已低于电量预警下限,请及时充电!" + msg; msg = "【电量预警】已低于电量预警下限,请及时充电!" + msg;
sendMessage(context, msg); sendMessage(context, msg);
return; return;
} else if (SettingUtil.getBatteryLevelAlarmOnce() && levelMax > 0 && levelPre < levelCur && levelCur >= levelMax) { //电量上升到上限 } else if (SettingUtils.getBatteryLevelAlarmOnce() && levelMax > 0 && levelPre < levelCur && levelCur >= levelMax) { //电量上升到上限
msg = "【电量预警】已高于电量预警上限,请拔掉充电器!" + msg; msg = "【电量预警】已高于电量预警上限,请拔掉充电器!" + msg;
sendMessage(context, msg); sendMessage(context, msg);
return; return;
} else if (!SettingUtil.getBatteryLevelAlarmOnce() && levelMin > 0 && levelPre > levelCur && levelCur == levelMin) { //电量下降到下限 } else if (!SettingUtils.getBatteryLevelAlarmOnce() && levelMin > 0 && levelPre > levelCur && levelCur == levelMin) { //电量下降到下限
msg = "【电量预警】已到达电量预警下限,请及时充电!" + msg; msg = "【电量预警】已到达电量预警下限,请及时充电!" + msg;
sendMessage(context, msg); sendMessage(context, msg);
return; return;
} else if (!SettingUtil.getBatteryLevelAlarmOnce() && levelMax > 0 && levelPre < levelCur && levelCur == levelMax) { //电量上升到上限 } else if (!SettingUtils.getBatteryLevelAlarmOnce() && levelMax > 0 && levelPre < levelCur && levelCur == levelMax) { //电量上升到上限
msg = "【电量预警】已到达电量预警上限,请拔掉充电器!" + msg; msg = "【电量预警】已到达电量预警上限,请拔掉充电器!" + msg;
sendMessage(context, msg); sendMessage(context, msg);
return; return;
@ -98,11 +98,11 @@ public class BatteryService extends Service {
//充电状态改变 //充电状态改变
int status = intent.getIntExtra("status", 0); int status = intent.getIntExtra("status", 0);
if (SettingUtil.getSwitchEnableBatteryReceiver()) { if (SettingUtils.getSwitchEnableBatteryReceiver()) {
int oldStatus = SettingUtil.getBatteryStatus(); int oldStatus = SettingUtils.getBatteryStatus();
if (status != oldStatus) { if (status != oldStatus) {
String msg = BatteryUtils.getBatteryInfo(intent); String msg = BatteryUtils.getBatteryInfo(intent);
SettingUtil.setBatteryStatus(status); SettingUtils.setBatteryStatus(status);
msg = "【充电状态】发生变化:" + BatteryUtils.getStatus(oldStatus) + " → " + BatteryUtils.getStatus(status) + msg; msg = "【充电状态】发生变化:" + BatteryUtils.getStatus(oldStatus) + " → " + BatteryUtils.getStatus(status) + msg;
sendMessage(context, msg); sendMessage(context, msg);
} }

@ -6,31 +6,84 @@ import android.app.NotificationChannel;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.app.Service; import android.app.Service;
import android.content.ContextWrapper;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.os.BatteryManager;
import android.os.Build; import android.os.Build;
import android.os.IBinder; import android.os.IBinder;
import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.widget.Toast;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.lifecycle.Observer;
import com.idormy.sms.forwarder.MainActivity; import com.idormy.sms.forwarder.MainActivity;
import com.idormy.sms.forwarder.MyApplication; import com.idormy.sms.forwarder.MyApplication;
import com.idormy.sms.forwarder.R; 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.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.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 { public class FrontService extends Service {
private static final String TAG = "FrontService"; 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_ID = "com.idormy.sms.forwarder";
private static final String CHANNEL_ONE_NAME = "com.idormy.sms.forwarderName"; 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"; 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") @SuppressLint("IconColors")
@Override @Override
public void onCreate() { public void onCreate() {
@ -40,50 +93,29 @@ public class FrontService extends Service {
//是否同意隐私协议 //是否同意隐私协议
if (!MyApplication.allowPrivacyPolicy) return; if (!MyApplication.allowPrivacyPolicy) return;
Notification.Builder builder = new Notification.Builder(this); //开启通知栏
builder.setSmallIcon(R.drawable.ic_forwarder); startForeground(NOTIFY_ID, createNotification());
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);
//Android8.1以下尝试启动主界面,以便动态获取权限 //Android8.1以下尝试启动主界面,以便动态获取权限
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.O_MR1) { if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.O_MR1) {
Intent intent = new Intent(this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent); startActivity(intent);
} }
// 手机重启未打开app时主动获取SIM卡信息
//手机重启未打开app时主动获取SIM卡信息
if (MyApplication.SimInfoList.isEmpty()) { if (MyApplication.SimInfoList.isEmpty()) {
PhoneUtils.init(this); PhoneUtils.init(this);
MyApplication.SimInfoList = PhoneUtils.getSimMultiInfo(); MyApplication.SimInfoList = PhoneUtils.getSimMultiInfo();
} }
if (SettingUtil.getSwitchEnableAppNotify() && CommonUtil.isNotificationListenerServiceEnabled(this)) { //开关通知监听服务
if (SettingUtils.getSwitchEnableAppNotify() && CommonUtil.isNotificationListenerServiceEnabled(this)) {
CommonUtil.toggleNotificationListenerService(this); CommonUtil.toggleNotificationListenerService(this);
} }
//Frc内网穿透
LiveEventBus.get(INTENT_KEY_FILE, String.class).observeStickyForever(keyObserver);
} }
@Override @Override
@ -98,6 +130,8 @@ public class FrontService extends Service {
//重新开启服务 //重新开启服务
startService(intent); startService(intent);
stopForeground(true); stopForeground(true);
compositeDisposable.dispose();
} }
@Override @Override
@ -112,18 +146,32 @@ public class FrontService extends Service {
return null; return null;
} }
//获取当前电量 //创建通知栏
@SuppressLint("ObsoleteSdkInt") private Notification createNotification() {
private int getBatteryLevel() { Notification.Builder builder = new Notification.Builder(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder.setSmallIcon(R.drawable.ic_forwarder);
BatteryManager batteryManager = (BatteryManager) getSystemService(BATTERY_SERVICE); builder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher));
return batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY); if (OSUtils.isMIUI()) {
} else { builder.setContentTitle(getString(R.string.app_name));
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);
} }
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.model.vo.SmsVo;
import com.idormy.sms.forwarder.sender.SendUtil; import com.idormy.sms.forwarder.sender.SendUtil;
import com.idormy.sms.forwarder.utils.CommonUtil; 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.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
@ -35,13 +35,13 @@ public class NotifyService extends NotificationListenerService {
if (!MyApplication.allowPrivacyPolicy) return; if (!MyApplication.allowPrivacyPolicy) return;
//未开启转发 //未开启转发
if (!SettingUtil.getSwitchEnableAppNotify()) return; if (!SettingUtils.getSwitchEnableAppNotify()) return;
//异常通知跳过 //异常通知跳过
if (sbn.getNotification() == null) return; if (sbn.getNotification() == null) return;
if (sbn.getNotification().extras == null) return; if (sbn.getNotification().extras == null) return;
//仅锁屏状态转发APP通知 //仅锁屏状态转发APP通知
if (SettingUtil.getSwitchNotUserPresent() && MyApplication.isUserPresent) return; if (SettingUtils.getSwitchNotUserPresent() && MyApplication.isUserPresent) return;
//推送通知的应用包名 //推送通知的应用包名
String packageName = sbn.getPackageName(); String packageName = sbn.getPackageName();
@ -74,20 +74,20 @@ public class NotifyService extends NotificationListenerService {
); );
//自动关闭通知 //自动关闭通知
if (SettingUtil.getSwitchCancelAppNotify()) { if (SettingUtils.getSwitchCancelAppNotify()) {
String key = sbn.getKey(); String key = sbn.getKey();
cancelNotification(key); cancelNotification(key);
} }
//重复通知不再处理 //重复通知不再处理
String prevHash = SettingUtil.getPrevNoticeHash(packageName); String prevHash = SettingUtils.getPrevNoticeHash(packageName);
String currHash = CommonUtil.MD5(packageName + title + text + time); String currHash = CommonUtil.MD5(packageName + title + text + time);
Log.d(TAG, "prevHash=" + prevHash + " currHash=" + currHash); Log.d(TAG, "prevHash=" + prevHash + " currHash=" + currHash);
if (prevHash != null && prevHash.equals(currHash)) { if (prevHash != null && prevHash.equals(currHash)) {
Log.w(TAG, "重复通知不再处理"); Log.w(TAG, "重复通知不再处理");
return; return;
} }
SettingUtil.setPrevNoticeHash(packageName, currHash); SettingUtils.setPrevNoticeHash(packageName, currHash);
SmsVo smsVo = new SmsVo(packageName, text, new Date(), title); SmsVo smsVo = new SmsVo(packageName, text, new Date(), title);
Log.d(TAG, "send_msg" + smsVo); Log.d(TAG, "send_msg" + smsVo);
@ -106,7 +106,7 @@ public class NotifyService extends NotificationListenerService {
@Override @Override
public void onNotificationRemoved(StatusBarNotification sbn) { public void onNotificationRemoved(StatusBarNotification sbn) {
//未开启转发 //未开启转发
if (!SettingUtil.getSwitchEnableAppNotify()) return; if (!SettingUtils.getSwitchEnableAppNotify()) return;
//异常通知跳过 //异常通知跳过
if (sbn.getNotification() == null) return; if (sbn.getNotification() == null) return;
@ -119,7 +119,7 @@ public class NotifyService extends NotificationListenerService {
@Override @Override
public void onListenerDisconnected() { public void onListenerDisconnected() {
//未开启转发 //未开启转发
if (!SettingUtil.getSwitchEnableAppNotify()) return; if (!SettingUtils.getSwitchEnableAppNotify()) return;
Log.d(TAG, "通知侦听器断开连接 - 请求重新绑定"); Log.d(TAG, "通知侦听器断开连接 - 请求重新绑定");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {

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

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

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

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

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

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

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

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

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

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

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

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

@ -8,7 +8,7 @@ import java.util.Date;
import java.util.Locale; import java.util.Locale;
import java.util.TimeZone; import java.util.TimeZone;
public class TimeUtil { public class TimeUtils {
//友好时间显示 //友好时间显示
public static String friendlyTime(String utcTime) { 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; 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.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
@ -15,6 +15,8 @@ import android.widget.ListView;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import com.idormy.sms.forwarder.R;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Locale; 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.SenderActivity;
import com.idormy.sms.forwarder.SettingActivity; import com.idormy.sms.forwarder.SettingActivity;
import com.idormy.sms.forwarder.sender.SenderUtil; import com.idormy.sms.forwarder.sender.SenderUtil;
import com.idormy.sms.forwarder.utils.LogUtil; import com.idormy.sms.forwarder.utils.LogUtils;
import com.idormy.sms.forwarder.utils.RuleUtil; import com.idormy.sms.forwarder.utils.RuleUtils;
import com.idormy.sms.forwarder.utils.SettingUtil; import com.idormy.sms.forwarder.utils.SettingUtils;
@SuppressWarnings("FieldCanBeLocal") @SuppressWarnings("FieldCanBeLocal")
public class StepBar extends LinearLayout { public class StepBar extends LinearLayout {
@ -165,15 +165,15 @@ public class StepBar extends LinearLayout {
@SuppressLint("UseCompatLoadingForDrawables") @SuppressLint("UseCompatLoadingForDrawables")
public void setHighlight() { public void setHighlight() {
SettingUtil.init(mContext); SettingUtils.init(mContext);
SenderUtil.init(mContext); SenderUtil.init(mContext);
RuleUtil.init(mContext); RuleUtils.init(mContext);
LogUtil.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 Step2 = SenderUtil.countSender("1", null) > 0;
boolean Step3 = RuleUtil.countRule("1", null, null) > 0; boolean Step3 = RuleUtils.countRule("1", null, null) > 0;
boolean Step4 = LogUtil.countLog("2", null, null) > 0; boolean Step4 = LogUtils.countLog("2", null, null) > 0;
//页面提示文本 //页面提示文本
if (txHelpTip != null) { if (txHelpTip != null) {

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

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

Loading…
Cancel
Save