Add Bluetooth audio/HID/discoverability/alias support, fix SD card hotplug & caller ID matching, and expand ReMEdy J2ME JSRs + 64MB GC

This commit is contained in:
Luxferre committed 2026-11-01 16:18:04 +02:00
1 parent 456d3fbc42
commit 471916424e
51 files changed
+2961 -305

No files matched your search

+43 -13
View File
@@ -296,8 +296,13 @@ class PhoneController {
std::string outDev = readActiveOutputDevice();
bool outMuted = (readIntFile("/tmp/sxmo_out_muted", 0) == 1);
// 1. Primary output volume (Speaker or Headphones if Headphones are active, linear 0..100%)
if (outDev == "Headphones") {
// 1. Primary output volume (Speaker, Headphones, or Bluetooth, linear 0..100%)
if (outDev == "Bluetooth") {
int btPct = readIntFile(getSxmoCfgDir() + "/bluetooth_vol", 80);
btPct = std::clamp(((btPct + 2) / 5) * 5, 0, 100);
items_.push_back({ControlId::SpeakerVol, kIconHeadphones, kIconSoundOff,
"Bluetooth", true, 0, 100, 5, btPct});
} else if (outDev == "Headphones") {
int hpPct = readIntFile(getSxmoCfgDir() + "/headphones_vol", -1);
if (hpPct < 0 || hpPct > 100) {
long rx1 = alsa_.getInteger("RX1 Digital Volume", 78);
@@ -365,10 +370,12 @@ class PhoneController {
items_.push_back({ControlId::Flashlight, kIconFlashlight, kIconFlashlight,
"Flashlight", false, 0, 1, 1, (torchCur > 0) ? 1 : 0});
// 7. Audio Output Route / Mute (0=Muted, 1=Speaker, 2=Earpiece, 3=Headphones)
// 7. Audio Output Route / Mute (0=Muted, 1=Speaker, 2=Earpiece, 3=Headphones, 4=Bluetooth)
int outMode = 1;
if (outMuted) {
outMode = 0;
} else if (outDev == "Bluetooth") {
outMode = 4;
} else if (outDev == "Earpiece") {
outMode = 2;
} else if (outDev == "Headphones") {
@@ -376,11 +383,11 @@ class PhoneController {
} else {
outMode = 1;
}
const char* outIcon = (outMode == 3) ? kIconHeadphones
const char* outIcon = (outMode == 3 || outMode == 4) ? kIconHeadphones
: (outMode == 2) ? kIconEarpiece
: kIconSoundOn;
items_.push_back({ControlId::SoundMute, outIcon, kIconSoundOff,
"Output", false, 0, 3, 1, outMode});
"Output", false, 0, 4, 1, outMode});
// 8. Microphone on/off (toggle)
unsigned int dec1 = alsa_.getEnum("DEC1 MUX", 1);
@@ -435,8 +442,10 @@ class PhoneController {
ControlItem& it = items_[idx];
if (it.isSlider) {
it.value = std::clamp(it.value + dir * it.stepVal, it.minVal, it.maxVal);
} else if (it.id == ControlId::RingerMode || it.id == ControlId::SoundMute) {
} else if (it.id == ControlId::RingerMode) {
it.value = (it.value + dir + 4) % 4;
} else if (it.id == ControlId::SoundMute) {
it.value = (it.value + dir + 5) % 5;
} else if (it.id == ControlId::VibrateStrength) {
it.value = ((it.value - 1 + dir + 3) % 3) + 1;
} else {
@@ -450,9 +459,12 @@ class PhoneController {
return;
}
ControlItem& it = items_[idx];
if (it.id == ControlId::RingerMode || it.id == ControlId::SoundMute) {
if (it.id == ControlId::RingerMode) {
it.value = (it.value + 1) % 4;
apply(it);
} else if (it.id == ControlId::SoundMute) {
it.value = (it.value + 1) % 5;
apply(it);
} else if (it.id == ControlId::VibrateStrength) {
it.value = (it.value % 3) + 1;
apply(it);
@@ -479,6 +491,10 @@ class PhoneController {
if (dev.empty()) {
dev = readLine(getSxmoCfgDir() + "/audio_out_device");
}
if (dev.find("Bluetooth") != std::string::npos || dev.find("bluetooth") != std::string::npos ||
dev.find("bluez") != std::string::npos) {
return "Bluetooth";
}
if (dev.find("Earpiece") != std::string::npos || dev.find("earpiece") != std::string::npos) {
return "Earpiece";
}
@@ -589,7 +605,15 @@ class PhoneController {
std::string cfg = getSxmoCfgDir();
::mkdir(cfg.c_str(), 0755);
std::string outDev = readActiveOutputDevice();
if (outDev == "Headphones") {
if (outDev == "Bluetooth") {
writeIntFile(cfg + "/bluetooth_vol", it.value);
writeIntFile("/tmp/sxmo_out_muted", (it.value <= 0) ? 1 : 0);
char cmd[160];
std::snprintf(cmd, sizeof(cmd),
"sxmo_audio.sh vol set %d Bluetooth >/dev/null 2>&1",
it.value);
runAsyncCmd(cmd);
} else if (outDev == "Headphones") {
writeIntFile(cfg + "/headphones_vol", it.value);
writeIntFile("/tmp/sxmo_out_muted", (it.value <= 0) ? 1 : 0);
long hw = (it.value <= 0) ? 0 : (52 + std::lround((it.value * 32.0) / 100.0));
@@ -670,10 +694,11 @@ class PhoneController {
runAsyncCmd("sxmo_audio.sh vol mute >/dev/null 2>&1");
} else {
writeIntFile("/tmp/sxmo_out_muted", 0);
const char* targetDev = (it.value == 2) ? "Earpiece"
const char* targetDev = (it.value == 4) ? "Bluetooth"
: (it.value == 3) ? "Headphones"
: (it.value == 2) ? "Earpiece"
: "Speaker";
it.iconOn = (it.value == 3) ? kIconHeadphones
it.iconOn = (it.value == 3 || it.value == 4) ? kIconHeadphones
: (it.value == 2) ? kIconEarpiece
: kIconSoundOn;
{
@@ -681,7 +706,12 @@ class PhoneController {
if (ofs) ofs << targetDev << "\n";
}
if (!items_.empty() && items_[0].id == ControlId::SpeakerVol) {
if (it.value == 3) {
if (it.value == 4) {
int btPct = readIntFile(getSxmoCfgDir() + "/bluetooth_vol", 80);
items_[0].label = "Bluetooth";
items_[0].iconOn = kIconHeadphones;
items_[0].value = std::clamp(((btPct + 2) / 5) * 5, 0, 100);
} else if (it.value == 3) {
int hpPct = readIntFile(getSxmoCfgDir() + "/headphones_vol", 80);
items_[0].label = "Headphones";
items_[0].iconOn = kIconHeadphones;
@@ -954,8 +984,8 @@ static int xdrawer_run_main(int argc, char** argv) {
: ((it.value == 1) ? &colYellow : &colMuted);
drawPango(layoutSmall, rCol, kWinWidth - stW - 6, ry, rowH, stStr);
} else if (it.id == ControlId::SoundMute) {
const char* oModes[4] = {"Muted", "Speaker", "Earpiece", "Headset"};
std::string stStr = std::string("< ") + oModes[std::clamp(it.value, 0, 3)] + " >";
const char* oModes[5] = {"Muted", "Speaker", "Earpiece", "Headset", "Bluetooth"};
std::string stStr = std::string("< ") + oModes[std::clamp(it.value, 0, 4)] + " >";
int stW = pangoWidth(layoutSmall, stStr);
XftColor* oCol = (it.value > 0) ? (isSel ? &colYellow : &colGreen) : &colMuted;
drawPango(layoutSmall, oCol, kWinWidth - stW - 6, ry, rowH, stStr);