Fix QMI USSD async response handling and prevent st terminal popup
This commit is contained in:
@@ -569,6 +569,7 @@ int runModemApp(int argc, char** argv) {
|
||||
std::string ussdInput = "*100#";
|
||||
std::string ussdResponse;
|
||||
bool ussdWaitingReply = false;
|
||||
int ussdScrollLine = 0;
|
||||
|
||||
// AT Console state
|
||||
int atFocusRow = 0; // 0 = Input, 1 = Preset/Port, 2 = Output scroll
|
||||
@@ -1180,10 +1181,28 @@ int runModemApp(int argc, char** argv) {
|
||||
: ussdResponse;
|
||||
pango_layout_set_width(layoutSmall, (kWinWidth - 48) * PANGO_SCALE);
|
||||
pango_layout_set_wrap(layoutSmall, PANGO_WRAP_WORD_CHAR);
|
||||
pango_layout_set_ellipsize(layoutSmall, PANGO_ELLIPSIZE_NONE);
|
||||
pango_layout_set_text(layoutSmall, respText.c_str(),
|
||||
static_cast<int>(respText.size()));
|
||||
pango_xft_render_layout(xftDraw, &colLight, layoutSmall,
|
||||
24 * PANGO_SCALE, 116 * PANGO_SCALE);
|
||||
int lineCount = pango_layout_get_line_count(layoutSmall);
|
||||
int maxVisLines = 6;
|
||||
if (ussdScrollLine > std::max(0, lineCount - maxVisLines)) {
|
||||
ussdScrollLine = std::max(0, lineCount - maxVisLines);
|
||||
}
|
||||
int curY = 114;
|
||||
for (int li = ussdScrollLine;
|
||||
li < lineCount && (li - ussdScrollLine) < maxVisLines; ++li) {
|
||||
PangoLayoutLine* pl = pango_layout_get_line_readonly(layoutSmall, li);
|
||||
if (pl) {
|
||||
PangoRectangle ink{}, logical{};
|
||||
pango_layout_line_get_pixel_extents(pl, &ink, &logical);
|
||||
pango_xft_render_layout_line(
|
||||
xftDraw, &colLight, pl, 24 * PANGO_SCALE,
|
||||
(curY - logical.y) * PANGO_SCALE);
|
||||
curY += std::max(18, logical.height + 2);
|
||||
}
|
||||
}
|
||||
pango_layout_set_width(layoutSmall, -1);
|
||||
|
||||
drawSoftkeyBar("Send", "Send", "Close");
|
||||
}
|
||||
@@ -1414,11 +1433,16 @@ int runModemApp(int argc, char** argv) {
|
||||
"\nIMEI 2: " + (im.imei2.empty() ? "--" : im.imei2) +
|
||||
"\nIMEI SV: " + (im.imeiSv.empty() ? "--" : im.imeiSv);
|
||||
ussdWaitingReply = false;
|
||||
ussdScrollLine = 0;
|
||||
return;
|
||||
}
|
||||
ussdResponse = "Sending USSD " + ussdInput + "...";
|
||||
bool wasWaiting = ussdWaitingReply;
|
||||
std::string req = ussdInput;
|
||||
ussdScrollLine = 0;
|
||||
ussdResponse = "Sending USSD " + req + "...";
|
||||
render();
|
||||
ussdResponse = sendModemUssd(ussdInput, ussdWaitingReply, &ussdWaitingReply);
|
||||
ussdResponse = sendModemUssd(req, wasWaiting && !isUssdCode(req),
|
||||
&ussdWaitingReply);
|
||||
if (ussdWaitingReply) {
|
||||
ussdInput.clear();
|
||||
}
|
||||
@@ -1765,10 +1789,29 @@ int runModemApp(int argc, char** argv) {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (sym == XK_Up || sym == XK_KP_Up) {
|
||||
if (ussdScrollLine > 0) {
|
||||
--ussdScrollLine;
|
||||
render();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (sym == XK_Down || sym == XK_KP_Down) {
|
||||
++ussdScrollLine;
|
||||
render();
|
||||
continue;
|
||||
}
|
||||
if (sym == XK_BackSpace || sym == XK_Delete) {
|
||||
if (!ussdInput.empty()) {
|
||||
ussdInput.pop_back();
|
||||
render();
|
||||
} else {
|
||||
if (ussdWaitingReply) {
|
||||
cancelModemUssd();
|
||||
ussdWaitingReply = false;
|
||||
}
|
||||
modal = ModalMode::None;
|
||||
render();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1670,7 +1670,7 @@ inline std::string sendModemUssd(const std::string& input,
|
||||
|
||||
if (outSessionActive) {
|
||||
std::string stOut = runCaptureCmd(
|
||||
"mmcli -m any -K 2>/dev/null | grep 'modem.3gpp.ussd.state'");
|
||||
"mmcli -m any -K 2>/dev/null | grep -E 'modem\\.3gpp\\.ussd\\.(status|state)'");
|
||||
if (stOut.find("user-response") != std::string::npos) {
|
||||
*outSessionActive = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user