mirror of
https://github.com/pppscn/SmsForwarder
synced 2024-11-08 01:10:23 +00:00
新增:{{IP_LIST}}
变量标签用于获取本机所有IP地址列表
(排除环回地址) #I9CVLZ
This commit is contained in:
parent
a53fa6db12
commit
866f90831f
@ -105,6 +105,7 @@ data class MsgInfo(
|
|||||||
)
|
)
|
||||||
.replaceTag(getString(R.string.tag_ipv4), TaskUtils.ipv4, needJson)
|
.replaceTag(getString(R.string.tag_ipv4), TaskUtils.ipv4, needJson)
|
||||||
.replaceTag(getString(R.string.tag_ipv6), TaskUtils.ipv6, needJson)
|
.replaceTag(getString(R.string.tag_ipv6), TaskUtils.ipv6, needJson)
|
||||||
|
.replaceTag(getString(R.string.tag_ip_list), TaskUtils.ipList, needJson)
|
||||||
.replaceTag(getString(R.string.tag_battery_pct), "%.0f%%".format(TaskUtils.batteryPct), needJson)
|
.replaceTag(getString(R.string.tag_battery_pct), "%.0f%%".format(TaskUtils.batteryPct), needJson)
|
||||||
.replaceTag(getString(R.string.tag_battery_status), BatteryUtils.getStatus(TaskUtils.batteryStatus), needJson)
|
.replaceTag(getString(R.string.tag_battery_status), BatteryUtils.getStatus(TaskUtils.batteryStatus), needJson)
|
||||||
.replaceTag(getString(R.string.tag_battery_plugged), BatteryUtils.getPlugged(TaskUtils.batteryPlugged), needJson)
|
.replaceTag(getString(R.string.tag_battery_plugged), BatteryUtils.getPlugged(TaskUtils.batteryPlugged), needJson)
|
||||||
|
@ -278,6 +278,7 @@ const val SP_DATA_SIM_SLOT = "data_sim_slot"
|
|||||||
const val SP_WIFI_SSID = "wifi_ssid"
|
const val SP_WIFI_SSID = "wifi_ssid"
|
||||||
const val SP_IPV4 = "ipv4"
|
const val SP_IPV4 = "ipv4"
|
||||||
const val SP_IPV6 = "ipv6"
|
const val SP_IPV6 = "ipv6"
|
||||||
|
const val SP_IP_LIST = "ip_list"
|
||||||
const val SP_SIM_STATE = "sim_state"
|
const val SP_SIM_STATE = "sim_state"
|
||||||
const val SP_LOCATION_INFO_OLD = "location_info_old"
|
const val SP_LOCATION_INFO_OLD = "location_info_old"
|
||||||
const val SP_LOCATION_INFO_NEW = "location_info_new"
|
const val SP_LOCATION_INFO_NEW = "location_info_new"
|
||||||
|
@ -15,6 +15,7 @@ import com.idormy.sms.forwarder.utils.SP_DATA_SIM_SLOT
|
|||||||
import com.idormy.sms.forwarder.utils.SP_DISCOVERED_DEVICES
|
import com.idormy.sms.forwarder.utils.SP_DISCOVERED_DEVICES
|
||||||
import com.idormy.sms.forwarder.utils.SP_IPV4
|
import com.idormy.sms.forwarder.utils.SP_IPV4
|
||||||
import com.idormy.sms.forwarder.utils.SP_IPV6
|
import com.idormy.sms.forwarder.utils.SP_IPV6
|
||||||
|
import com.idormy.sms.forwarder.utils.SP_IP_LIST
|
||||||
import com.idormy.sms.forwarder.utils.SP_LOCATION_INFO_NEW
|
import com.idormy.sms.forwarder.utils.SP_LOCATION_INFO_NEW
|
||||||
import com.idormy.sms.forwarder.utils.SP_LOCATION_INFO_OLD
|
import com.idormy.sms.forwarder.utils.SP_LOCATION_INFO_OLD
|
||||||
import com.idormy.sms.forwarder.utils.SP_LOCK_SCREEN_ACTION
|
import com.idormy.sms.forwarder.utils.SP_LOCK_SCREEN_ACTION
|
||||||
@ -143,6 +144,9 @@ class TaskUtils private constructor() {
|
|||||||
//IPv6地址
|
//IPv6地址
|
||||||
var ipv6: String by SharedPreference(SP_IPV6, "")
|
var ipv6: String by SharedPreference(SP_IPV6, "")
|
||||||
|
|
||||||
|
//IP地址列表
|
||||||
|
var ipList: String by SharedPreference(SP_IP_LIST, "")
|
||||||
|
|
||||||
//SIM卡状态:0-未知状态,1-卡被移除,5-卡已准备就绪
|
//SIM卡状态:0-未知状态,1-卡被移除,5-卡已准备就绪
|
||||||
var simState: Int by SharedPreference(SP_SIM_STATE, 0)
|
var simState: Int by SharedPreference(SP_SIM_STATE, 0)
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import com.idormy.sms.forwarder.core.Core
|
|||||||
import com.idormy.sms.forwarder.entity.MsgInfo
|
import com.idormy.sms.forwarder.entity.MsgInfo
|
||||||
import com.idormy.sms.forwarder.entity.TaskSetting
|
import com.idormy.sms.forwarder.entity.TaskSetting
|
||||||
import com.idormy.sms.forwarder.entity.condition.NetworkSetting
|
import com.idormy.sms.forwarder.entity.condition.NetworkSetting
|
||||||
|
import com.idormy.sms.forwarder.utils.CommonUtils
|
||||||
import com.idormy.sms.forwarder.utils.Log
|
import com.idormy.sms.forwarder.utils.Log
|
||||||
import com.idormy.sms.forwarder.utils.PhoneUtils
|
import com.idormy.sms.forwarder.utils.PhoneUtils
|
||||||
import com.idormy.sms.forwarder.utils.TaskWorker
|
import com.idormy.sms.forwarder.utils.TaskWorker
|
||||||
@ -40,6 +41,9 @@ class NetworkWorker(context: Context, params: WorkerParameters) : CoroutineWorke
|
|||||||
val ipv6 = getPublicIP(true)
|
val ipv6 = getPublicIP(true)
|
||||||
TaskUtils.ipv6 = if (ipv6Pattern.matches(ipv6)) ipv6 else ""
|
TaskUtils.ipv6 = if (ipv6Pattern.matches(ipv6)) ipv6 else ""
|
||||||
Log.d(TAG, "ipv4 = $ipv4, ipv6 = $ipv6")
|
Log.d(TAG, "ipv4 = $ipv4, ipv6 = $ipv6")
|
||||||
|
//获取所有IP地址
|
||||||
|
val ipList = CommonUtils.getIPAddresses().filter { !isLocalAddress(it) }
|
||||||
|
TaskUtils.ipList = if (ipList.isNotEmpty()) ipList.joinToString("\n") else ""
|
||||||
|
|
||||||
val conditionType = inputData.getInt(TaskWorker.CONDITION_TYPE, -1)
|
val conditionType = inputData.getInt(TaskWorker.CONDITION_TYPE, -1)
|
||||||
val taskList = Core.task.getByType(conditionType)
|
val taskList = Core.task.getByType(conditionType)
|
||||||
@ -165,4 +169,9 @@ class NetworkWorker(context: Context, params: WorkerParameters) : CoroutineWorke
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//检查IP地址是否为本地地址
|
||||||
|
private fun isLocalAddress(ip: String): Boolean {
|
||||||
|
return ip == "127.0.0.1" || ip == "::1" || ip.startsWith("fe80:") || ip.startsWith("fec0:")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -24,6 +24,7 @@
|
|||||||
<string name="tag_uid" translatable="false">{{UID}}</string>
|
<string name="tag_uid" translatable="false">{{UID}}</string>
|
||||||
<string name="tag_ipv4" translatable="false">{{IPV4}}</string>
|
<string name="tag_ipv4" translatable="false">{{IPV4}}</string>
|
||||||
<string name="tag_ipv6" translatable="false">{{IPV6}}</string>
|
<string name="tag_ipv6" translatable="false">{{IPV6}}</string>
|
||||||
|
<string name="tag_ip_list" translatable="false">{{IP_LIST}}</string>
|
||||||
<string name="tag_net_type" translatable="false">{{NET_TYPE}}</string>
|
<string name="tag_net_type" translatable="false">{{NET_TYPE}}</string>
|
||||||
|
|
||||||
<string name="type_param_sms">短信</string>
|
<string name="type_param_sms">短信</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user