Change StorageManager's default mount point from /mnt/obb to /mnt/data - android

I am following this obb sample to load a native library from an obb file. But I am seeing following error on System.load(mylib.getAbsolutePath()) call.
java.lang.UnsatisfiedLinkError: dlopen failed: library "/mnt/obb/fcc93fcbaf5acfc/mylibs.so" needed or dlopened by
"/system/lib/libnativeloader.so" is not accessible for the namespace "classloader-namespace"
[name="classloader-namespace", ld_library_paths="", default_library_paths="", permitted_paths="/data:/mnt/expand:/data/data/com.example"]
But as far as I understood, StorageManager#mountObb() by default mounting to /mnt/obb. Is there a way I can instruct StorageManager to mount the obb at /mnt/data ?

Related

How to get access to system .so libraries un android

I want to write fm radio for my phone. I decompiled it,and noticed,what it use libfmjni.so,which i found in system folder. But when i try to use it,i get exception:
java.lang.UnsatisfiedLinkError: dlopen failed: library "/system/lib/libfmjni.so" needed or dlopened by "/system/lib/libnativeloader.so" is not accessible for the namespace "classloader-namespace"
I tryed to load it in jni\armeAbe folder,but i have the same effect. My phone is rooted. Also i not understand,why in decompiled app (i did the same),it load fmjni instead of libfmjni. Thanks everybody for any help.

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.

Loading an .so native library from android's obb folder

I have an .so file that I packed into an obb expansion. It's about 20 megabytes.
I'm trying to use
System.load("/storage/emulated/0/Android/obb/com.mypackage.myapp/libtest.so");
to load the library. But I get the error:
dlopen("/storage/emulated/0/Android/obb/com.mypackage.myapp/libtest.so", RTLD_LAZY) failed: dlopen failed: couldn't map "/storage/emulated/0/Android/obb/com.mypackage.myapp/libtest.so" segment 2: Permission denied
type=1400 audit(0.0:8): avc: denied { execute } for path="/storage/emulated/0/Android/obb/com.mypackage.myapp/libtest.so" dev="fuse" ino=367663176224 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:fuse:s0 tclass=file permissive=0
So I realized that we're not permitted to have an executable there.
So my question is,
1- Where should extract the file to be able to do this?
2- What function call should I make?
Thank you.
Copy the file to any location of your choice under your app's private internal storage folder, make sure it is marked read only and executable (not writable, especially by anyone else!). This is the only tree of locations typically writable by an application where executables are permitted.
You can determine the private folder location by calling getFilesDir() on an initialized Activity or Service Context.
There are a number of existing questions here which demonstrate mechanisms for file copying in Java.

Create a file in /system directory

I want to create a file in the /system directory. I think that directory is "protected" and the phone must be rooted to access and create to it.
I used this simple code to create a file in /system but nothing is created:
File file = new File("/system", "test.prop");
How can i solve that problem?
Thank you for your help.
I can't tell how to implement the following steps but I think it's not too hard to find a solution on the net:
acquire root-access for your application
check if /system is mounted with option rw, if not, remount it so
hint: use the "adb shell" and check if the upper steps can lead to success
(su && remount -o remount,rw /system && touch /system/test)
On some devices there's the unlucky chance that the internal memory is in protected mode (google S-ON / S-OFF). If this is the case for you it will not be that easy like I imagined.
But even than it must be possible, since the market is installing files there. This would be the last hint, to look at the market source-code ;/
You need to call following method on file object
file.createNewFile();
On executing this following error comes because of read-only directory
11-09 19:45:15.136: E/VideoSample(4245): java.io.IOException: open failed: EROFS
(Read-only file system)
11-09 19:45:15.136: E/VideoSample(4245): at
java.io.File.createNewFile(File.java:940)

Accessing the /cache directory in the Android filesystem

How can I write a file in the /cache directory? I continue to get a FileNotFoundException (Permission denied).
Someone told me about the android.permission.ACCESS_CACHE_FILESYSTEM but i can't find it in the Android reference.
Any help will be appreciated.
EDIT: i'm using level 13 apis
You can only write to the cache directory of your own application: use context.getCacheDir() to get its location.

Categories

Resources