aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* tools: ipc-modem: get rid of state global variableDenis 'GNUtoo' Carikli2022-03-282-19/+20
| | | | | | | Since we now have a private struct for all the data we need, we don't need to use global variables anymore. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: get rid of out_call global variableDenis 'GNUtoo' Carikli2022-03-282-10/+11
| | | | | | | Since we now have a private struct for all the data we need, we don't need to use global variables anymore. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: get rid of call_done global variableDenis 'GNUtoo' Carikli2022-03-282-4/+3
| | | | | | | Since we now have a private struct for all the data we need, we don't need to use global variables anymore. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: get rid of in_call global variableDenis 'GNUtoo' Carikli2022-03-282-20/+21
| | | | | | | Since we now have a private struct for all the data we need, we don't need to use global variables anymore. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: get rid of sim_pin global variableDenis 'GNUtoo' Carikli2022-03-282-17/+18
| | | | | | | Since we now have a private struct for all the data we need, we don't need to use global variables anymore. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: get rid of call_number global variableDenis 'GNUtoo' Carikli2022-03-282-22/+23
| | | | | | | Since we now have a private struct for all the data we need, we don't need to use global variables anymore. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: move ipc_client struct in private data structDenis 'GNUtoo' Carikli2022-03-282-55/+53
| | | | | | | Having everything needed in the same struct will simplify the code later on as we could also move the global variables there as well. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: Add syslog supportDenis 'GNUtoo' Carikli2022-03-282-20/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is ongoing work to make libsamsung-ipc and the modem drivers of the Galaxy SIII (GT-I9300) work on top of an upstream kernel instead of kernels derived from the vendor kernels. For that work it's convenient to be able to store the kernel the kernel logs in systemd-journald along with the output of ipc-modem. If the kernel is built with CONFIG_LOCALVERSION_AUTO, we can track the exact kernel revision used. And if the modem driver crashed, we can still have the logs in journald at the next reboot. It also enables us to store logs over a long period of time and get back to old logs. However when running ipc-modem through a systemd service unit, the output is piped to systemd, and we only get the following output with journalctl -u <service> .service: Started [Service Unit Description]. This is because when a program is piped, line buffering changes from line buffered (the default when outputing to stdout on a terminal according to setbuf(3)) to fully buffered. To fix that we add a syslog log-target. Several programs already have a --syslog (like OpenVPN) or --log-target= (like PulseAudio) command line argument. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: use the log callback instead of printfDenis 'GNUtoo' Carikli2022-03-282-86/+173
| | | | | | | | | | This enables to add other log callbacks than printf / stdout later on. The ipc_modem_log function is inspired from ipc_client_log. This change should contain no functional changes. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: group contiguous printf callsDenis 'GNUtoo' Carikli2022-03-281-17/+17
| | | | | | | | | | | | There is no use in making multiple calls to printf when only one call is sufficient. It's also a good practice to do that in general, especially when part of the code can print to the console at any time, to ensure that that all the buffer is printed contiguously and not interleaved with other prints. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: move definitions in ipc-modem.hDenis 'GNUtoo' Carikli2022-03-282-17/+43
| | | | | | | | | This enables to add more definitions later and to also add functions prototypes there. This change contains no functional changes. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: getopt_long: shorten nested ifsDenis 'GNUtoo' Carikli2022-03-281-36/+29
| | | | | | | This makes the code more readable. It should contain no functional changes. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tests: ipc-modem: add phone number argument testDenis 'GNUtoo' Carikli2022-03-281-0/+14
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: nv_data_imei: use const arrays of structs with static storage durationDenis 'GNUtoo' Carikli2022-03-282-21/+21
| | | | | | | This ensures that the content of theses arrays cannot be changed at runtime. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* scripts: guix.scm: add -Werror=pedantic to detect Replicant 6.0 warningsDenis 'GNUtoo' Carikli2022-03-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without the commit 355433ab5f17f25ca202ec092d989b267fd78c19 (tools: nv_data_imei: get rid of missing initializer warning), we have the following warnings when building Replicant 6.0: hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:245:2: warning: missing initializer for field 'option' of 'struct command_option' [-Wmissing-field-initializers] { /* Sentinel */ }, ^ In file included from hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:39:0: hardware/replicant/libsamsung-ipc/tools/nv_data-imei.h:65:10: note: 'option' declared here uint8_t option; ^ hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:277:2: warning: missing initializer for field 'name' of 'struct command' [-Wmissing-field-initializers] { /* Sentinel */ }, ^ In file included from hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:39:0: hardware/replicant/libsamsung-ipc/tools/nv_data-imei.h:57:14: note: 'name' declared here const char *name; ^ The addition of -Werror=pedantic in guix.scm enables to detect these as the build would then fail: CC nv_data-imei.o nv_data-imei.c:245:2: error: ISO C forbids empty initializer braces [-Werror=pedantic] 245 | { /* Sentinel */ }, | ^ nv_data-imei.c:277:2: error: ISO C forbids empty initializer braces [-Werror=pedantic] 277 | { /* Sentinel */ }, | ^ CC nv_data-md5.o Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: nv_data_imei: get rid of missing initializer warningDenis 'GNUtoo' Carikli2022-03-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without that fix, we have the following warnings on Replicant 6.0: hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:245:2: warning: missing initializer for field 'option' of 'struct command_option' [-Wmissing-field-initializers] { /* Sentinel */ }, ^ In file included from hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:39:0: hardware/replicant/libsamsung-ipc/tools/nv_data-imei.h:65:10: note: 'option' declared here uint8_t option; ^ hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:277:2: warning: missing initializer for field 'name' of 'struct command' [-Wmissing-field-initializers] { /* Sentinel */ }, ^ In file included from hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:39:0: hardware/replicant/libsamsung-ipc/tools/nv_data-imei.h:57:14: note: 'name' declared here const char *name; ^ Note that even if the code isn't valid C17 code, the warning is harmless since the arrays of struct is declared outside functions (static storage duration), so the "Sentinel" will be filled with zeros anyway. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* partitions: android: silence compiler warningDenis 'GNUtoo' Carikli2022-03-281-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Without that fix, when building the 'libsamsung-ipc' package through scripts/guix.scm, we have the following warning: CC partitions/android/android.lo partitions/android/android.c: In function ‘open_android_modem_partition_by_name’: partitions/android/android.c:87:3: warning: ‘strncpy’ specified bound depends on the length of the source argument [-Wstringop-overflow=] 87 | strncpy(path, partitions_dirnames[i], | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 88 | strlen(partitions_dirnames[i])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CC partitions/toc/toc.lo CCLD libsamsung-ipc.la The warning is hamless because: - The source (partitions_dirnames[i]) is hardcoded. - The desitination buffer size was allocated more space than the length of partitions_dirnames[i]. However it's good to silence non problematic warnings in order to better detect really serious issues. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* samsung-ipc: ipc_group_string: fix unknown group caseDenis 'GNUtoo' Carikli2022-03-281-1/+1
| | | | | | | | This was introduced by the commit 5a643dd89e2636cea19d9642c3a205d2d20250ec (ipc_utils: add ipc_group_string) Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-imei: fix printf size_t integer conversionDenis 'GNUtoo' Carikli2022-03-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without that fix we have compilation errors: nv_data-imei.c: In function ‘get_imei’: nv_data-imei.c:181:12: error: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=] 181 | printf("In addition it is also invalid" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ...... 184 | len, IMEI_LENGTH); | ~~~ | | | size_t {aka long unsigned int} nv_data-imei.c:183:14: note: format string is defined here 183 | "%d digits instead of %d.\n", | ~^ | | | int | %ld nv_data-imei.c:193:12: error: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=] 193 | printf("The '%s' " | ^~~~~~~~~~~ ...... 196 | imei->optarg, len, IMEI_LENGTH); | ~~~ | | | size_t {aka long unsigned int} nv_data-imei.c:195:14: note: format string is defined here 195 | "%d digits instead of %d.\n", | ~^ | | | int | %ld This issue was introduced in commit 1cd1a569bef21ed3bfaeda15fb210ef6fd218152 (tools: Add a new nv_data-imei tool based on rfs-imei) Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Add tools to build all the last commitsDenis 'GNUtoo' Carikli2022-03-282-0/+183
| | | | | | | This makes it easier to build-test all the latest commits before sending patches or pushing patches. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Android.mk: enable to build libsamsung-ipc for all devicesDenis 'GNUtoo' Carikli2022-03-281-3/+5
| | | | | | | | | | | | | | | | | | For now -DIPC_DEVICE_NAME is only used to force to use a specific device driver instead of trying to find out automatically which driver to use. So with it all the drivers are still compiled in and there is only one string that changes between builds with different -DIPC_DEVICE_NAME. There are some advantages in being able to not use -DIPC_DEVICE_NAME: - If one day, only the relevant driver(s) are compiled with -DIPC_DEVICE_NAME, we would still be able to compile-test all the code by not setting -DIPC_DEVICE_NAME. - Not hardcoding the device name would be a good step toward having Android images that work on multiple devices. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Add PKGBUILDDenis 'GNUtoo' Carikli2022-01-241-0/+52
| | | | | | | The usage of this PKGBUILD is similar to the guix.scm file in the same directory: it can be used to test the build of the current source. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tests: nv_data-md5: fix test with out of tree buildsDenis 'GNUtoo' Carikli2022-01-241-4/+10
| | | | | | | | | | | | | | | | | | | | | | When running the tests in an out of tree build directory (here in scripts/src/), without that fix, we have the following error in src/samsung-ipc/tests/test-suite.log when running 'make check': FAIL: nv_data-md5 ================= Traceback (most recent call last): File "[...]/scripts/src/tools/../../../tools/nv_data-md5.py", line 69, in <module> rc = main() File "[...]/scripts/src/tools/../../../tools/nv_data-md5.py", line 64, in main nv_data_md5 = NvDataMD5() File "[...]/scripts/src/tools/../../../tools/nv_data-md5.py", line 39, in __init__ self.nv_data_md5 = sh.Command(srcdir + os.sep + 'nv_data-md5') File "/usr/lib/python3.9/site-packages/sh.py", line 1342, in __init__ raise CommandNotFound(path) sh.CommandNotFound: ../../../tools/nv_data-md5 FAIL nv_data-md5.py (exit status: 1) Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tests: nv_data-imei: fix test with out of tree buildsDenis 'GNUtoo' Carikli2022-01-241-4/+11
| | | | | | | | | | | | | | | | | | | | | | When running the tests in an out of tree build directory (here in scripts/src/), without that fix, we have the following error in src/samsung-ipc/tests/test-suite.log when running 'make check': FAIL: nv_data-imei ================== Traceback (most recent call last): File "[...]/scripts/src/tools/../../../tools/nv_data-imei.py", line 122, in <module> rc = main() File "[...]/scripts/src/tools/../../../tools/nv_data-imei.py", line 117, in main nv_data_imei = NvDataImei() File "[...]/scripts/src/tools/../../../tools/nv_data-imei.py", line 53, in __init__ self.nv_data_imei = sh.Command(srcdir + os.sep + 'nv_data-imei') File "/usr/lib/python3.9/site-packages/sh.py", line 1342, in __init__ raise CommandNotFound(path) sh.CommandNotFound: ../../../tools/nv_data-imei FAIL nv_data-imei.py (exit status: 1) Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tests: ipc-modem: fix test with out of tree buildsDenis 'GNUtoo' Carikli2022-01-241-4/+10
| | | | | | | | | | | | | | | | | | | | | | When running the tests in an out of tree build directory (here in scripts/src/), without that fix, we have the following error in src/samsung-ipc/tests/test-suite.log when running 'make check': FAIL: ipc-modem =============== Traceback (most recent call last): File "[...]/scripts/src/tools/../../../tools/ipc-modem.py", line 79, in <module> rc = main() File "[...]/scripts/src/tools/../../../tools/ipc-modem.py", line 74, in main ipc_modem = IpcModem() File "[...]/scripts/src/tools/../../../tools/ipc-modem.py", line 39, in __init__ ipc_modem = sh.Command(srcdir + os.sep + 'ipc-modem') File "/usr/lib/python3.9/site-packages/sh.py", line 1342, in __init__ raise CommandNotFound(path) sh.CommandNotFound: ../../../tools/ipc-modem FAIL ipc-modem.py (exit status: 1) Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tests: libsamsung-ipc-test: fix test with out of tree buildsDenis 'GNUtoo' Carikli2022-01-241-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When running the tests in an out of tree build directory (here in scripts/src/), without that fix, we have the following error in src/samsung-ipc/tests/test-suite.log when running 'make check': ============================================================ libsamsung-ipc 0.7.0: samsung-ipc/tests/test-suite.log ============================================================ # TOTAL: 1 # PASS: 0 # SKIP: 0 # XFAIL: 0 # FAIL: 1 # XPASS: 0 # ERROR: 0 .. contents:: :depth: 2 FAIL: libsamsung-ipc-test ========================= Traceback (most recent call last): File "[...]/scripts/src/samsung-ipc/tests/../../../../samsung-ipc/tests/libsamsung-ipc-test.py", line 54, in <module> main() File "[...]/scripts/src/samsung-ipc/tests/../../../../samsung-ipc/tests/libsamsung-ipc-test.py", line 50, in main tests = libsamsung_ipc_test() File "[...]/scripts/src/samsung-ipc/tests/../../../../samsung-ipc/tests/libsamsung-ipc-test.py", line 33, in __init__ self.run = sh.Command(srcdir + os.sep + "libsamsung-ipc-test") File "/usr/lib/python3.9/site-packages/sh.py", line 1342, in __init__ raise CommandNotFound(path) sh.CommandNotFound: ../../../../samsung-ipc/tests/libsamsung-ipc-test FAIL libsamsung-ipc-test.py (exit status: 1) Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tests: python: unify string quotes as per PEP 8Denis 'GNUtoo' Carikli2022-01-244-44/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Having a code style makes the code easier to read. As for which code style to use, the code style defined by the PEP 8 [1] is used in the python standard library and in the main Python distribution. Its official nature (it's standardized by python) probably makes it the most well known and used code style adopted by python programmers. In it we have a section about string quotes: String Quotes ------------- In Python, single-quoted strings and double-quoted strings are the same. This PEP does not make a recommendation for this. Pick a rule and stick to it. When a string contains single or double quote characters, however, use the other one to avoid backslashes in the string. It improves readability. For triple-quoted strings, always use double quote characters to be consistent with the docstring convention in PEP 257. Since "if __name__ == '__main__':" is widely used, we choose to use the single quotes. [1]https://www.python.org/dev/peps/pep-0008/ Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* scripts: Add manifest.scmDenis 'GNUtoo' Carikli2022-01-041-0/+48
| | | | | | | | | | | | | | | | | On Guix, if we have all the required dependencies installed, running ./autogen.sh && ./configure && make fails with the following error: CCLD libsamsung-ipc-test ld: /gnu/store/cm6wv72061h65lri2aqgwa8bvncls51h-openssl-1.1.1l/lib/libcrypto.so: undefined reference to `fstat@GLIBC_2.33' ld: /gnu/store/cm6wv72061h65lri2aqgwa8bvncls51h-openssl-1.1.1l/lib/libcrypto.so: undefined reference to `stat@GLIBC_2.33' The same command works when using guix shell or guix environment (still with all the dependencies). Having a manifest file in libsamsung-ipc will enable Guix system users to easily work on libsamsung-ipc without having to use trial and error to get a working setup. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: Add testsreplicant-6.0-0004-transitionreplicant-6.0-0004-rc6replicant-6.0-0004Denis 'GNUtoo' Carikli2021-09-013-2/+85
| | | | | | | While the tests don't talk to a real modem, they are still useful to detect regressions with the use of threads. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Add dry-run mode for automatic testingDenis 'GNUtoo' Carikli2021-09-011-2/+41
| | | | | | | | This enables to test things like the threads usage without the need for a real modem implementing the samsung-ipc protocol. This could for instance be used in libsamsung-ipc automated tests. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: move command line options prints in its own functionDenis 'GNUtoo' Carikli2021-09-011-1/+9
| | | | | | | As this is done once all options have been parsed, it enables to only print some options when debug is on. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: move parsed command line arguments in a structDenis 'GNUtoo' Carikli2021-09-011-12/+22
| | | | | | | | This enables to more easily enables to share the parsed command line arguments across different functions and it also enables to add new command line arguments more easily. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: Fail if there is no chosen commandDenis 'GNUtoo' Carikli2021-09-011-1/+11
| | | | | | | | | | | | | | | Without that fix, if some arguments were set and no command was given, ipc-modem would proceed anyway: $ ./tools/ipc-modem --debug [I] Debug enabled [...] As it's expected to at least be used with a command to do something meaningful, without that fix, it could misslead users into thinking that everything is fine when it's not or vice versa. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: move ipc code outside of mainDenis 'GNUtoo' Carikli2021-09-011-48/+83
| | | | | | | | | | This makes the code easier to read as we separate the command line handling from the IPC code. In addition it also enables to more easily add RFS support later on as the IPC code is not mixed with command line handling. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: Add --help in the helpDenis 'GNUtoo' Carikli2021-09-011-0/+1
| | | | | | | While --help is parsed in the command line, it wasn't described in the help itself. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: small code cleanups for the command line interfaceDenis 'GNUtoo' Carikli2021-09-011-30/+30
| | | | | | | | The help and the code is sorted alphabetically. It should contain no functional changes. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Add ipc_client_type_stringDenis 'GNUtoo' Carikli2021-09-013-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | When working on applications using libsamsung-ipc, we sometimes have functions that have an ipc client type argument and that work for all 3 ipc client types, or want to refactorize the code to do that in order to make the code more clean and generic. However in these cases, these functions often needed to output some error message or tell users what is going on through logging prints, and the code ends up being way cleaner if there is a generic function to get the name of the ipc client type. In many cases it makes sense not to use the full IPC_CLIENT_TYPE_<type> name but only the <name> type in these messages, so because it's easier to add IPC_CLIENT_TYPE_ to the <type> than removing it, it makes sense to only return the string associated to the type (like "FMT", "RFS" or "DUMMY". The least significant number of the library version was also bumped as we are adding a new function, but the applications that were built against older libsamsung-ipc revisions should still work. However applications that depends on this ipc_client_type_string will not work with previous versions of libsamsung-ipc. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Move string functions in their own fileDenis 'GNUtoo' Carikli2021-09-014-366/+391
| | | | | | | | | | | There are already 4 string functions and combined together, they already take more than 300 lines, so it makes sense to move them in a separate file. In addition, it will also clarify in which files new string functions are supposed to be added in. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Android.mk: Add static ipc-modem for drop-in testsDenis 'GNUtoo' Carikli2021-09-011-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Replicant 6.0, ipc-modem is shipped in the images. When it will make it in released images, it will be very useful for regression testing and for tests that don't involve the full Android stack[1]. For such tests to work, users are expected to disable the modem (with 'modem.sh off') before. In this configuration, the test utilities like ipc-modem use the system libsamsung-ipc as they are linked dynamically against it. However if we want to also do regression testing with code that is being worked on, it's very convenient to build test utilities that have libsamsung-ipc built-in: This way it can test our the code that is being worked on without interfering in any way with the Android stack. The static version of ipc-modem can for instance be built with the following commands in the Replicant source code directory: $ source build/envsetup.sh $ lunch replicant_i9300-userdebug $ make ipc-modem-static It can then be run with the following commands (for the GT-I9300): $ adb root $ adb remount $ adb push \ out/target/product/i9300/system/bin/ipc-modem-static \ /system/bin/ $ adb shell "modem.sh off" $ adb wait-for-device $ adb root $ adb shell ipc-modem-static [...] Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* gitignore: add forgotten test filesDenis 'GNUtoo' Carikli2021-09-011-0/+12
| | | | | | | | | | | Running tests (and even just running autogen.sh) produces files used during the tests, and so git has to ignore these as they are produced during the build procedure. Ideally they should have been added to gitignore when I added the tests that generated these files but I forgot. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* gitignore: Add forgetten nv_data-imeiDenis 'GNUtoo' Carikli2021-09-011-0/+1
| | | | | | | Without this patch, after compiling libsamsung-ipc, git status shows tools/nv_data-imei in the list of untracked files. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* gitignore: Also ignore Emacs and Vim swap filesDenis 'GNUtoo' Carikli2021-09-011-0/+4
| | | | | | | | | | | Text editors produce temporary files. They can often be used to recover data in case of computer crash or abrupt shut down. However when using text editors like Emacs and Vim, temporary files often end up in the source directory, so as they are not part of the official libsamsung-ipc source code we need to tell git to ignore them. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: fix nv-data-md5 compilation with Replicant 6replicant-6.0-0004-rc5-transitionreplicant-6.0-0004-rc5Denis 'GNUtoo' Carikli2021-03-172-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | When compiling nv-data-md5 under Replicant 6 we have: hardware/replicant/libsamsung-ipc/tools/nv_data-md5.c: In function 'main': hardware/replicant/libsamsung-ipc/tools/nv_data-md5.c:103:1: error: control reaches end of non-void function [-Werror=return-type] } ^ cc1: some warnings being treated as errors So we simply need to add a return in the error path. While we're at it, we use an exit code referenced in sysexits.h to follow a standard. This can help differentiating between different types of errors. Thanks to that, it can also simplify the code when writing tests. As Android doesn't have sysexits.h, we also need to use the one that has been copied inside libsamsung-ipc in tools/include/glibc, else it would also fail to compile because of the missing header file. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: add option to call a numberDenis 'GNUtoo' Carikli2021-03-171-10/+27
| | | | | | | | | | | | | | | The ipc-modem tool contained commented code to call a specific phone number. This patch reuses that code and retrieve the number to call from the command line. The number to call is expected to be in the same country as the caller SIM card and network. Adding support for international calls could be done by computing the right prefix instead of hardcoding the IPC_CALL_PREFIX_NONE prefix. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: fix potential out of bounds sim_pin memcpyDenis 'GNUtoo' Carikli2021-03-171-11/+12
| | | | | | | | | | If for instance "1234" is given as pin, the size of optarg should be 5 but memcpy would copy 8. In addition, the current code also makes sure that there is a terminating null byte ('\0') inside the sim_pin array. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: remove unused DEF_SIM_PIN definitionDenis 'GNUtoo' Carikli2021-03-171-1/+0
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* partitions: android: Add open_android_modem_partition_by_nameDenis 'GNUtoo' Carikli2021-03-042-0/+65
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Partitions: android: add tests for open_android_modem_partitionDenis 'GNUtoo' Carikli2021-03-048-3/+366
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Libraries typically have a public API and some internal implementation of that API. In libsamsung-ipc, the public API is defined in the include/ directory from the top directory. When compiling and installing libsamsung-ipc, that include/ directory is installed as well. Anything that is not defined in include/ is not part of that public API. However here we need to precisely test functions that are not part of that public API: The open_android_modem_partition function being tested here is only used by the herolte device, and that device doesn't have a battery that is easily replaceable, so most Replicant contributors will not want to get that device. As currently all the non static symbols of libsamsung-ipc are exported and that open_android_modem_partition isn't static, we can simply link to libsamsung-ipc for now and use its internal headers to access the functions to test. If at some point, libsamsung-ipc only exports the symbols defined in include/ we would need to find other ways to run such tests, for instance by using test frameworks that take care of that or by compiling libsamsung-ipc source code into the test programs. Some of the code of the libsamsung-ipc-test utility was adapted from code from the nv_data-md5 utility (which is currently in tools/). Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* samsung-ipc: move Android partition handling in its own directoryDenis 'GNUtoo' Carikli2021-03-035-25/+88
| | | | | | | This code could also be useful for other devices and in any cases it's not device specific. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* MAINTAINERS: Update git URLDenis 'GNUtoo' Carikli2021-02-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | While libsamsung-ipc is not limited to Replicant (it can be used on GNU/Linux or in other Android distributions), it is currently maintained by Replicant. In order to make that more clear, it was renamed by the commit aa4f61805b2d8943e94847cae825ec209060569e ("Move libsamsung-ril and libsamsung-ipc in vendor/replicant") in the Replicant manifest repository[1]. Because of that we also need to adjust the git URL in the MAINTAINERS file. In addition we use https because it's safer than git:// as it uses TLS, and because we have redirects in place for http(s) but not for git://, so if the repository URL changes again, the old URL will most likely continue to work with http(s). [1]https://git.replicant.us/replicant/manifest.git Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>