Implement SD card autodetection, automount, and GUI/dmenu mounter
- Enable GPIO 38 active-low card detect (cd-gpios) with bias-pull-up on sdhci@7864000 across all MSM8905/MSM8909 device trees and DTBs - Add sxmo_sdcard.sh and 88-bananarchy-sdcard.rules udev rules for automatic mounting at /media/sdcard on insertion and cleanup on removal - Integrate SD card mount, unmount/eject, and navigation into the GUI File Manager (files.so) and built-in dmenu SD Card menu (@menu:sdcard)
This commit is contained in:
1 parent
370f8b085c
commit
32d5d2f2b4
26 files changed
+530
-24
No files matched your search
@@ -750,10 +750,22 @@ int runFilesApp(int argc, char** argv) {
|
||||
statusBannerUntilMs = nowMs() + 2200;
|
||||
};
|
||||
|
||||
auto isSdCardMounted = []() -> bool {
|
||||
std::ifstream f("/proc/mounts");
|
||||
std::string line;
|
||||
while (std::getline(f, line)) {
|
||||
if (line.find(" /media/sdcard ") != std::string::npos) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
auto buildActionsList = [&]() {
|
||||
actionsList.clear();
|
||||
bool hasSel = !filteredItems.empty();
|
||||
bool isParent = hasSel && filteredItems[selected].isParent;
|
||||
bool sdMounted = isSdCardMounted();
|
||||
|
||||
if (hasSel) {
|
||||
if (!filteredItems[selected].isDir) {
|
||||
@@ -807,6 +819,14 @@ int runFilesApp(int argc, char** argv) {
|
||||
else if (sortMode == SortMode::Date) sortLbl += "Size (#)";
|
||||
else sortLbl += "Name (#)";
|
||||
actionsList.push_back({11, kIconSort, sortLbl});
|
||||
if (sdMounted) {
|
||||
if (currentDir != "/media/sdcard") {
|
||||
actionsList.push_back({18, kIconFolderOpen, "Open SD Card (/media/sdcard)"});
|
||||
}
|
||||
actionsList.push_back({19, kIconOutCall, "Unmount / Eject SD Card"});
|
||||
} else {
|
||||
actionsList.push_back({20, kIconFolder, "Mount SD Card (/media/sdcard)"});
|
||||
}
|
||||
actionsList.push_back({12, kIconTerm, "Open Terminal Here"});
|
||||
actionSelected = 0;
|
||||
};
|
||||
@@ -1667,6 +1687,34 @@ int runFilesApp(int argc, char** argv) {
|
||||
filteredItems[selected].name);
|
||||
} else if (actId == 17 && !filteredItems.empty()) {
|
||||
openTextViewer(filteredItems[selected]);
|
||||
} else if (actId == 18) {
|
||||
loadDirectory("/media/sdcard");
|
||||
mode = ViewMode::Browser;
|
||||
} else if (actId == 19) {
|
||||
if (currentDir.rfind("/media/sdcard", 0) == 0) {
|
||||
loadDirectory(homeDir);
|
||||
}
|
||||
int rc = std::system("sxmo_sdcard.sh unmount >/dev/null 2>&1");
|
||||
loadDirectory(currentDir);
|
||||
statusBanner = (rc == 0 && !isSdCardMounted())
|
||||
? "SD card unmounted"
|
||||
: "Unmount failed (busy)";
|
||||
statusBannerUntilMs = nowMs() + 2200;
|
||||
mode = ViewMode::Browser;
|
||||
} else if (actId == 20) {
|
||||
mode = ViewMode::Browser;
|
||||
statusBanner = "Scanning SD card slot...";
|
||||
statusBannerUntilMs = nowMs() + 2500;
|
||||
drawUI();
|
||||
int rc = std::system("sxmo_sdcard.sh mount >/dev/null 2>&1");
|
||||
if (rc == 0 && isSdCardMounted()) {
|
||||
loadDirectory("/media/sdcard");
|
||||
statusBanner = "SD card mounted";
|
||||
} else {
|
||||
loadDirectory(currentDir);
|
||||
statusBanner = "No SD card detected";
|
||||
}
|
||||
statusBannerUntilMs = nowMs() + 2200;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user