Giving Permission to File Executing the command
chmod 777 /sys/class/gpio/gpio41/value
It Worked................
Domanda
I need the sample code for how to edit the System Using Jni. i need to edit the file in the location /sys/class/gpio/gpio41/value
I tried These codes But It Is Not Working.
#include <jni.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
jstring
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env,
jobject thiz )
{
int fd ;
char gpio_path[30];
sprintf(gpio_path,"/sys/class/gpio/gpio41/value");
fd = open(gpio_path, O_RDWR | O_NONBLOCK );
write(fd, "1", 2);
close(fd);
return (*env)->NewStringUTF(env, gpio_path);
}
Soluzione 2
Giving Permission to File Executing the command
chmod 777 /sys/class/gpio/gpio41/value
It Worked................
Altri suggerimenti
In general, sysfs files are not writable in android for security issue.
Specific applications can be writable have suitable uid such as system, media, graphics, etc.
See https://android.googlesource.com/platform/cts/+/master/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java and look testAllFilesInSysAreNotWritable() method.