Merge pull request #8 from dminor/bug-894958-fix

Bug 894958 - Improve Negatus support for Linux; r=mcote
This commit is contained in:
Dan Minor 2014-01-30 06:44:43 -08:00
Родитель fed5d6bfe1 0d878f1d41
Коммит cf70710ad2
3 изменённых файлов: 18 добавлений и 5 удалений

Просмотреть файл

@ -4,6 +4,7 @@ CXX=g++
LD:=$(CXX)
CPPFLAGS=\
-DNEGATUS_LINUX_DESKTOP_BUILD \
-g \
$(shell nspr-config --cflags)

Просмотреть файл

@ -463,7 +463,11 @@ CommandEventHandler::os()
{
// not really supported yet. Best we could do is
// cat /system/sources.xml | grep gaia and another grep for m-c
#ifdef NEGATUS_LINUX_DESKTOP_BUILD
return std::string("linux");
#else
return std::string("B2G");
#endif
}
@ -527,14 +531,14 @@ CommandEventHandler::memory()
return agentWarn("Error on fopen: /proc/meminfo, with mode r");
}
unsigned int total, available;
unsigned long total, available;
char buffer[BUFSIZE];
fgets(buffer, BUFSIZE, meminfo);
sscanf(buffer + getFirstIntPos(buffer, BUFSIZE), "%u", &total);
sscanf(buffer + getFirstIntPos(buffer, BUFSIZE), "%lu", &total);
fgets(buffer, BUFSIZE, meminfo);
sscanf(buffer + getFirstIntPos(buffer, BUFSIZE), "%u", &available);
sscanf(buffer + getFirstIntPos(buffer, BUFSIZE), "%lu", &available);
sprintf(buffer, "Total: %d; Available: %d.", total * 1000, available * 1000);
sprintf(buffer, "Total: %lu; Available: %lu.", total * 1000, available * 1000);
return std::string(buffer);
}
@ -559,8 +563,12 @@ CommandEventHandler::power()
std::string
CommandEventHandler::ps(std::vector<std::string>& args)
{
// might need to change command on linux since the output is different on B2G
#ifdef NEGATUS_LINUX_DESKTOP_BUILD
// remove leading space and extra spaces between columns
return getCmdOutput("ps --no-header -eo pid,uid,comm |sed \"s/^\\s\\+//;s/\\s\\+/ /\"");
#else
return getCmdOutput("ps | tr -s \" \" | cut -d' ' -f1,2,9 | tail +2");
#endif
}

Просмотреть файл

@ -9,7 +9,11 @@
#define SD_CARD_MOUNT "/mnt/sdcard"
#define TESTROOT_SD_CARD "/mnt/sdcard/test"
#ifdef NEGATUS_LINUX_DESKTOP_BUILD
#define TESTROOT_NO_SD_CARD "/tmp"
#else
#define TESTROOT_NO_SD_CARD "/data/local/tmp"
#endif
class Config
{