Using the legacy sysfs GPIO under Android and Linux the first step in the process is toe export
the particular GPIO pins you want to use. And when you are done with
The pseudo-files in /sys/class/gpio
are fairly thin wrappers around function calls in the kernel interface. There's a clue in the kernel documentation [1] about the purpose of the import/export functionality:
After a kernel driver requests a GPIO, it may only be made available in the sysfs interface by gpiod_export(). The driver can control whether the signal direction may change. This helps drivers prevent userspace code from accidentally clobbering important system state.
This explicit exporting can help with debugging (by making some kinds of experiments easier), or can provide an always-there interface that’s suitable for documenting as part of a board support package.
So, essentially, this functionality exists to prevent user-space applications carelessly trampling on the state of I/O devices. How useful it is in practice, I don't know.
[1] https://www.kernel.org/doc/html/latest/admin-guide/gpio/sysfs.html