Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,54 @@
# Changelog

## SimBridge 2.8.0

Update both apps. Pairing is kept. This release includes the 2.7 redesign, which was not released on its own.

### Why the hotspot was slow: Wi-Fi 6
On a Galaxy A56 hotspot with **Wi-Fi 6** turned on, a Pixel 9 joined with a very strong signal
(−32 dBm) but its send rate was stuck at **8 Mbps** (it can do 1200). A direct test between the two
phones, with no internet involved, moved only about **1 Mbps** from the Pixel to the SIM phone.
Every download needs small replies sent back, so browsing, speed tests and calls were all slow,
and only a reboot of both phones sometimes cleared it. The 2.4 / 5 / 6 GHz band made no difference.

After turning off **Wi-Fi 6** in the SIM phone's hotspot settings (Hotspot > Advanced), the same
link came up as Wi-Fi 5 at **702 / 866 Mbps**.

- **Fix:** on the SIM phone open *Hotspot > Advanced* and turn off *Wi-Fi 6*.
- *Check everything* now spots this: when the link is Wi-Fi 6 with a strong signal but a send rate
under 30 Mbps, it tells you to turn Wi-Fi 6 off.
- Other things this ruled out: the carrier (the hotspot does not use a separate tethering APN) and
the band. If your carrier does slow down tethered traffic, use *Carrier-friendly sharing* below.

### New look (2.7)
- A bottom bar with **Messages, Calls, SIM phone and Settings**. Each tool on the SIM phone has its
own page, and settings are a short list of sections instead of tabs.
- Quick-Settings-style tiles for mobile data, hotspot, battery saver, remote screen, ring and restart.
- A design system (`docs/DESIGN.md`): Material 3 with your wallpaper colours, rounded grouped
lists and clear on/off states.

### Calls
- Fewer gaps and less delay: Wi-Fi low-latency locks on both phones during a call, a gentler
jitter buffer that catches up without big jumps, and no more Wi-Fi scans during a call.
- **Last call card:** how much audio went missing and how good the link was, with a tip.

### SIM phone and hotspot
- **Check everything:** one page that finds what is wrong and links to the fix.
- **Wi-Fi links:** signal, band and speed of both phones' Wi-Fi.
- **Hotspot band** (5 / 2.4 GHz / auto) and hardware acceleration switch.
- **Smart hotspot:** turns off when both phones share a Wi-Fi and nobody uses it, back on when
Wi-Fi is gone.
- **Carrier-friendly sharing:** an optional web proxy on the SIM phone (port 8118) for carriers
that slow down hotspot traffic. *SIM phone's own internet* speed test shows whether you need it.
- **Night mode:** mobile data off and battery saver on at night on the SIM phone.
- **Monthly data limit:** a text at 80 % and 100 %.
- **Main phones:** see how many phones and tablets are connected.

### Main phone
- **Quick Settings tiles** for the SIM phone's hotspot, mobile data and battery saver.
- **Voice notes:** hold the mic in a chat to record and send one.
- **Reactions:** select a message and react with an emoji.

## SimBridge 2.6.0

Update both apps. Pairing is kept.
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ languages, free cloud engines or fully on-device.
[Disclaimer](DISCLAIMER.md)

<p align="center">
<img src="docs/images/simbridge-gateway.png" width="280" alt="SimBridge Gateway on the SIM phone">
&nbsp;&nbsp;
<img src="docs/images/simbridge-settings.png" width="280" alt="SimBridge settings on the main phone">
<img src="docs/images/simbridge-sim-phone.png" width="200" alt="SIM phone page: status, quick tiles and tools">
<img src="docs/images/simbridge-check.png" width="200" alt="Check everything: what is wrong and how to fix it">
<img src="docs/images/simbridge-calls.png" width="200" alt="Calls: voicemail, translation, quiet hours and recent calls">
<img src="docs/images/simbridge-settings-hub.png" width="200" alt="Settings: connection, calls, messages and app">
</p>
<p align="center">
<img src="docs/images/simbridge-gateway.png" width="200" alt="SimBridge Gateway on the SIM phone">
</p>

