Android : change permission of system files - android

My phone is rooted and i wrote code in my app to change file permission of system file which is located at /sys/class/leds/lcd-backlight/brightness
Runtime.getRuntime().exec("su");
Runtime.getRuntime().exec("chmod 777 /sys/class/leds/lcd-backlight/brightness");
but this code can't change the file permission of the specified file and i won't got any kind of error or exception

Download the RootTools.jar from this link https://github.com/Stericson/RootTools/releases
Put that .jar file into your project's 'libs' directory
import com.stericson.RootTools.*;
.
.
Command cmd=new Command(0,"chmod 766 /sys/class/leds/lcd-backlight/brightness");
RootShell.getShell(true).add(cmd);

That's not how you execute su-ed commands. Please refer to http://su.chainfire.eu/ for guidance.

Related

Flutter: File can not be deleted or can not change path of the file

I tried to change path of the internal storage file but it could not happen.
Then I tried copy that file to another location and delete it from first location. unfortunately, this also did not work.
Here is my error:
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled
Exception: FileSystemException: Cannot delete file, path =
'/storage/emulated/0/DCIM/Screenshots/Screenshot_20230116-114448.jpg'
(OS Error: No such file or directory, errno = 2)
If anyone have idea then it could be helpful. Thank You.
before accessing the storage ask for storage permission with the below code and also you can check this permission package https://pub.dev/packages/permission_handler. Don't forget to add permission in for android and iOS in their respective folder
await Permission.storage.request();
and if you have any other doubt then you can ask it in comments.
If you are in android 10 and above WRITE_EXTERNAL_STORAGE is remove in android native...we can only delete the file that app have write in DCIM or any public directory, if we uninstall the app and reinstall the same app then it won't delete it...
You can view the answer and comment of this stackoverflow

QPython - Reading a file

I have installed QPython in my Android mobile.
I written a statement in the QEdit to read a text file from the below path
/storage/emulated/0/com.hipipal.qpyplus/script3/File1.txt
I used the below statement
fob=open('/storage/emulated/0/com.hipipal.qpyplus/script3/File1.txt','r')
fob.read()
If I run the statement, it is throwing error as:
IOError:[Errno 2] No such file or directory: '/storage/emulated/0/com.hipipal.qpyplus/script3/File1.txt'
1|uo_a116#cancro:/ $
Is the above statement correct?
fob=open('File1.txt','r')
Is not working in version 1.0.4.
fout=open('File2.txt','w')
Was working on version 0.9.6, but is not working in 1.0.4.
The "error" is Read only file system.
It looks like restrictions in the (new 1.0.4) file system library. I post a mail to the editor, but no answer at this time.
For testing, try to write absolute path to your files pointing, for example, to sdcard (/sdcard/out.txt).
I had problems on this versions (>=1.0.4) because launch process of script changes and execution directory is not the same as script directory.
I had to change my scripts to point to absolute paths.
It was tested with qpython developer.
Check this link:
https://github.com/qpython-android/qpython.org/issues/48
You can also try as simple as:
fob=open('File1.txt','r')
fob.read()
Just if the script is in the same folder of the file.
You can change the current working directory to path with script before read file:
import os
os.chdir(os.path.dirname(os.path.abspath(__file__)))

Access to permission files

I am trying to connect a zwave device to android tv box.
For that I need to edit handheld_core_hardware.xml file situated in /system/etc/permissions, but I can't do that since it is a read only file.
Can somebody tell me any trick by which I can edit the file?
You cannot access that file without root (superuser) permissions.
Every files located in /data or /system dirs are protected and you can read or write it only with root permissions.
Try something different or your app will run only on rooted devices.
Read more about that :
http://en.wikipedia.org/wiki/Android_rooting
http://www.androidcentral.com/root

How to write to a file in the Directory "/sys/....."

How can i edit the file in the sys directory using JNI and NDk in android.
Actually i Need to edit these file "/sys/class/gpio/gpio41/value".
By changing the mode you can now edit the file using: chmod 777 /sys/class/gpio/gpio41/value
just a little hint: use chmod 666 ...
You will get read/write permission but you don't need execute permission on
HW-pins.
Regards
Martin

How can I change the Read/Write Permissions of /mnt/SDcard folder on Kindle Fire?

I am trying to develop Amazon In-app in android. For this i download the sample code for from this site https://developer.amazon.com/sdk/in-app-purchasing/sample-code/button-clicker.html. This article suggests that we have to put a file amazon.sdktester.json in mnt/sdkcard folder of device. For this i read article from this site https://developer.amazon.com/sdk/fire/connect-adb.html#InstallApp and do the same. But when I tried to push file on sdcard, the eclipse gives me following error:
[2012-11-19 13:39:39 - ddms] transfer error: Permission denied
[2012-11-19 13:39:39] Failed to push selection: Permission denied
Is there any way to change the permissions of root folder of Kindle Fire?
Please try to use chmod command in the ADB shell...
Following are some chmod sample:
Add single permission to a file/directory
Changing permission to a single set. + symbol means adding permission.
For example, do the following to give execute permission for the user
irrespective of anything else:
$ chmod u+x filename
Add multiple permission to a file/directory
Use comma to separate the multiple permission sets as shown below.
$ chmod u+r,g+x filename
Remove permission from a file/directory
Following example removes read and write permission for the user.
$ chmod u-rx filename
Change permission for all roles on a file/directory
Following example assigns execute privilege to user, group and others
(basically anybody can execute this file).
$ chmod a+x filename
Make permission for a file same as another file (using reference)
If you want to change a file permission same as another file, use the
reference option as shown below. In this example, file2′s permission
will be set exactly same as file1′s permission.
$ chmod --reference=file1 file2
Apply the permission to all the files under a directory recursively
Use option -R to change the permission recursively as shown below.
$ chmod -R 755 directory-name/
Change execute permission only on the directories (files are not affected)
On a particular directory if you have multiple sub-directories and
files, the following command will assign execute permission only to
all the sub-directories in the current directory (not the files in the
current directory).
$ chmod u+X *

Categories

Resources