mirror of
https://github.com/pppscn/SmsForwarder
synced 2025-08-03 01:17:41 +08:00
优化:电池状态监听(剩余电量预警上下限,电池状态改变)
This commit is contained in:
parent
0470e4d6ff
commit
cdeed5cfc3
@ -23,6 +23,7 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.idormy.sms.forwarder.adapter.LogAdapter;
|
||||
import com.idormy.sms.forwarder.model.vo.LogVo;
|
||||
import com.idormy.sms.forwarder.service.BatteryService;
|
||||
import com.idormy.sms.forwarder.service.FrontService;
|
||||
import com.idormy.sms.forwarder.utils.CommonUtil;
|
||||
import com.idormy.sms.forwarder.utils.KeepAliveUtils;
|
||||
@ -74,7 +75,16 @@ public class MainActivity extends AppCompatActivity implements RefreshListView.I
|
||||
serviceIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startService(serviceIntent);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "onCreate:", e);
|
||||
Log.e(TAG, "FrontService:", e);
|
||||
}
|
||||
|
||||
//监听电池状态
|
||||
try {
|
||||
Intent batteryServiceIntent = new Intent(this, BatteryService.class);
|
||||
batteryServiceIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startService(batteryServiceIntent);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "BatteryService:", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -162,7 +172,7 @@ public class MainActivity extends AppCompatActivity implements RefreshListView.I
|
||||
Log.d(TAG, "SimInfoList = " + MyApplication.SimInfoList.size());
|
||||
|
||||
//省电优化设置为无限制
|
||||
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
||||
if (MyApplication.showHelpTip && Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
||||
if (!KeepAliveUtils.isIgnoreBatteryOptimization(this)) {
|
||||
Toast.makeText(this, R.string.tips_battery_optimization, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import com.idormy.sms.forwarder.sender.SendHistory;
|
||||
import com.idormy.sms.forwarder.service.BatteryService;
|
||||
import com.idormy.sms.forwarder.service.FrontService;
|
||||
import com.idormy.sms.forwarder.utils.CommonUtil;
|
||||
import com.idormy.sms.forwarder.utils.Define;
|
||||
@ -47,12 +48,14 @@ public class MyApplication extends Application {
|
||||
//pro close log
|
||||
UMConfigure.setLogEnabled(true);
|
||||
|
||||
//前台服务
|
||||
Intent intent = new Intent(this, FrontService.class);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
startForegroundService(intent);
|
||||
} else {
|
||||
startService(intent);
|
||||
}
|
||||
|
||||
SendHistory.init(this);
|
||||
SettingUtil.init(this);
|
||||
|
||||
@ -70,6 +73,10 @@ public class MyApplication extends Application {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//电池状态监听
|
||||
Intent batteryServiceIntent = new Intent(this, BatteryService.class);
|
||||
startService(batteryServiceIntent);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "onCreate:", e);
|
||||
}
|
||||
|
@ -49,8 +49,10 @@ public class SettingActivity extends AppCompatActivity {
|
||||
EditText et_add_extra_sim2 = findViewById(R.id.et_add_extra_sim2);
|
||||
editAddExtraSim2(et_add_extra_sim2);
|
||||
|
||||
EditText et_battery_level_alarm = findViewById(R.id.et_battery_level_alarm);
|
||||
editBatteryLevelAlarm(et_battery_level_alarm);
|
||||
EditText et_battery_level_alarm_min = findViewById(R.id.et_battery_level_alarm_min);
|
||||
editBatteryLevelAlarmMin(et_battery_level_alarm_min);
|
||||
EditText et_battery_level_alarm_max = findViewById(R.id.et_battery_level_alarm_max);
|
||||
editBatteryLevelAlarmMax(et_battery_level_alarm_max);
|
||||
|
||||
EditText et_retry_delay_time1 = findViewById(R.id.et_retry_delay_time1);
|
||||
editRetryDelayTime(et_retry_delay_time1, 1);
|
||||
@ -78,6 +80,9 @@ public class SettingActivity extends AppCompatActivity {
|
||||
@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_exclude_from_recents = findViewById(R.id.switch_exclude_from_recents);
|
||||
switchExcludeFromRecents(switch_exclude_from_recents);
|
||||
|
||||
@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_battery_receiver = findViewById(R.id.switch_battery_receiver);
|
||||
switchBatteryReceiver(switch_battery_receiver);
|
||||
|
||||
EditText textSmsTemplate = findViewById(R.id.text_sms_template);
|
||||
editSmsTemplate(textSmsTemplate);
|
||||
}
|
||||
@ -104,6 +109,17 @@ public class SettingActivity extends AppCompatActivity {
|
||||
});
|
||||
}
|
||||
|
||||
//监听电池状态变化
|
||||
private void switchBatteryReceiver(@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_battery_receiver) {
|
||||
switch_battery_receiver.setChecked(SettingUtil.getSwitchEnableBatteryReceiver());
|
||||
|
||||
switch_battery_receiver.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
//TODO:校验使用来电转发必备的权限
|
||||
SettingUtil.switchEnableBatteryReceiver(isChecked);
|
||||
Log.d(TAG, "switchEnablePhone:" + isChecked);
|
||||
});
|
||||
}
|
||||
|
||||
//设置转发APP通知
|
||||
private void switchEnableAppNotify(@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_enable_app_notify) {
|
||||
switch_enable_app_notify.setChecked(SettingUtil.getSwitchEnableAppNotify());
|
||||
@ -205,9 +221,9 @@ public class SettingActivity extends AppCompatActivity {
|
||||
});
|
||||
}
|
||||
|
||||
//设置低电量报警值
|
||||
private void editBatteryLevelAlarm(final EditText et_battery_level_alarm) {
|
||||
et_battery_level_alarm.setText(String.valueOf(SettingUtil.getBatteryLevelAlarm()));
|
||||
//设置低电量报警值下限
|
||||
private void editBatteryLevelAlarmMin(final EditText et_battery_level_alarm) {
|
||||
et_battery_level_alarm.setText(String.valueOf(SettingUtil.getBatteryLevelAlarmMin()));
|
||||
|
||||
et_battery_level_alarm.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
@ -222,9 +238,34 @@ public class SettingActivity extends AppCompatActivity {
|
||||
public void afterTextChanged(Editable s) {
|
||||
String batteryLevel = et_battery_level_alarm.getText().toString().trim();
|
||||
if (!batteryLevel.isEmpty()) {
|
||||
SettingUtil.setBatteryLevelAlarm(Integer.parseInt(batteryLevel));
|
||||
SettingUtil.setBatteryLevelAlarmMin(Integer.parseInt(batteryLevel));
|
||||
} else {
|
||||
SettingUtil.setBatteryLevelAlarm(0);
|
||||
SettingUtil.setBatteryLevelAlarmMin(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//设置低电量报警值上限
|
||||
private void editBatteryLevelAlarmMax(final EditText et_battery_level_alarm) {
|
||||
et_battery_level_alarm.setText(String.valueOf(SettingUtil.getBatteryLevelAlarmMax()));
|
||||
|
||||
et_battery_level_alarm.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
String batteryLevel = et_battery_level_alarm.getText().toString().trim();
|
||||
if (!batteryLevel.isEmpty()) {
|
||||
SettingUtil.setBatteryLevelAlarmMax(Integer.parseInt(batteryLevel));
|
||||
} else {
|
||||
SettingUtil.setBatteryLevelAlarmMax(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -17,7 +17,7 @@ import java.util.regex.PatternSyntaxException;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@SuppressWarnings({"unused", "SpellCheckingInspection"})
|
||||
@SuppressWarnings({"unused"})
|
||||
@Data
|
||||
public class RuleModel {
|
||||
public static final String FILED_TRANSPOND_ALL = "transpond_all";
|
||||
|
@ -9,7 +9,6 @@ public final class RuleTable {
|
||||
}
|
||||
|
||||
/* Inner class that defines the table contents */
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
public static class RuleEntry implements BaseColumns {
|
||||
public static final String TABLE_NAME = "rule";
|
||||
public static final String COLUMN_NAME_TYPE = "type";
|
||||
|
@ -6,6 +6,7 @@ import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import com.idormy.sms.forwarder.service.BatteryService;
|
||||
import com.idormy.sms.forwarder.service.FrontService;
|
||||
import com.idormy.sms.forwarder.utils.InitUtil;
|
||||
|
||||
@ -18,12 +19,18 @@ public class RebootBroadcastReceiver extends BroadcastReceiver {
|
||||
Log.d(TAG, "onReceive intent " + receiveAction);
|
||||
if (receiveAction.equals("android.intent.action.BOOT_COMPLETED")) {
|
||||
InitUtil.init(context);
|
||||
|
||||
//前台服务
|
||||
Intent frontServiceIntent = new Intent(context, FrontService.class);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
context.startForegroundService(frontServiceIntent);
|
||||
} else {
|
||||
context.startService(frontServiceIntent);
|
||||
}
|
||||
|
||||
//电池状态监听
|
||||
Intent batteryServiceIntent = new Intent(context, BatteryService.class);
|
||||
context.startService(batteryServiceIntent);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
|
||||
@SuppressWarnings({"ResultOfMethodCallIgnored", "rawtypes", "unchecked", "deprecation", "SpellCheckingInspection"})
|
||||
@SuppressWarnings({"ResultOfMethodCallIgnored", "rawtypes", "unchecked", "deprecation"})
|
||||
public class SenderDingdingMsg extends SenderBaseMsg {
|
||||
|
||||
static final String TAG = "SenderDingdingMsg";
|
||||
|
@ -10,7 +10,11 @@ import android.os.BatteryManager;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import com.idormy.sms.forwarder.model.vo.SmsVo;
|
||||
import com.idormy.sms.forwarder.sender.SendUtil;
|
||||
import com.idormy.sms.forwarder.utils.SettingUtil;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BatteryService extends Service {
|
||||
@ -26,9 +30,9 @@ public class BatteryService extends Service {
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
Log.i(TAG, "onCreate--------------");
|
||||
IntentFilter batteryFilter = new IntentFilter();
|
||||
batteryFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
||||
registerReceiver(batteryReceiver, batteryFilter);
|
||||
IntentFilter batteryfilter = new IntentFilter();
|
||||
batteryfilter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
||||
registerReceiver(batteryReceiver, batteryfilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -39,7 +43,7 @@ public class BatteryService extends Service {
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
Log.i(TAG, "onStartCommand--------------");
|
||||
return Service.START_STICKY; //保证service不被杀死
|
||||
return Service.START_STICKY; //
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -51,7 +55,7 @@ public class BatteryService extends Service {
|
||||
|
||||
// 接收电池信息更新的广播
|
||||
private final BroadcastReceiver batteryReceiver = new BroadcastReceiver() {
|
||||
@SuppressWarnings("unused")
|
||||
@SuppressLint("DefaultLocale")
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.i(TAG, "BatteryReceiver--------------");
|
||||
@ -60,50 +64,121 @@ public class BatteryService extends Service {
|
||||
Log.i(TAG, "ACTION_BATTERY_CHANGED");
|
||||
int status = intent.getIntExtra("status", 0);
|
||||
int health = intent.getIntExtra("health", 0);
|
||||
boolean present = intent.getBooleanExtra("present", false);
|
||||
int level = intent.getIntExtra("level", 0);
|
||||
//boolean present = intent.getBooleanExtra("present", false);
|
||||
int levelCur = intent.getIntExtra("level", 0);
|
||||
int scale = intent.getIntExtra("scale", 0);
|
||||
int icon_small = intent.getIntExtra("icon-small", 0);
|
||||
//int icon_small = intent.getIntExtra("icon-small", 0);
|
||||
int plugged = intent.getIntExtra("plugged", 0);
|
||||
int voltage = intent.getIntExtra("voltage", 0);
|
||||
int temperature = intent.getIntExtra("temperature", 0);
|
||||
String technology = intent.getStringExtra("technology");
|
||||
//String technology = intent.getStringExtra("technology");
|
||||
|
||||
String statusString = "";
|
||||
switch (status) {
|
||||
case BatteryManager.BATTERY_STATUS_UNKNOWN:
|
||||
statusString = "unknown";
|
||||
break;
|
||||
case BatteryManager.BATTERY_STATUS_CHARGING:
|
||||
statusString = "charging";
|
||||
break;
|
||||
case BatteryManager.BATTERY_STATUS_DISCHARGING:
|
||||
statusString = "discharging";
|
||||
break;
|
||||
case BatteryManager.BATTERY_STATUS_NOT_CHARGING:
|
||||
statusString = "not charging";
|
||||
break;
|
||||
case BatteryManager.BATTERY_STATUS_FULL:
|
||||
statusString = "full";
|
||||
break;
|
||||
}
|
||||
String acString = "";
|
||||
String msg = "";
|
||||
msg += "\n剩余电量:" + levelCur + "%";
|
||||
|
||||
if (scale > 0) msg += "\n充满电量:" + scale + "%";
|
||||
|
||||
if (voltage > 0) msg += "\n当前电压:" + String.format("%.2f", voltage / 1000F) + "V";
|
||||
|
||||
if (temperature > 0) msg += "\n当前温度:" + String.format("%.2f", temperature / 10F) + "℃";
|
||||
|
||||
msg += "\n电池状态:" + getStatus(status);
|
||||
|
||||
if (health > 0) msg += "\n健康度:" + getHealth(health);
|
||||
|
||||
switch (plugged) {
|
||||
case BatteryManager.BATTERY_PLUGGED_AC:
|
||||
acString = "plugged ac";
|
||||
msg += "\n充电器:AC";
|
||||
break;
|
||||
case BatteryManager.BATTERY_PLUGGED_USB:
|
||||
acString = "plugged usb";
|
||||
msg += "\n充电器:USB";
|
||||
break;
|
||||
case BatteryManager.BATTERY_PLUGGED_WIRELESS:
|
||||
msg += "\n充电器:无线";
|
||||
break;
|
||||
}
|
||||
|
||||
@SuppressLint("SimpleDateFormat") SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss:SSS ");
|
||||
String date = sDateFormat.format(new java.util.Date());
|
||||
Log.i(TAG, msg);
|
||||
|
||||
Log.i(TAG, "battery: date=" + date + ",status " + statusString
|
||||
+ ",level=" + level + ",scale=" + scale
|
||||
+ ",voltage=" + voltage + ",acString=" + acString);
|
||||
//电量发生变化
|
||||
int levelPre = SettingUtil.getBatteryLevelCurrent();
|
||||
if (levelCur != levelPre) {
|
||||
SettingUtil.setBatteryLevelCurrent(levelCur);
|
||||
|
||||
int levelMin = SettingUtil.getBatteryLevelAlarmMin();
|
||||
int levelMax = SettingUtil.getBatteryLevelAlarmMax();
|
||||
if (levelMin > 0 && levelPre > levelCur && levelCur <= levelMin) { //电量下降到下限
|
||||
msg = "【电量预警】已到达电量预警下限,请及时充电!" + msg;
|
||||
sendMessage(context, msg);
|
||||
return;
|
||||
} else if (levelMax > 0 && levelPre < levelCur && levelCur >= levelMax) { //电量上升到上限
|
||||
msg = "【电量预警】已到达电量预警上限,请拔掉充电器!" + msg;
|
||||
sendMessage(context, msg);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//充电状态改变
|
||||
if (SettingUtil.getSwitchEnableBatteryReceiver()) {
|
||||
int oldStatus = SettingUtil.getBatteryStatus();
|
||||
if (status != oldStatus) {
|
||||
SettingUtil.setBatteryStatus(status);
|
||||
msg = "【充电状态】发生变化:" + getStatus(oldStatus) + " → " + getStatus(status) + msg;
|
||||
sendMessage(context, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
//电池状态
|
||||
private String getStatus(int status) {
|
||||
switch (status) {
|
||||
case BatteryManager.BATTERY_STATUS_CHARGING:
|
||||
return "充电中";
|
||||
case BatteryManager.BATTERY_STATUS_DISCHARGING:
|
||||
return "放电中";
|
||||
case BatteryManager.BATTERY_STATUS_NOT_CHARGING:
|
||||
return "未充电";
|
||||
case BatteryManager.BATTERY_STATUS_FULL:
|
||||
return "充满电";
|
||||
case BatteryManager.BATTERY_STATUS_UNKNOWN:
|
||||
default:
|
||||
return "未知";
|
||||
}
|
||||
}
|
||||
|
||||
//健康度
|
||||
private String getHealth(int health) {
|
||||
switch (health) {
|
||||
case 2:
|
||||
return "良好";
|
||||
case 3:
|
||||
return "过热";
|
||||
case 4:
|
||||
return "没电";
|
||||
case 5:
|
||||
return "过电压";
|
||||
case 6:
|
||||
return "未知错误";
|
||||
case 7:
|
||||
return "温度过低";
|
||||
default:
|
||||
case 1:
|
||||
return "未知";
|
||||
}
|
||||
}
|
||||
|
||||
//发送信息
|
||||
private void sendMessage(Context context, String msg) {
|
||||
Log.i(TAG, msg);
|
||||
try {
|
||||
SmsVo smsVo = new SmsVo("88888888", msg, new Date(), "电池状态监听");
|
||||
Log.d(TAG, "send_msg" + smsVo.toString());
|
||||
SendUtil.send_msg(context, smsVo, 1, "app");
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "getLog e:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -6,7 +6,6 @@ import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
@ -21,18 +20,11 @@ import androidx.annotation.Nullable;
|
||||
import com.idormy.sms.forwarder.MainActivity;
|
||||
import com.idormy.sms.forwarder.MyApplication;
|
||||
import com.idormy.sms.forwarder.R;
|
||||
import com.idormy.sms.forwarder.model.vo.SmsVo;
|
||||
import com.idormy.sms.forwarder.sender.SendUtil;
|
||||
import com.idormy.sms.forwarder.sender.SenderUtil;
|
||||
import com.idormy.sms.forwarder.utils.CommonUtil;
|
||||
import com.idormy.sms.forwarder.utils.OSUtil;
|
||||
import com.idormy.sms.forwarder.utils.PhoneUtils;
|
||||
import com.idormy.sms.forwarder.utils.SettingUtil;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class FrontService extends Service {
|
||||
private static final String TAG = "FrontService";
|
||||
private static final String CHANNEL_ONE_ID = "com.idormy.sms.forwarder";
|
||||
@ -84,36 +76,6 @@ public class FrontService extends Service {
|
||||
MyApplication.SimInfoList = PhoneUtils.getSimMultiInfo();
|
||||
}
|
||||
|
||||
// 低电量预警
|
||||
final int[] alarmTimes = {0}; //通知次数,只通知2次
|
||||
Context context1 = this;
|
||||
SenderUtil.init(context1);
|
||||
new Timer().schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
int batteryLevel = getBatteryLevel();
|
||||
//System.out.println("当前剩余电量:" + batteryLevel + "%");
|
||||
int batteryLevelAlarm = SettingUtil.getBatteryLevelAlarm();
|
||||
if (alarmTimes[0] <= 1 && batteryLevelAlarm > 0 && batteryLevelAlarm <= 100 && (batteryLevel == batteryLevelAlarm || batteryLevel == batteryLevelAlarm - 1)) {
|
||||
try {
|
||||
alarmTimes[0] = alarmTimes[0] + 1;
|
||||
SmsVo smsVo = new SmsVo("88888888",
|
||||
"当前剩余电量:" + batteryLevel + "%,已经到达低电量预警阈值,请及时充电!",
|
||||
new Date(),
|
||||
"低电量预警");
|
||||
Log.d(TAG, "send_msg" + smsVo.toString());
|
||||
SendUtil.send_msg(context1, smsVo, 1, "app");
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "getLog e:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (batteryLevelAlarm > 0 && batteryLevelAlarm <= 100 && batteryLevel > batteryLevelAlarm) {
|
||||
alarmTimes[0] = 0;
|
||||
}
|
||||
}
|
||||
}, 0, 10000);
|
||||
|
||||
if (SettingUtil.getSwitchEnableAppNotify() && CommonUtil.isNotificationListenerServiceEnabled(this)) {
|
||||
CommonUtil.toggleNotificationListenerService(this);
|
||||
}
|
||||
|
@ -15,7 +15,11 @@ public class Define {
|
||||
public static final String SP_MSG_KEY_STRING_ADD_EXTRA_SIM2 = "tsms_msg_key_string_add_extra_sim2";
|
||||
public static final String SP_MSG_KEY_SWITCH_SMS_TEMPLATE = "tsms_msg_key_switch_sms_template";
|
||||
public static final String SP_MSG_KEY_STRING_SMS_TEMPLATE = "tsms_msg_key_string_sms_template";
|
||||
public static final String SP_MSG_KEY_STRING_BATTERY_STATUS = "tsms_msg_key_string_battery_status";
|
||||
public static final String SP_MSG_KEY_STRING_BATTERY_RECEIVER = "tsms_msg_key_switch_battery_receiver";
|
||||
public static final String SP_MSG_KEY_STRING_BATTERY_LEVEL_CURRENT = "tsms_msg_key_string_battery_level_current";
|
||||
public static final String SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM = "tsms_msg_key_string_battery_level_alarm";
|
||||
public static final String SP_MSG_KEY_STRING_BATTERY_LEVEL_MAX = "tsms_msg_key_string_battery_level_max";
|
||||
public static final String SP_MSG_KEY_STRING_RETRY_DELAY_TIME1 = "tsms_msg_key_string_retry_delay_time1";
|
||||
public static final String SP_MSG_KEY_STRING_RETRY_DELAY_TIME2 = "tsms_msg_key_string_retry_delay_time2";
|
||||
public static final String SP_MSG_KEY_STRING_RETRY_DELAY_TIME3 = "tsms_msg_key_string_retry_delay_time3";
|
||||
|
@ -31,7 +31,7 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@SuppressWarnings({"deprecation", "rawtypes", "unchecked", "CommentedOutCode", "SynchronizeOnNonFinalField", "unused", "SameReturnValue", "SpellCheckingInspection"})
|
||||
@SuppressWarnings({"deprecation", "rawtypes", "unchecked", "CommentedOutCode", "SynchronizeOnNonFinalField", "unused", "SameReturnValue"})
|
||||
public class PhoneUtils {
|
||||
static Boolean hasInit = false;
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
|
@ -12,7 +12,7 @@ import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
@SuppressWarnings({"unused", "SpellCheckingInspection"})
|
||||
@SuppressWarnings({"unused"})
|
||||
class RuleLine {
|
||||
public static final String CONJUNCTION_AND = "并且";
|
||||
public static final String CONJUNCTION_OR = "或者";
|
||||
|
@ -78,6 +78,16 @@ public class SettingUtil {
|
||||
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_APP_NOTIFY, false);
|
||||
}
|
||||
|
||||
public static void switchEnableBatteryReceiver(Boolean enable) {
|
||||
sp_setting.edit()
|
||||
.putBoolean(Define.SP_MSG_KEY_STRING_BATTERY_RECEIVER, enable)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static boolean getSwitchEnableBatteryReceiver() {
|
||||
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_BATTERY_RECEIVER, false);
|
||||
}
|
||||
|
||||
public static void switchExcludeFromRecents(Boolean enable) {
|
||||
sp_setting.edit()
|
||||
.putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_EXCLUDE_FROM_RECENTS, enable)
|
||||
@ -155,17 +165,50 @@ public class SettingUtil {
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static int getBatteryLevelAlarm() {
|
||||
public static int getBatteryLevelAlarmMin() {
|
||||
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM, 0);
|
||||
}
|
||||
|
||||
public static void setBatteryLevelAlarm(int battery_level) {
|
||||
public static void setBatteryLevelAlarmMin(int battery_level) {
|
||||
Log.d(TAG, "battery_level :" + battery_level);
|
||||
sp_setting.edit()
|
||||
.putInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM, battery_level)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static int getBatteryLevelAlarmMax() {
|
||||
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_MAX, 0);
|
||||
}
|
||||
|
||||
public static void setBatteryLevelAlarmMax(int battery_level) {
|
||||
Log.d(TAG, "battery_level :" + battery_level);
|
||||
sp_setting.edit()
|
||||
.putInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_MAX, battery_level)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static int getBatteryLevelCurrent() {
|
||||
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_CURRENT, 0);
|
||||
}
|
||||
|
||||
public static void setBatteryLevelCurrent(int battery_level) {
|
||||
Log.d(TAG, "battery_level :" + battery_level);
|
||||
sp_setting.edit()
|
||||
.putInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_CURRENT, battery_level)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static int getBatteryStatus() {
|
||||
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_BATTERY_STATUS, 0);
|
||||
}
|
||||
|
||||
public static void setBatteryStatus(int battery_status) {
|
||||
Log.d(TAG, "battery_status :" + battery_status);
|
||||
sp_setting.edit()
|
||||
.putInt(Define.SP_MSG_KEY_STRING_BATTERY_STATUS, battery_status)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static boolean saveMsgHistory() {
|
||||
return !sp_setting.getBoolean("option_save_history_on", false);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -248,4 +248,10 @@
|
||||
<string name="account">✱Account</string>
|
||||
<string name="servers">✱Servers</string>
|
||||
<string name="email">✱Email</string>
|
||||
<string name="below">below</string>
|
||||
<string name="percent">%</string>
|
||||
<string name="above">above</string>
|
||||
<string name="zero">0</string>
|
||||
<string name="monitor_battery_status_changes">Monitor battery status changes</string>
|
||||
<string name="battery_status_changes_tips">Notify when charging status changes (charging/discharging/uncharged/fully charged)</string>
|
||||
</resources>
|
||||
|
@ -159,8 +159,8 @@
|
||||
<string name="sim1_remark" tools:ignore="Typos">SIM1备注</string>
|
||||
<string name="sim2_remark" tools:ignore="Typos">SIM2备注</string>
|
||||
<string name="carrier_mobile">运营商_手机号</string>
|
||||
<string name="low_power_alarm_threshold">低电量预警阈值(%)</string>
|
||||
<string name="low_power_alarm_threshold_tips">取值范围:0–100,留空或0禁用</string>
|
||||
<string name="low_power_alarm_threshold">电量预警阈值(%)</string>
|
||||
<string name="low_power_alarm_threshold_tips">取值范围:0–100,0禁用</string>
|
||||
<string name="retry_interval">每次重试间隔(秒)</string>
|
||||
<string name="retry_interval_tips">接口请求失败后将重试5次</string>
|
||||
<string name="forward_sms">转发短信广播</string>
|
||||
@ -247,4 +247,10 @@
|
||||
<string name="account">✱帐户管理</string>
|
||||
<string name="servers">✱服务器信息</string>
|
||||
<string name="email">✱邮件设置</string>
|
||||
<string name="below">低于</string>
|
||||
<string name="percent">%</string>
|
||||
<string name="above">高于</string>
|
||||
<string name="zero">0</string>
|
||||
<string name="monitor_battery_status_changes">监听电池状态变化</string>
|
||||
<string name="battery_status_changes_tips">充电状态改变(充电中/放电中/未充电/已充满)时发出通知</string>
|
||||
</resources>
|
||||
|
@ -1,3 +1,3 @@
|
||||
#Fri Jul 16 10:33:23 CST 2021
|
||||
versionName=2.2.1
|
||||
versionCode=31
|
||||
versionName=2.3.0
|
||||
versionCode=32
|
||||
|
Loading…
x
Reference in New Issue
Block a user