modem, callscreen, ring: fix DSDS incoming ring hangup/volume and add Primary/Secondary GW SIM swap UI
This commit is contained in:
1 parent
9a079e1068
commit
7927bacb67
18 files changed
+280
-84
No files matched your search
@@ -1178,6 +1178,15 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
return callId;
|
||||
};
|
||||
|
||||
auto stopRingingJobs = [&]() {
|
||||
::unlink("/tmp/sxmo_call_ringing");
|
||||
runAsyncCmd("sxmo_jobs.sh stop ringing >/dev/null 2>&1; "
|
||||
"pkill -TERM -f sxmo_hook_ring.sh >/dev/null 2>&1; "
|
||||
"pkill -TERM -f 'pw-play.*ring' >/dev/null 2>&1; "
|
||||
"pkill -TERM -f 'mpv.*ring' >/dev/null 2>&1; "
|
||||
"pkill -TERM -x sxmo_vibrate >/dev/null 2>&1");
|
||||
};
|
||||
|
||||
auto acceptIncomingCall = [&]() {
|
||||
if (callState != CallState::Incoming) {
|
||||
return;
|
||||
@@ -1190,13 +1199,12 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
dtmfSent.clear();
|
||||
selectedRow = 0;
|
||||
writeActiveStateFiles();
|
||||
stopRingingJobs();
|
||||
setSpeakerRoute(false);
|
||||
render();
|
||||
|
||||
if (!cid.empty() && cid != "-" && cid != "sim" && cid != "test") {
|
||||
runAsyncArgv("sxmo_modemcall.sh", "pickup", cid.c_str());
|
||||
} else {
|
||||
runAsyncCmd("sxmo_jobs.sh stop ringing >/dev/null 2>&1");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1205,11 +1213,10 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
return;
|
||||
}
|
||||
ringMuted = true;
|
||||
stopRingingJobs();
|
||||
std::string cid = resolveActiveModemCallId();
|
||||
if (!cid.empty() && cid != "-" && cid != "sim" && cid != "test") {
|
||||
runAsyncArgv("sxmo_modemcall.sh", "mute", cid.c_str());
|
||||
} else {
|
||||
runAsyncCmd("sxmo_jobs.sh stop ringing >/dev/null 2>&1");
|
||||
}
|
||||
statusNotice = "Ringtone silenced";
|
||||
statusNoticeUntilMs = nowMs() + 2500;
|
||||
@@ -1221,12 +1228,6 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
if (micMuted) {
|
||||
setMicMuted(false);
|
||||
}
|
||||
alsa.setBoolean("PRI_MI2S_RX Voice Mixer VoiceMMode1", false);
|
||||
alsa.setBoolean("VoiceMMode1 Capture Mixer TERT_MI2S_TX", false);
|
||||
alsa.setEnum("EAR_S", 0);
|
||||
alsa.setEnum("RX3 MIX1 INP1", 3);
|
||||
alsa.setBoolean("SPK DAC Switch", true);
|
||||
runAsyncCmd("sxmo_modemaudio.sh disable_call_audio_mode >/dev/null 2>&1");
|
||||
if (callStartMs > 0 &&
|
||||
(callState == CallState::Active || callState == CallState::Outgoing)) {
|
||||
lastFinalDurationSec = static_cast<int>((nowMs() - callStartMs) / 1000);
|
||||
@@ -1239,17 +1240,29 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
dtmfMode = false;
|
||||
ringMuted = false;
|
||||
writeActiveStateFiles();
|
||||
stopRingingJobs();
|
||||
alsa.setBoolean("PRI_MI2S_RX Voice Mixer VoiceMMode1", false);
|
||||
alsa.setBoolean("VoiceMMode1 Capture Mixer TERT_MI2S_TX", false);
|
||||
alsa.setEnum("EAR_S", 0);
|
||||
alsa.setEnum("RX3 MIX1 INP1", 3);
|
||||
alsa.setBoolean("SPK DAC Switch", true);
|
||||
runAsyncCmd("sxmo_jobs.sh stop ringing >/dev/null 2>&1; "
|
||||
"pkill -TERM -f sxmo_hook_ring.sh >/dev/null 2>&1; "
|
||||
"pkill -TERM -f 'pw-play.*ring' >/dev/null 2>&1; "
|
||||
"pkill -TERM -f 'mpv.*ring' >/dev/null 2>&1; "
|
||||
"pkill -TERM -x sxmo_vibrate >/dev/null 2>&1; "
|
||||
"sxmo_modemaudio.sh disable_call_audio_mode >/dev/null 2>&1");
|
||||
render();
|
||||
};
|
||||
|
||||
auto hangupCall = [&]() {
|
||||
std::string cid = resolveActiveModemCallId();
|
||||
bool wasIncoming = (callState == CallState::Incoming);
|
||||
stopRingingJobs();
|
||||
if (!cid.empty() && cid != "-" && cid != "sim" && cid != "test") {
|
||||
runAsyncArgv("sxmo_modemcall.sh", "hangup", cid.c_str());
|
||||
} else {
|
||||
runAsyncCmd("sxmo_jobs.sh stop ringing >/dev/null 2>&1; "
|
||||
"mmcli -m any --voice-hangup-all >/dev/null 2>&1");
|
||||
runAsyncCmd("mmcli -m any --voice-hangup-all >/dev/null 2>&1");
|
||||
}
|
||||
transitionToEnded(wasIncoming ? "CALL REJECTED" : "CALL ENDED");
|
||||
};
|
||||
@@ -1516,8 +1529,9 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
callState = CallState::Active;
|
||||
callStartMs = nowMs();
|
||||
ringMuted = false;
|
||||
setSpeakerRoute(speakerOn);
|
||||
writeActiveStateFiles();
|
||||
stopRingingJobs();
|
||||
setSpeakerRoute(speakerOn);
|
||||
render();
|
||||
} else if (foundState == "ringing-in" && callState == CallState::Idle) {
|
||||
callState = CallState::Incoming;
|
||||
@@ -1543,8 +1557,15 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
struct dirent* ent;
|
||||
while ((ent = ::readdir(d)) != nullptr) {
|
||||
if (ent->d_name[0] != '.' && ent->d_name[0] != '\0') {
|
||||
std::string fpPath = callsDir + "/" + ent->d_name;
|
||||
::unlink(fpPath.c_str());
|
||||
std::string fn(ent->d_name);
|
||||
if (fn.rfind("sub", 0) == 0 ||
|
||||
fn.find(".ringing-in") != std::string::npos ||
|
||||
fn.find(".dialing") != std::string::npos ||
|
||||
fn.find(".ringing-out") != std::string::npos ||
|
||||
fn.find(".active") != std::string::npos) {
|
||||
std::string fpPath = callsDir + "/" + fn;
|
||||
::unlink(fpPath.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
::closedir(d);
|
||||
|
||||
@@ -760,9 +760,10 @@ int runModemApp(int argc, char** argv) {
|
||||
10, cardY + 2, 22, kIconSim);
|
||||
|
||||
std::string title = "SIM Slot " + std::to_string(s.slotNum);
|
||||
if (status.dualSimActive &&
|
||||
(s.isActiveProvisioned || s.isSecondaryProvisioned)) {
|
||||
title += s.isPreferred ? " [ACTIVE / DEFAULT]" : " [ACTIVE / DSDS]";
|
||||
if (status.dualSimActive && s.isActiveProvisioned) {
|
||||
title += s.isPreferred ? " [PRI 4G / DEFAULT]" : " [PRI 4G / DSDS]";
|
||||
} else if (status.dualSimActive && s.isSecondaryProvisioned) {
|
||||
title += s.isPreferred ? " [SEC 2G / DEFAULT]" : " [SEC 2G / DSDS]";
|
||||
} else if (s.isActiveProvisioned) {
|
||||
title += " [ACTIVE]";
|
||||
} else if (s.isSecondaryProvisioned) {
|
||||
@@ -854,23 +855,28 @@ int runModemApp(int argc, char** argv) {
|
||||
10, cardY + 44, 18, line3, 220);
|
||||
}
|
||||
|
||||
// Quick Action Rows below the 2 SIM cards (4 rows, 24px each)
|
||||
// Quick Action Rows below the 2 SIM cards (5 rows, 19px each)
|
||||
int actSlot = (simRowSel == 1) ? 2 : 1;
|
||||
int otherSlot = (status.preferredSlot == 1) ? 2 : 1;
|
||||
int otherGwSlot = (status.primaryGwSlot == 1) ? 2 : 1;
|
||||
if (status.primaryGwSlot == 0) {
|
||||
if (status.slots[1].state == "present" && status.slots[0].state != "present") {
|
||||
otherSlot = 2;
|
||||
otherGwSlot = 2;
|
||||
} else if (status.slots[0].state == "present" && status.slots[1].state != "present") {
|
||||
otherSlot = 1;
|
||||
otherGwSlot = 1;
|
||||
}
|
||||
}
|
||||
std::string quickRows[4] = {
|
||||
std::string quickRows[5] = {
|
||||
std::string(kIconRefresh) +
|
||||
(status.primaryGwSlot == 0
|
||||
? (" Activate SIM " + std::to_string(otherSlot))
|
||||
: (status.dualSimActive
|
||||
? (" Set Default SIM to Slot " + std::to_string(otherSlot))
|
||||
: (" Switch Active to SIM " + std::to_string(otherSlot)))),
|
||||
std::string(kIconSignal) + " Swap Primary (4G/Data) to Slot " +
|
||||
std::to_string(otherGwSlot),
|
||||
std::string(kIconUnlock) + " Unlock SIM (PIN / PUK)",
|
||||
std::string(kIconLock) + " Enable / Disable SIM PIN",
|
||||
std::string(kIconKey) + " Change SIM PIN Code",
|
||||
@@ -878,13 +884,13 @@ int runModemApp(int argc, char** argv) {
|
||||
(void)actSlot;
|
||||
|
||||
int baseY = contentY + 142;
|
||||
for (int r = 0; r < 4; ++r) {
|
||||
int ry = baseY + r * 23;
|
||||
for (int r = 0; r < 5; ++r) {
|
||||
int ry = baseY + r * 19;
|
||||
bool isSel = (simRowSel == (r + 2));
|
||||
XSetForeground(dpy, gc, isSel ? pt.spec.selBg : ((r % 2 == 0) ? pt.spec.bgAltEven : pt.spec.bgAltOdd));
|
||||
XFillRectangle(dpy, pix, gc, 4, ry, kWinWidth - 8, 22);
|
||||
XFillRectangle(dpy, pix, gc, 4, ry, kWinWidth - 8, 18);
|
||||
drawPango(layoutSmall, isSel ? &colWhite : &colLight,
|
||||
10, ry, 22, quickRows[r], kWinWidth - 20);
|
||||
10, ry, 18, quickRows[r], kWinWidth - 20);
|
||||
}
|
||||
|
||||
drawSoftkeyBar("Actions", "Select", "Close");
|
||||
@@ -1085,27 +1091,28 @@ int runModemApp(int argc, char** argv) {
|
||||
// Modal Overlays
|
||||
if (modal == ModalMode::SimActions) {
|
||||
XSetForeground(dpy, gc, pt.spec.bgOverlay);
|
||||
XFillRectangle(dpy, pix, gc, 12, 44, kWinWidth - 24, 196);
|
||||
XFillRectangle(dpy, pix, gc, 12, 38, kWinWidth - 24, 214);
|
||||
XSetForeground(dpy, gc, pt.spec.accent);
|
||||
XDrawRectangle(dpy, pix, gc, 12, 44, kWinWidth - 25, 195);
|
||||
XDrawRectangle(dpy, pix, gc, 12, 38, kWinWidth - 25, 213);
|
||||
|
||||
std::string hdr = "SIM Slot " + std::to_string(targetSlot) + " Actions";
|
||||
drawPango(layoutMain, &colYellow, 20, 48, 24, hdr, kWinWidth - 40);
|
||||
drawPango(layoutMain, &colYellow, 20, 42, 22, hdr, kWinWidth - 40);
|
||||
|
||||
const char* actLabels[5] = {
|
||||
"Set as Default / Primary SIM",
|
||||
const char* actLabels[6] = {
|
||||
"Set as Default SIM (Fast)",
|
||||
"Make Primary GW (4G/Data Swap)",
|
||||
"Unlock SIM (Enter PIN)",
|
||||
"Unblock SIM (Enter PUK)",
|
||||
"Enable / Disable SIM PIN",
|
||||
"Change SIM PIN Code",
|
||||
};
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
int ry = 76 + i * 30;
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
int ry = 68 + i * 29;
|
||||
bool isSel = (actionSel == i);
|
||||
XSetForeground(dpy, gc, isSel ? pt.spec.selBg : pt.spec.bgButton);
|
||||
XFillRectangle(dpy, pix, gc, 18, ry, kWinWidth - 36, 26);
|
||||
XFillRectangle(dpy, pix, gc, 18, ry, kWinWidth - 36, 25);
|
||||
drawPango(layoutSmall, isSel ? &colWhite : &colLight,
|
||||
24, ry, 26, actLabels[i], kWinWidth - 48);
|
||||
24, ry, 25, actLabels[i], kWinWidth - 48);
|
||||
}
|
||||
drawSoftkeyBar("Select", "OK", "Back");
|
||||
} else if (modal == ModalMode::VerifyPin ||
|
||||
@@ -1312,13 +1319,22 @@ int runModemApp(int argc, char** argv) {
|
||||
::unlink(activePidPath.c_str());
|
||||
};
|
||||
|
||||
auto switchSimSlotNow = [&](int slotNum) {
|
||||
auto switchSimSlotNow = [&](int slotNum, bool swapGw = false) {
|
||||
slotNum = std::clamp(slotNum, 1, 2);
|
||||
setBanner("Switching active SIM to Slot " + std::to_string(slotNum) + "...");
|
||||
if (swapGw) {
|
||||
setBanner("Swapping Primary (4G/Data) to Slot " + std::to_string(slotNum) + "...");
|
||||
} else {
|
||||
setBanner("Setting Default SIM to Slot " + std::to_string(slotNum) + "...");
|
||||
}
|
||||
render();
|
||||
int rc = 0;
|
||||
runCaptureCmd("doas -n /usr/libexec/msm-modem-uim-selection switch " +
|
||||
std::to_string(slotNum) + " >/dev/null 2>&1", &rc);
|
||||
std::string cmd = "doas -n /usr/libexec/msm-modem-uim-selection switch " +
|
||||
std::to_string(slotNum);
|
||||
if (swapGw) {
|
||||
cmd += " --swap-gw";
|
||||
}
|
||||
cmd += " >/dev/null 2>&1";
|
||||
runCaptureCmd(cmd, &rc);
|
||||
runAsyncCmd("sxmo_hook_statusbar.sh modem >/dev/null 2>&1");
|
||||
refreshData(false);
|
||||
if (status.slots[slotNum - 1].needsPin() ||
|
||||
@@ -1327,7 +1343,11 @@ int runModemApp(int argc, char** argv) {
|
||||
return;
|
||||
}
|
||||
if (rc == 0) {
|
||||
setBanner("Active SIM set to Slot " + std::to_string(slotNum));
|
||||
if (swapGw) {
|
||||
setBanner("Primary (4G/Data) swapped to Slot " + std::to_string(slotNum));
|
||||
} else {
|
||||
setBanner("Default SIM set to Slot " + std::to_string(slotNum));
|
||||
}
|
||||
} else {
|
||||
setBanner("Failed to switch SIM slot");
|
||||
}
|
||||
@@ -1524,16 +1544,26 @@ int runModemApp(int argc, char** argv) {
|
||||
otherSlot = 1;
|
||||
}
|
||||
}
|
||||
switchSimSlotNow(otherSlot);
|
||||
switchSimSlotNow(otherSlot, false);
|
||||
} else if (row == 3) {
|
||||
openPinOrPukModalForSlot(defaultActiveOrPresentSlot());
|
||||
int otherGwSlot = (status.primaryGwSlot == 1) ? 2 : 1;
|
||||
if (status.primaryGwSlot == 0) {
|
||||
if (status.slots[1].state == "present" && status.slots[0].state != "present") {
|
||||
otherGwSlot = 2;
|
||||
} else if (status.slots[0].state == "present" && status.slots[1].state != "present") {
|
||||
otherGwSlot = 1;
|
||||
}
|
||||
}
|
||||
switchSimSlotNow(otherGwSlot, true);
|
||||
} else if (row == 4) {
|
||||
openPinOrPukModalForSlot(defaultActiveOrPresentSlot());
|
||||
} else if (row == 5) {
|
||||
targetSlot = defaultActiveOrPresentSlot();
|
||||
wizardStep = 0;
|
||||
inputPin1.clear();
|
||||
modalError.clear();
|
||||
modal = ModalMode::TogglePinLock;
|
||||
} else if (row == 5) {
|
||||
} else if (row == 6) {
|
||||
targetSlot = defaultActiveOrPresentSlot();
|
||||
wizardStep = 0;
|
||||
inputPin1.clear();
|
||||
@@ -1572,30 +1602,32 @@ int runModemApp(int argc, char** argv) {
|
||||
if (modal == ModalMode::SimActions) {
|
||||
int act = actionSel;
|
||||
modal = ModalMode::None;
|
||||
if (act >= 1 && act <= 4 &&
|
||||
if (act >= 2 && act <= 5 &&
|
||||
status.slots[targetSlot - 1].state != "present") {
|
||||
targetSlot = defaultActiveOrPresentSlot();
|
||||
}
|
||||
if (act == 0) {
|
||||
switchSimSlotNow(targetSlot);
|
||||
switchSimSlotNow(targetSlot, false);
|
||||
} else if (act == 1) {
|
||||
switchSimSlotNow(targetSlot, true);
|
||||
} else if (act == 2) {
|
||||
wizardStep = 0;
|
||||
inputPin1.clear();
|
||||
modalError.clear();
|
||||
modal = ModalMode::VerifyPin;
|
||||
} else if (act == 2) {
|
||||
} else if (act == 3) {
|
||||
wizardStep = 0;
|
||||
inputPin1.clear();
|
||||
inputPin2.clear();
|
||||
inputPin3.clear();
|
||||
modalError.clear();
|
||||
modal = ModalMode::UnblockPuk;
|
||||
} else if (act == 3) {
|
||||
} else if (act == 4) {
|
||||
wizardStep = 0;
|
||||
inputPin1.clear();
|
||||
modalError.clear();
|
||||
modal = ModalMode::TogglePinLock;
|
||||
} else if (act == 4) {
|
||||
} else if (act == 5) {
|
||||
wizardStep = 0;
|
||||
inputPin1.clear();
|
||||
inputPin2.clear();
|
||||
@@ -1868,10 +1900,10 @@ int runModemApp(int argc, char** argv) {
|
||||
|
||||
if (modal == ModalMode::SimActions) {
|
||||
if (sym == XK_Up || sym == XK_KP_Up) {
|
||||
actionSel = (actionSel + 4) % 5;
|
||||
actionSel = (actionSel + 5) % 6;
|
||||
render();
|
||||
} else if (sym == XK_Down || sym == XK_KP_Down) {
|
||||
actionSel = (actionSel + 1) % 5;
|
||||
actionSel = (actionSel + 1) % 6;
|
||||
render();
|
||||
} else if (sym == XK_Return || sym == XK_KP_Enter) {
|
||||
handleEnterKey();
|
||||
@@ -2005,7 +2037,7 @@ int runModemApp(int argc, char** argv) {
|
||||
render();
|
||||
} else if (sym == XK_Up || sym == XK_KP_Up) {
|
||||
if (activeTab == TabId::SimCards) {
|
||||
simRowSel = (simRowSel + 5) % 6;
|
||||
simRowSel = (simRowSel + 6) % 7;
|
||||
} else if (activeTab == TabId::RadioInfo) {
|
||||
radioRowSel = (radioRowSel + 4) % 5;
|
||||
} else if (activeTab == TabId::AtConsole) {
|
||||
@@ -2020,7 +2052,7 @@ int runModemApp(int argc, char** argv) {
|
||||
render();
|
||||
} else if (sym == XK_Down || sym == XK_KP_Down) {
|
||||
if (activeTab == TabId::SimCards) {
|
||||
simRowSel = (simRowSel + 1) % 6;
|
||||
simRowSel = (simRowSel + 1) % 7;
|
||||
} else if (activeTab == TabId::RadioInfo) {
|
||||
radioRowSel = (radioRowSel + 1) % 5;
|
||||
} else if (activeTab == TabId::AtConsole) {
|
||||
|
||||
@@ -354,7 +354,7 @@ int runRingtonesApp(int argc, char** argv) {
|
||||
stopPreview();
|
||||
settings = loadRingSettings();
|
||||
int rvol = std::clamp(settings.ringVol, 0, 100);
|
||||
int rx3 = (rvol <= 0) ? 0 : (60 + rvol * 34 / 100);
|
||||
int rx3 = (rvol <= 0) ? 0 : (60 + rvol * 24 / 100);
|
||||
int mpvVol = rvol;
|
||||
std::string volArg = "--volume=" + std::to_string(mpvVol);
|
||||
runAsyncCmd("amixer -c 0 cset \"name='EAR_S'\" 0 >/dev/null 2>&1; "
|
||||
|
||||
Reference in new issue
Block a user