modem, callscreen, ring: fix DSDS incoming ring hangup/volume and add Primary/Secondary GW SIM swap UI

This commit is contained in:
Luxferre committed 2026-10-27 13:02:14 +02:00
1 parent 9a079e1068
commit 7927bacb67
18 files changed
+280 -84

No files matched your search

+67 -35
View File
@@ -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) {