SMS: composer-only (ACTION_SENDTO), drop SEND_SMS permission

Reverting the SmsManager direct-send path and its runtime SEND_SMS request - the SMS
feature was meant to use the system SMS composer, which needs no permission. Keep only
the prefilled ACTION_SENDTO composer.
This commit is contained in:
4aiman 2026-10-26 22:12:31 +03:00
commit f91281a218
2 changed files with 2 additions and 28 deletions

View file

@ -6,7 +6,6 @@
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE" />

View file

@ -11,7 +11,6 @@ import android.provider.Settings
import android.os.Bundle
import android.os.FileObserver
import android.provider.ContactsContract
import android.telephony.SmsManager
import android.util.Log
import android.webkit.WebView
import androidx.activity.OnBackPressedCallback
@ -461,34 +460,10 @@ class MainActivity : TauriActivity() {
return if (format == "geojson") track.formatAsGeoJson() else track.formatAsGpx()
}
// Send the location SMS. If SEND_SMS was granted, send it straight over the cellular network
// (the in-app confirm was the only tap). Otherwise request the permission for next time and fall
// back to the system SMS composer, prefilled — which needs no permission. Either path works with
// no internet, over 2G/EDGE.
// Send the location SMS by opening the system SMS app prefilled (ACTION_SENDTO). This needs
// NO permission by design — the user taps send in their SMS app. Works offline over 2G/EDGE.
private fun sendSms(number: String, text: String) {
if (number.isBlank()) return
val granted = checkSelfPermission(android.Manifest.permission.SEND_SMS) == PackageManager.PERMISSION_GRANTED
if (granted) {
try {
val sm = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
getSystemService(SmsManager::class.java)
else
@Suppress("DEPRECATION") SmsManager.getDefault()
val parts = sm.divideMessage(text)
if (parts.size > 1) sm.sendMultipartTextMessage(number, null, parts, null, null)
else sm.sendTextMessage(number, null, text, null, null)
Log.d("BalDav", "SMS sent directly to $number")
runOnUiThread {
android.widget.Toast.makeText(this, "СМС отправлено", android.widget.Toast.LENGTH_SHORT).show()
}
return
} catch (e: Exception) {
Log.w("BalDav", "direct SMS failed, falling back to composer: ${e.message}")
}
} else {
// Ask for the permission so the next send can go directly; this one still uses the composer.
try { requestPermissions(arrayOf(android.Manifest.permission.SEND_SMS), 4343) } catch (_: Exception) {}
}
try {
val intent = Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:$number")).apply {
putExtra("sms_body", text)