---
Expand Down Expand Up @@ -356,6 +360,7 @@ call's audio and text: tell the caller where the law requires it.
|---|---|
| Main phone says *Looking for your SIM phone…* | Both phones on the same Wi-Fi (or main phone on the hotspot)? Is SimBridge Gateway open, with **Forward calls & texts** on? Some routers block mDNS or isolate devices: use the hotspot, or turn off "AP/client isolation". |
| *The SIM phone rejected this phone* / *key changed* | Scan the SIM phone's code again (*Pair a phone*). This is expected after *New key* on the SIM phone. After 5 wrong tries the gateway ignores that device for 10 minutes. |
| **Hotspot is very slow** or stops until both phones restart | On the SIM phone open *Hotspot → Advanced* and turn off **Wi-Fi 6**. Some Samsung hotspots leave a Pixel's send rate stuck at a few Mbps on Wi-Fi 6 even with a strong signal. *Check everything* in SimBridge spots this. If it is still slow, compare *SIM phone's own internet* in the speed test: if that is much faster, your carrier slows tethering, so try *Carrier-friendly sharing*. |
| *Your microphone is off for this call* | Tap the notification once. It happens on the first call after the main phone restarted or SimBridge was updated. |
| Picture messages don't arrive | Make SimBridge Gateway the SIM phone's SMS app (*Picture & group messages*) and keep mobile data on. |
| Missed calls don't appear in the Phone app | Allow SimBridge's *call log* permission (Android settings → Apps → SimBridge → Permissions). |
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId = "io.github.simbridge.gateway"
minSdk = 30
targetSdk = 36
versionCode = 470
versionName = "2.6.0"
versionCode = 490
versionName = "2.8.0"
// Filter all transitive JNI libraries as well as PJSIP's own module outputs.
ndk {
//abiFilters += listOf("arm64-v8a", "x86_64")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import org.json.JSONObject
* persistent queue while no phone is registered.
*/
/** Control operations that change something on this phone; each is written to the [Audit] log. */
private val AUDITED = setOf("machine", "control", "ussd", "ussd-reply", "screen-start", "network-mode", "apn-select", "apn-add", "sms-app",
private val AUDITED = setOf("hotspot-band", "tether-offload", "machine", "control", "ussd", "ussd-reply", "screen-start", "network-mode", "apn-select", "apn-add", "sms-app",
"at-place", "charge-limit", "locate", "block-rules", "voicemail")

/** Who changed what on this phone, and when (the last 200 entries). */
Expand Down Expand Up @@ -74,6 +74,24 @@ class GatewayControl(private val app: Context, private val rt: GatewayRuntime) {
prompts.prepare(greeting); prompts.prepare(screenPrompt)
send(status(), from)
}
"hotspot-band" -> rt.worker {
privileged("softap-band", o.optInt("band", 5).toString())
// Restart a running hotspot so the new band is used now.
if (hotspotOn()) { privilegedRaw("hotspot", "off"); Thread.sleep(1500); privilegedRaw("hotspot", "on") }
send(status(), from)
}
"tether-offload" -> rt.worker { privileged("tether-offload", if (o.optBoolean("on")) "on" else "off"); send(status(), from) }
// This phone's own internet speed (for comparing with the main phone's, through the hotspot).
"speed-net" -> rt.worker { send(JSONObject().put("op", "speed-net").put("mbps", ownDownloadMbps()), from) }
"smart-hotspot" -> { prefs.edit().putBoolean("smart_hotspot", o.optBoolean("on")).apply(); send(status(), from) }
"night" -> {
prefs.edit().putBoolean("night_on", o.optBoolean("on")).putInt("night_start", o.optInt("start", 60))
.putInt("night_end", o.optInt("end", 420)).putBoolean("night_data", o.optBoolean("data", true))
.putBoolean("night_saver", o.optBoolean("saver", true)).apply()
send(status(), from)
}
"data-limit" -> { prefs.edit().putFloat("data_limit_gb", o.optDouble("gb", 0.0).toFloat()).putInt("data_warned", 0).apply(); send(status(), from) }
"proxy" -> { prefs.edit().putBoolean("proxy_on", o.optBoolean("on")).apply(); applyProxy(); send(status(), from) }
"audit" -> send(JSONObject().put("op", "audit").put("list", Audit.recent(app)), from)
"charge-limit" -> rt.worker {
privileged("charge-limit", o.optString("value", "off"))
Expand Down Expand Up @@ -263,8 +281,19 @@ class GatewayControl(private val app: Context, private val rt: GatewayRuntime) {
o.put("uptimeMin", SystemClock.elapsedRealtime() / 60_000)
o.put("version", runCatching { app.packageManager.getPackageInfo(app.packageName, 0).versionName }.getOrNull() ?: "")
o.put("hotspot", hotspotOn())
privilegedRaw("softap-info", "").takeUnless { it.startsWith("error") }?.split(',')?.let {
o.put("apBand", it[0].toIntOrNull() ?: 0).put("apChannel", it.getOrNull(1)?.toIntOrNull() ?: 0)
}
o.put("offload", privilegedRaw("tether-offload-get", "") != "off")
privilegedRaw("charge-limit-get", "").takeUnless { it.startsWith("error") }?.let { o.put("chargeLimit", it) }
o.put("dailyReport", prefs.getBoolean("daily_report", true))
o.put("smartHotspot", prefs.getBoolean("smart_hotspot", false))
o.put("night", JSONObject().put("on", prefs.getBoolean("night_on", false)).put("start", prefs.getInt("night_start", 60))
.put("end", prefs.getInt("night_end", 420)).put("data", prefs.getBoolean("night_data", true)).put("saver", prefs.getBoolean("night_saver", true)))
o.put("dataLimitGb", prefs.getFloat("data_limit_gb", 0f).toDouble())
o.put("proxy", HttpProxy.running).put("proxyPort", HttpProxy.PORT)
o.put("phones", JSONArray(rt.sipAgent?.phoneAddresses ?: emptyList<String>()))
ownWifi()?.let { o.put("wifi", it) }
o.put("vmOn", voicemailOn).put("screenMode", screenMode).put("greeting", greeting).put("screenPrompt", screenPrompt)
o.put("smsApp", MmsGateway.isDefaultSmsApp(app))
o.put("noAnswerSec", noAnswerSec)
Expand Down Expand Up @@ -555,8 +584,82 @@ class GatewayControl(private val app: Context, private val rt: GatewayRuntime) {
.put("wav", android.util.Base64.encodeToString(Wav.encode(audio, rate), android.util.Base64.NO_WRAP)))
}

// ------------------------------------------------------------ smart hotspot, night mode, data limit

private fun applyProxy() {
HttpProxy.allowed = { ip -> ip.startsWith("10.") || ip.startsWith("192.168.") || ip.startsWith("172.") }
if (prefs.getBoolean("proxy_on", false)) HttpProxy.start() else HttpProxy.stop()
}

/** This phone's Wi-Fi when it is a client (home Wi-Fi): name, band, link speeds, signal. */
private fun ownWifi(): JSONObject? = runCatching {
val wm = app.getSystemService(android.net.wifi.WifiManager::class.java)
@Suppress("DEPRECATION") val i = wm.connectionInfo ?: return null
if (i.networkId == -1 && i.rssi <= -127) return null
JSONObject().put("ssid", i.ssid.trim('"')).put("freq", i.frequency).put("rssi", i.rssi)
.put("tx", i.txLinkSpeedMbps).put("rx", i.rxLinkSpeedMbps)
}.getOrNull()

private fun ownDownloadMbps(): Double = runCatching {
val c = java.net.URL("https://speed.cloudflare.com/__down?bytes=25000000").openConnection() as java.net.HttpURLConnection
c.connectTimeout = 8000; c.readTimeout = 15_000
val buf = ByteArray(64 * 1024); var got = 0L
val t0 = System.nanoTime()
c.inputStream.use { s -> while (System.nanoTime() - t0 < 8_000_000_000L) { val n = s.read(buf); if (n < 0) break; got += n } }
c.disconnect()
got * 8.0 / ((System.nanoTime() - t0) / 1e9) / 1e6
}.getOrDefault(0.0)

private var noClientsSince = 0L
private var nightApplied = false

/** Every minute: hotspot only when needed, night mode, the monthly data limit. */
private fun housekeeping() {
// Smart hotspot: off when the main phones reach us some other way and nobody uses it.
if (prefs.getBoolean("smart_hotspot", false) && hotspotOn()) {
val phones = rt.sipAgent?.phoneAddresses.orEmpty()
val viaOther = phones.isNotEmpty() && phones.none { it.startsWith("10.") }
val clients = hotspotClients().length()
if (viaOther && clients == 0) {
if (noClientsSince == 0L) noClientsSince = System.currentTimeMillis()
if (System.currentTimeMillis() - noClientsSince > 10 * 60_000) {
AppLog.i("smart hotspot: not needed, turning it off"); privileged("hotspot", "off"); noClientsSince = 0
}
} else noClientsSince = 0
} else if (prefs.getBoolean("smart_hotspot", false)) hotspotIfNoWifi("smart hotspot")
// Night mode: data off and/or battery saver between two times.
if (prefs.getBoolean("night_on", false)) {
val c = java.util.Calendar.getInstance()
val m = c.get(java.util.Calendar.HOUR_OF_DAY) * 60 + c.get(java.util.Calendar.MINUTE)
val s = prefs.getInt("night_start", 60); val e = prefs.getInt("night_end", 420)
val night = if (s <= e) m in s until e else m >= s || m < e
if (night != nightApplied) {
nightApplied = night
AppLog.i("night mode ${if (night) "starts" else "ends"}")
if (prefs.getBoolean("night_data", true)) privileged("mobile-data", if (night) "off" else "on")
if (prefs.getBoolean("night_saver", true)) rt.setCompanionPower(night)
}
}
// Data limit: a text at 80 % and at 100 % of the month.
val limit = prefs.getFloat("data_limit_gb", 0f)
if (limit > 0) dataUsage()?.let { (_, month) ->
val pct = (month / (limit * 1e9) * 100).toInt()
val warned = prefs.getInt("data_warned", 0)
val month0 = prefs.getInt("data_warned_month", -1); val nowMonth = java.util.Calendar.getInstance().get(java.util.Calendar.MONTH)
if (month0 != nowMonth) prefs.edit().putInt("data_warned", 0).putInt("data_warned_month", nowMonth).apply()
if (pct >= 100 && warned < 100) { prefs.edit().putInt("data_warned", 100).apply(); rt.alerts.post("📶 Mobile data limit reached: ${"%.1f".format(month / 1e9)} GB of $limit GB this month.") }
else if (pct >= 80 && warned < 80) { prefs.edit().putInt("data_warned", 80).apply(); rt.alerts.post("📶 80 % of your mobile data limit used: ${"%.1f".format(month / 1e9)} GB of $limit GB.") }
}
}

private fun loop() {
main.postDelayed({ rt.worker { runCatching { housekeeping() }.onFailure { AppLog.w("housekeeping: ${it.message}") }; loop() } }, 60_000)
}

/** Called once when the gateway starts. */
fun start() {
applyProxy()
loop()
prompts.prepare(greeting); prompts.prepare(screenPrompt)
scheduleReport()
if (prefs.getBoolean("crashed", false)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ data class HealthState(
class GatewayRuntime private constructor(context: Context) {
private val app = context.applicationContext
private val worker = newWorker()
@Volatile private var boostedSession: Any? = null
/** Runs [block] on the gateway worker thread (control, SIP, privileged calls). */
fun worker(block: () -> Unit) = worker.execute(block)
val settingsStore = SettingsStore(app)
Expand Down Expand Up @@ -731,6 +732,12 @@ class GatewayRuntime private constructor(context: Context) {
)
b.addListener { session ->
noteMissed(session)
// The SIM phone's Wi-Fi radio stays awake while a call is bridged (no power-save bursts).
if (session.connectedAtMs != null && session.endedAtMs == null && boostedSession != session) {
boostedSession = session; WifiBoost.acquire(app)
} else if (session.endedAtMs != null && boostedSession == session) {
boostedSession = null; WifiBoost.release()
}
val description = describe(session)
worker.execute {
if (bridge !== b) return@execute
Expand Down
Loading
Loading