What does /mnt/asec
directory contain in Android? Can someone explain in brief?
Thought Google would have an official definition on Android Developers, but surprisingly not. So with a lil bit of Google I dug up this:
Android Security Internals: An In-Depth Guide to Android's Security Architecture
Look around P80 for related content. From what I understand, ASEC (Android Secure External Cache) was implemented in a time when Android devices come with limited storage and has to resort to external storage (i.e. SD card) for apps, and its purpose is to securely store part of the apps so as to prevent corruption and piracy by copying SD card contents.
Wikipedia also has a bit of intro here.
It's actually used to achieve "Move to SD card" feature.
Take a sample app called com.sample.app
.
When an app is installed, a new folder will be created by the app name /data/com.sample.app
which contains the app's private data. Similarly, the APK itself is contained in /data/app/com.sample.app1.apk
When we move the application to external storage,
- It will not be moved to
/mnt/sdcard/
partition. Android will create a new folder under/mnt/asec
partiton called/mnt/asec/com.sample.app
. - It will also copy the APK from
/data/app/com.sample.app1.apk
to/mnt/asec/com.sample.app/com.sample.app1.apk
-
Thanks for your answer. I have few more queries. Does /mnt/asec partition is tmpfs mounted. Also if the application is moved to sdcard, it will always exist in /mnt/asec partition . it will never be moved to sdcard partition. Is my understanding correct. – Spyder Aug 23 '16 at 1:55
On one hand, when I browse my rooted android through adb shell, I get here:
/data/data/com.sample.app
Then ls -al
gives :
drwxrwx--x u0_a25 u0_a25 2018-10-28 23:52 cache
drwxrwx--x u0_a25 u0_a25 2018-10-29 00:36 files
lrwxrwxrwx install install 2018-10-29 09:48 lib -> /mnt/asec/com.sample.app-1/lib
drwxrwx--x u0_a25 u0_a25 2018-10-29 07:45 shared_prefs
On the other hand, through USB connection, I get two mount points:
mtp:/Y330-U01/Phone storage/
mtp:/Y330-U01/SD card/
The following directory mtp:/Y330-U01/Carte SD/.android_secure/
looks empty. Is it actually empty ?
When plugging directly the SD Card on the PC (via USB micro SD adapter) the directory .android_secure/
appears to contain:
com.sample.app-1.asec
So in my opinion /mnt/asec
is a mount point for /mnt/asec/com.sample.app-1/
mount points, leading to .android_secure/*.asec
secure disk image files (or kind of...)
-
This is how it appears on API_19 emulator:
/init.rc: mount tmpfs tmpfs /mnt/asec mode=0755,gid=1000
– Alex Cohn Jan 8 '20 at 8:22