更新已知问题
This commit is contained in:
parent
7eb8c3a5ad
commit
cc46a40896
@ -4,7 +4,7 @@
|
|||||||
<selectionStates>
|
<selectionStates>
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
<DropdownSelection timestamp="2026-03-26T12:09:09.946169900Z">
|
<DropdownSelection timestamp="2026-03-26T14:07:43.913102200Z">
|
||||||
<Target type="DEFAULT_BOOT">
|
<Target type="DEFAULT_BOOT">
|
||||||
<handle>
|
<handle>
|
||||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=lvzdxotknne6u4nv" />
|
<DeviceId pluginId="PhysicalDevice" identifier="serial=lvzdxotknne6u4nv" />
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -22,6 +22,16 @@
|
|||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
|
<!-- 为 ROLE_SMS 申请准备:声明自己是可处理短信的应用 -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.SENDTO" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<data android:scheme="sms" />
|
||||||
|
<data android:scheme="smsto" />
|
||||||
|
<data android:scheme="mms" />
|
||||||
|
<data android:scheme="mmsto" />
|
||||||
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<!-- 接收系统短信广播 -->
|
<!-- 接收系统短信广播 -->
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.yunzer.sms
|
package com.yunzer.sms
|
||||||
|
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
|
import android.app.role.RoleManager
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
@ -25,6 +26,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
private lateinit var btnSave: Button
|
private lateinit var btnSave: Button
|
||||||
private lateinit var etTestPhone: EditText
|
private lateinit var etTestPhone: EditText
|
||||||
private lateinit var btnSmsTest: Button
|
private lateinit var btnSmsTest: Button
|
||||||
|
private lateinit var btnRequestSmsRole: Button
|
||||||
private lateinit var btnClearLog: Button
|
private lateinit var btnClearLog: Button
|
||||||
private lateinit var tvStatus: TextView
|
private lateinit var tvStatus: TextView
|
||||||
private lateinit var tvLog: TextView
|
private lateinit var tvLog: TextView
|
||||||
@ -42,6 +44,12 @@ class MainActivity : ComponentActivity() {
|
|||||||
|
|
||||||
private val configStore by lazy { ConfigStore(this) }
|
private val configStore by lazy { ConfigStore(this) }
|
||||||
|
|
||||||
|
private val smsRoleLauncher =
|
||||||
|
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
||||||
|
// 角色授权结束后,再尝试启动网关
|
||||||
|
maybeStartGateway()
|
||||||
|
}
|
||||||
|
|
||||||
private val permissionLauncher =
|
private val permissionLauncher =
|
||||||
registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) {
|
registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) {
|
||||||
// 权限申请后可能有两类后续动作:
|
// 权限申请后可能有两类后续动作:
|
||||||
@ -69,6 +77,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
btnSave = findViewById(R.id.btnSave)
|
btnSave = findViewById(R.id.btnSave)
|
||||||
etTestPhone = findViewById(R.id.etTestPhone)
|
etTestPhone = findViewById(R.id.etTestPhone)
|
||||||
btnSmsTest = findViewById(R.id.btnSmsTest)
|
btnSmsTest = findViewById(R.id.btnSmsTest)
|
||||||
|
btnRequestSmsRole = findViewById(R.id.btnRequestSmsRole)
|
||||||
btnClearLog = findViewById(R.id.btnClearLog)
|
btnClearLog = findViewById(R.id.btnClearLog)
|
||||||
tvStatus = findViewById(R.id.tvStatus)
|
tvStatus = findViewById(R.id.tvStatus)
|
||||||
tvLog = findViewById(R.id.tvLog)
|
tvLog = findViewById(R.id.tvLog)
|
||||||
@ -126,6 +135,22 @@ class MainActivity : ComponentActivity() {
|
|||||||
sendTestSms(phone)
|
sendTestSms(phone)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
btnRequestSmsRole.setOnClickListener {
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||||
|
Toast.makeText(this, "当前系统版本不需要 ROLE_SMS", Toast.LENGTH_SHORT).show()
|
||||||
|
return@setOnClickListener
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
val roleManager = getSystemService(RoleManager::class.java) ?: return@setOnClickListener
|
||||||
|
SmsGatewayLogger.post(this, "INFO", "用户点击:申请 ROLE_SMS")
|
||||||
|
val intent = roleManager.createRequestRoleIntent(RoleManager.ROLE_SMS)
|
||||||
|
smsRoleLauncher.launch(intent)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Toast.makeText(this, "申请 ROLE_SMS 失败:${e.message}", Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
btnClearLog.setOnClickListener {
|
btnClearLog.setOnClickListener {
|
||||||
tvLog.text = ""
|
tvLog.text = ""
|
||||||
SmsGatewayLogger.post(this, "INFO", "日志已清空")
|
SmsGatewayLogger.post(this, "INFO", "日志已清空")
|
||||||
|
|||||||
@ -49,6 +49,13 @@
|
|||||||
android:text="@string/sms_test"
|
android:text="@string/sms_test"
|
||||||
android:layout_marginTop="8dp" />
|
android:layout_marginTop="8dp" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnRequestSmsRole"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/request_sms_role"
|
||||||
|
android:layout_marginTop="8dp" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btnClearLog"
|
android:id="@+id/btnClearLog"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@ -15,6 +15,8 @@
|
|||||||
<string name="sms_test_success">短信测试发送成功</string>
|
<string name="sms_test_success">短信测试发送成功</string>
|
||||||
<string name="sms_test_failed">短信测试发送失败</string>
|
<string name="sms_test_failed">短信测试发送失败</string>
|
||||||
|
|
||||||
|
<string name="request_sms_role">申请默认短信权限(ROLE_SMS)</string>
|
||||||
|
|
||||||
<string name="permission_tip">请授予短信接收/发送权限</string>
|
<string name="permission_tip">请授予短信接收/发送权限</string>
|
||||||
<string name="config_saved">配置已保存并启动网关</string>
|
<string name="config_saved">配置已保存并启动网关</string>
|
||||||
<string name="config_invalid">请填写后端地址、ApiKey</string>
|
<string name="config_invalid">请填写后端地址、ApiKey</string>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user