dalvik-cache preventing file creation - android

I'm trying to change the Dalvik VM in order to extract an extra file to the dalvik-cache directory when the dex file is being extracted by JarFile.cpp.
The problem is when I use open() function I'm getting permission denied!
I'm aware that the permissions of the dalvik-cache are "system system", but I see in it other permissions for u0_a## for dex file.
I can create the dex file in the dalvik-cache but not other types of files.
How can that be? What's preventing me on file types to create files?

Applications do not have permission to create files in /data/dalvik-cache. Neither does dexopt.
The installd command does have permission, so it creates the file entry and passes an open file descriptor as an argument to dexopt.
The only time dexopt directly creates files is on engineering builds, where the initial bootstrap classes are created when the zygote process starts. At that point it's running as root with full capabilities.
To create an additional file you'd need to modify installd.

Related

Failed to Build AppBundle

I am trying to build appbundle using command flutter build appbundle. However, it will not start because of the following error:
Failed to open output file 'F:\Mobile app\user app\booking_system_flutter\booking_system_flutter\build\app\intermediates\flutter\release\flutter_asse
ts\packages/flutter_vector_icons/fonts/AntDesign.ttf'. The parent directory may not exist, or the user does not have permission to create this file.
Failed to open output file 'F:\Mobile app\user app\booking_system_flutter\booking_system_flutter\build\app\intermediates\flutter\release\flutter_asse
ts\packages/flutter_vector_icons/fonts/MaterialCommunityIcons.ttf'. The parent directory may not exist, or the user does not have permission to create this file.
Failed to open output file 'F:\Mobile app\user app\booking_system_flutter\booking_system_flutter\build\app\intermediates\flutter\release\flutter_asse
ts\fonts/MaterialIcons-Regular.otf'. The parent directory may not exist, or the user does not have permission to create this file.
Anyone have solution for this?
I think you have permission conflict in your directories or specific type of files (like ttf maybe).
If you using IDE or Code Editor terminal just open it with run as administrator or just open your platform terminal with as administrator it will help.
In my case I use vs code
Or cmd as terminal
if you are storing project in usb or other drives, just copy and paste in your locale drive and there won't be similar problem.

OTA update fails, can't mount /data/ partition

I am trying to implement OTA functionality for a msm8998 board running Android 8.1.
I've generated the OTA file and followed the standard way of doing it,
I've run into two problems, solving either one would solve the issue:
OTA size is bigger than /cache, therefore even though recovery can mount /cache, the image cannot fit there. How would I increase the /cache size, and is it a good idea to do so?
If I put the OTA zip in /data/ or /sdcard/, I have an error during recovery, seemingly it can't mount it. How would I make /data/ mountable?
...
Finding update package...
I:Update location: /data/update.zip
Opening update package...
E:Failed to mount /data: Invalid argument
E:Unable to open '/data/update.zip': No such file or directory
E:failed to map file
W:failed to read uncrypt status: No such file or directory
W:Failed to read /sys/class/thermal/thermal_zone28/temp: Invalid argument
W:Failed to read /sys/class/thermal/thermal_zone27/temp: Invalid argument
I:current maximum temperature: 44756
I:/data/update.zip
I:0
I:time_total: 0
I:retry: 0
I:temperature_start: 44814
I:temperature_end: 44756
I:temperature_max: 44814
I:
Installation aborted.
Turns out you have to use RecoverySystem.installPackage(...) method AND have the OTA file be in /data/.
Previously I had tried RecoverySystem.installPackage(...) method but with file in /sdcard/, and separately by setting /cache/recovery/command myself and using /data/
When using RecoverySystem.installPackage(...) and the file in /data/, seems uncrypt is run on it before reboot, and that makes the update accessible to the recovery.

Android NDK can't open any file

I'm trying to open files from C in my Android app/library. This did work at some point but stopped working after changing several things that seem completely irrelevant, and don't run until after this error occurs.
I am using the following function in C: *ppFile = fopen(fullUncFilePathAndName, "r+b"); and then again with permissions "w+b"
After each of these calls, errno = 13 (Permission Denied).
The file path is /data/data/{appFolder}/files/{filename} (got from Context.getFilesDir().getAbsolutePath(), and the working directory according to the C functions is "/". This is on internal storage, but I added the permission WRITE_EXTERNAL_STORAGE just because I had nothing else to do.
Can anyone think why reading or writing to existing and non-existent files in internal storage from an NDK library would fail with permission errors?
This problem solved itself in the best worst way possible. I deleted my app's data folder in the file browser, and then at the next build the app created its files without a hitch.
You could also clean the project and recompile from scratch.

how to grant android mediaserver file write permission?

I am developing several AudioEffect subclasses that are being compiled into Android 4.0.3 ICS... I am trying to dump raw PCM data to files, but because the AudioEffects run in the context of the mediaserver process it seems there is no file writing permissions available.
fopen("/data/local/tmp/pcm_in.pcm", "w");
is returning a NULL pointer and errno 13 (permission denied).
Any ideas how I can grant mediaserver this permission, or write to a folder I can access? I'm compiling the OS, so anything goes...
More specifically: How are permissions for these native/system services determined? I don't suppose they have a AndroidManifest.xml...
I suspect the problem is that you don't have permissions to create a file at /data/local/tmp. In fact i'm not even sure that directory exists on Android.
Instead you should either use the private storage for an app or save the files to the SD card. See this for more information: http://developer.android.com/guide/topics/data/data-storage.html
Maybe you can just create a folder with permission.
root#android:/mount -o remount,rw /
root#android:/mkdir test
root#android:/chown media:media test
root#android:/chmod 777 test
Then you can do whatever you want.
z.B.
fopen("/test/pcm_in.pcm", "w");

Setgid() call return fail in JNI

I am writting jni code for a netTV project apk. so I write code line like setgid(AID_AUDIO) in jni to make the current process have right to write data to the audio devices.
The problem is the setgit(AID_AUDIO) return fail because a common apk program can have user permission. I know that common apk cannot access to any device over jni, but my question is: how can I get my apk have system or root permission?

Categories

Resources