Add Dual-SIM Dual Standby (DSDS), outgoing SIM selection, and instant charging icon update
This commit is contained in:
1 parent
5132deb4d8
commit
46f1255905
28 files changed
+2560
-280
No files matched your search
+104
-13
@@ -30,6 +30,7 @@ enum class ViewMode {
|
||||
ConfirmDelete = 5,
|
||||
Blocklist = 6,
|
||||
AddBlock = 7,
|
||||
SelectSim = 8,
|
||||
};
|
||||
|
||||
enum class TextCaseMode {
|
||||
@@ -169,6 +170,8 @@ int runSmsApp(int argc, char** argv) {
|
||||
int selectedPicker = 0;
|
||||
int confirmSelected = 0;
|
||||
int blockSelected = 0;
|
||||
int simPickIdx = 0;
|
||||
DualSimInfo simInfo;
|
||||
std::string addBlockInput;
|
||||
|
||||
std::string activeNumber;
|
||||
@@ -341,13 +344,26 @@ int runSmsApp(int argc, char** argv) {
|
||||
};
|
||||
|
||||
auto startAsyncSendSms = [&](const std::string& rawRecipient,
|
||||
const std::string& body) {
|
||||
const std::string& body,
|
||||
int chosenSim = 0) {
|
||||
std::string recipient = normalizePhone(rawRecipient);
|
||||
if (recipient.empty() || trimStr(body).empty()) {
|
||||
statusBanner = "Set recipient and message";
|
||||
statusBannerUntilMs = nowMs() + 2000;
|
||||
return;
|
||||
}
|
||||
if (chosenSim == 0) {
|
||||
simInfo = queryDualSimInfo(false);
|
||||
if (simInfo.dualSimActive) {
|
||||
simPickIdx = (simInfo.preferredSlot == 2) ? 1 : 0;
|
||||
mode = ViewMode::SelectSim;
|
||||
return;
|
||||
}
|
||||
chosenSim = simInfo.preferredSlot;
|
||||
}
|
||||
if (chosenSim != 1 && chosenSim != 2) {
|
||||
chosenSim = 1;
|
||||
}
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(sendMutex);
|
||||
if (sendingInProgress) {
|
||||
@@ -356,12 +372,13 @@ int runSmsApp(int argc, char** argv) {
|
||||
sendingInProgress = true;
|
||||
}
|
||||
saveSmsDraft(recipient, body);
|
||||
statusBanner = "Sending SMS to " + recipient + "...";
|
||||
statusBanner = "Sending SMS (SIM " + std::to_string(chosenSim) + ") to " +
|
||||
recipient + "...";
|
||||
statusBannerUntilMs = nowMs() + 15000;
|
||||
|
||||
int writePipe = notifyPipe[1];
|
||||
std::thread([recipient, body, writePipe, &sendMutex, &sendingInProgress,
|
||||
&statusBanner, &statusBannerUntilMs]() {
|
||||
std::thread([recipient, body, chosenSim, writePipe, &sendMutex,
|
||||
&sendingInProgress, &statusBanner, &statusBannerUntilMs]() {
|
||||
std::string draftPath =
|
||||
getModemLogDirPath() + "/" + recipient + "/draft.txt";
|
||||
ContactBook::ensureParentDir(draftPath);
|
||||
@@ -370,6 +387,7 @@ int runSmsApp(int argc, char** argv) {
|
||||
out << body << "\n";
|
||||
}
|
||||
|
||||
std::string simStr = std::to_string(chosenSim);
|
||||
int rc = -1;
|
||||
pid_t pid = ::fork();
|
||||
if (pid == 0) {
|
||||
@@ -381,11 +399,11 @@ int runSmsApp(int argc, char** argv) {
|
||||
if (nullfd > 2) ::close(nullfd);
|
||||
}
|
||||
execlp("sxmo_modemsendsms.sh", "sxmo_modemsendsms.sh",
|
||||
recipient.c_str(), "-f", draftPath.c_str(),
|
||||
static_cast<char*>(nullptr));
|
||||
"--sim", simStr.c_str(), recipient.c_str(), "-f",
|
||||
draftPath.c_str(), static_cast<char*>(nullptr));
|
||||
execl("/usr/bin/sxmo_modemsendsms.sh", "sxmo_modemsendsms.sh",
|
||||
recipient.c_str(), "-f", draftPath.c_str(),
|
||||
static_cast<char*>(nullptr));
|
||||
"--sim", simStr.c_str(), recipient.c_str(), "-f",
|
||||
draftPath.c_str(), static_cast<char*>(nullptr));
|
||||
_exit(127);
|
||||
} else if (pid > 0) {
|
||||
int status = 0;
|
||||
@@ -411,12 +429,13 @@ int runSmsApp(int argc, char** argv) {
|
||||
ContactBook::ensureParentDir(smsPath);
|
||||
std::ofstream smsOut(smsPath, std::ios::app);
|
||||
if (smsOut.is_open()) {
|
||||
smsOut << "Sent at " << tbuf << ":\n" << body << "\n\n";
|
||||
smsOut << "Sent at " << tbuf << " [SIM " << chosenSim << "]:\n"
|
||||
<< body << "\n\n";
|
||||
}
|
||||
std::ofstream logOut(getModemLogFilePath(), std::ios::app);
|
||||
if (logOut.is_open()) {
|
||||
logOut << tbuf << "\tsent_txt\t" << recipient << "\t"
|
||||
<< body.size() << " chars\n";
|
||||
logOut << tbuf << "\tsent_txt\t" << recipient << "\t[SIM "
|
||||
<< chosenSim << "] " << body.size() << " chars\n";
|
||||
}
|
||||
removeSmsDraft(recipient);
|
||||
}
|
||||
@@ -424,7 +443,9 @@ int runSmsApp(int argc, char** argv) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(sendMutex);
|
||||
sendingInProgress = false;
|
||||
statusBanner = (rc == 0) ? "SMS Sent!" : "Saved to Sent (modem offline)";
|
||||
statusBanner = (rc == 0)
|
||||
? ("SMS Sent (SIM " + std::to_string(chosenSim) + ")!")
|
||||
: "Saved to Sent (modem offline)";
|
||||
statusBannerUntilMs = nowMs() + 2200;
|
||||
}
|
||||
if (writePipe >= 0) {
|
||||
@@ -944,6 +965,48 @@ int runSmsApp(int argc, char** argv) {
|
||||
i == 0 ? "No, Keep Thread" : "Yes, Delete Thread", 184);
|
||||
}
|
||||
drawSoftkeyBar("Select", "Confirm", "Cancel");
|
||||
|
||||
} else if (mode == ViewMode::SelectSim) {
|
||||
XSetForeground(dpy, gc, pt.spec.bgHeader);
|
||||
XFillRectangle(dpy, pix, gc, 0, 0, kWinWidth, 36);
|
||||
drawPango(layoutIcon, &colYellow, 8, 0, 36, kIconSim);
|
||||
drawPango(layoutMain, &colWhite, 30, 0, 36, "Select SIM for SMS", 200);
|
||||
|
||||
std::string cname = book.resolveName(composeRecipient);
|
||||
std::string toLine =
|
||||
"To: " + (cname.empty() ? composeRecipient : cname);
|
||||
drawPango(layoutSmall, &colLight, 12, 44, 22, toLine, 216);
|
||||
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
int ry = 74 + i * 74;
|
||||
bool isSel = (simPickIdx == i);
|
||||
XSetForeground(dpy, gc, isSel ? pt.spec.selBg : pt.spec.bgAltEven);
|
||||
XFillRectangle(dpy, pix, gc, 10, ry, kWinWidth - 20, 64);
|
||||
XSetForeground(dpy, gc, isSel ? pt.spec.accent : pt.spec.border);
|
||||
XDrawRectangle(dpy, pix, gc, 10, ry, kWinWidth - 21, 63);
|
||||
|
||||
std::string op = (i == 0) ? simInfo.slot1Operator : simInfo.slot2Operator;
|
||||
std::string rat = (i == 0) ? simInfo.slot1Rat : simInfo.slot2Rat;
|
||||
std::string num = (i == 0) ? simInfo.slot1Number : simInfo.slot2Number;
|
||||
if (op.empty()) op = "SIM " + std::to_string(i + 1);
|
||||
std::string title = "[" + std::to_string(i + 1) + "] SIM " +
|
||||
std::to_string(i + 1) + " - " + op;
|
||||
if (!rat.empty()) title += " [" + rat + "]";
|
||||
std::string sub = num.empty() ? "Ready" : num;
|
||||
if (simInfo.preferredSlot == (i + 1)) {
|
||||
sub += " (Default)";
|
||||
}
|
||||
|
||||
drawPango(layoutIcon, isSel ? &colYellow : &colGreen, 18, ry + 8, 22,
|
||||
kIconSim);
|
||||
drawPango(layoutMain, &colWhite, 40, ry + 8, 22, title, kWinWidth - 54);
|
||||
drawPango(layoutSmall, isSel ? &colLight : &colMuted, 40, ry + 34, 18,
|
||||
sub, kWinWidth - 54);
|
||||
}
|
||||
|
||||
drawPango(layoutSmall, &colMuted, 12, 230, 20,
|
||||
"Press 1 or 2, or Up/Down + Send", 216);
|
||||
drawSoftkeyBar("Send", "Select", "Back");
|
||||
}
|
||||
|
||||
int64_t tNow = nowMs();
|
||||
@@ -1257,6 +1320,14 @@ int runSmsApp(int argc, char** argv) {
|
||||
} else {
|
||||
mode = prevMode;
|
||||
}
|
||||
} else if (mode == ViewMode::SelectSim) {
|
||||
if (isLeft) {
|
||||
mode = ViewMode::Compose;
|
||||
startAsyncSendSms(composeRecipient, composeText,
|
||||
(simPickIdx == 1) ? 2 : 1);
|
||||
} else {
|
||||
mode = ViewMode::Compose;
|
||||
}
|
||||
}
|
||||
drawUI();
|
||||
};
|
||||
@@ -1348,7 +1419,12 @@ int runSmsApp(int argc, char** argv) {
|
||||
(kc == 177 || sym == XF86XK_PickupPhone || sym == XF86XK_Phone ||
|
||||
sym == _EVDEVK(0x1bd) || sym == _EVDEVK(0x0a9));
|
||||
if (isCallKey) {
|
||||
if (mode == ViewMode::Compose) {
|
||||
if (mode == ViewMode::SelectSim) {
|
||||
mode = ViewMode::Compose;
|
||||
startAsyncSendSms(composeRecipient, composeText,
|
||||
(simPickIdx == 1) ? 2 : 1);
|
||||
drawUI();
|
||||
} else if (mode == ViewMode::Compose) {
|
||||
startAsyncSendSms(composeRecipient, composeText);
|
||||
drawUI();
|
||||
} else if (mode == ViewMode::ThreadView && !activeNumber.empty()) {
|
||||
@@ -1590,6 +1666,21 @@ int runSmsApp(int argc, char** argv) {
|
||||
} else if (sym == XK_Return || sym == XK_KP_Enter) {
|
||||
handleSoftkeyAction(true);
|
||||
}
|
||||
} else if (mode == ViewMode::SelectSim) {
|
||||
char d = mapDialKey(sym, kc, ev.xkey.state);
|
||||
if (d == '1') {
|
||||
simPickIdx = 0;
|
||||
handleSoftkeyAction(true);
|
||||
} else if (d == '2') {
|
||||
simPickIdx = 1;
|
||||
handleSoftkeyAction(true);
|
||||
} else if (sym == XK_Up || sym == XK_Down || sym == XK_KP_Up ||
|
||||
sym == XK_KP_Down) {
|
||||
simPickIdx = 1 - simPickIdx;
|
||||
drawUI();
|
||||
} else if (sym == XK_Return || sym == XK_KP_Enter) {
|
||||
handleSoftkeyAction(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user