Android installation process and Application directory - android

I read that during .apk installation process a new user is created and with this new user rights, the Applications directory(.apk is extracted here) in the internal storage is created (in /data/app , not very sure). I can't find any Application directory in /data/app , even /system/app also contain .apk not Application directories . Can someone explain where I can find Application directories ??
Also what are the things happens during installation process (I am interested in knowing if some specific files are copied to specific location).

You read wrong :) APKs are not extracted on the file system, just decompressed in memory. So you will only find APK files in /data/app, /system/app, etc. The whole process is version dependent (for example Jelly Bean adds forward locking/encryption). You need to read the Android source to get the actual details. Start with PackageManagerService.java.

Related

Phonegap. Cannot write into app's data folder/directory

Following my previous post it appears that it is not possible to write into the following app's data folders which are identified by:
cordova.file.dataDirectory
cordova.file.externalDataDirectory
Which are translated respectively into:
file:///data/data/my_app_id/files
file:///storage/sdcard0/Android/data/my_id_app/files/
and which both map to the same destination (the internal Android storage space):
.../sdcard0/Android/data/my_id_app/files/
When the app is installed, inside .../sdcard0/Android/data/ a directory named my_id_app is created with two subdirectories files and cache. The files directory has no write permissions:
If I try to write into cordova.file.dataDirectory no error is
reported. The operation seems to have been successful but it is
not. I cannot write into this directory even if the phone is rooted.
If I try to write into cordova.file.externalDataDirectory error code = 1 (file not found) is raised. Nothing can be written into this directory. I can read/write into this directory only if the phone rooted.
I did these tests on my Samsung S3 Mini (Android 4.1.2) and Phonegap Build 6.2. Nothing about these kind of permissions restrictions is specified or clearly explained in the official documentation at cordova-plugin-file.
I would like to write into the app's data directory because it's the only directory that it's removed when the user uninstalls the app. I don't want to leave pieces of my app into the user's phone if he wants to remove the app.
If these directories are not writable where should I save the files the app downloads and be sure they are removed when the app is uninstalled?
Any thoughts, explanations, suggestions? I'm missing something?

Make Our Android Application work As a Preinstalled Application

I want to make my own application as a preinstalled android application.
To accompolish this
I tried to push in my app apk in /system/app folder but could not able to do. First i mounted r/w permission for /system/app folder using adb shell commands but that also i am not able to do.
Is anyone have ideas.
how to solve this issue?
Advance thanks for any help.
First of all you must root your phone to do that !
Now You are trying to pack your app as system application. classes.dex files are ripped from system applications and saved as optimized ODEX files. So before setting up, you should convert APK files to DEX to ODEX and then put it in system folder.
You can get more information about ODEX/DEX here.
You can directly install apk by adding them into system/app folder after gaining the root access on device. ODEX files would be best choice for developing system apps. Samsung, htc and many more companies use it to deliver their custom pre-installed apps.

where is .apk location for apps that are installed on sdcard?

I know that the location for system apps is '/system/app' and the location for user apps is '/data/app'.
But I can't find the location of apk for the ones that I moved to/installed on sdcard.
Apps installed on the SD-Card are stored within the directory ".android_secure".
If I remember correctly you won't find the APK files directly in that folder because the content is encrypted. This is for preventing direct access to the APK file of paid apps.
The encrypted part is mounted somewhere else into the file system.
For me at least using cyanogenmod9 on a Samsung galaxy s 2 i777 I found them in /mnt/asec/
This location works differently than /system/app/ and /data/app/ because the system is actually creating a mount for each app rather than just stuffing them in a folder.
Make sure you take note of symbolic links.
You will not be able to add to here like you can the other two, but you can extract an apk. A better solution would be MyAppSharer from the market.
It will be in mnt -> asec -> -> pkg.apk
On Android 5.0+ (Lollipop, Marshmallow) almost every installed non-system app will be placed in:
/data/app/
Access to /data requires root.
Use su when you are working with adb shell to gain root access, this of course requires your phone to be rooted in the first place.
The directory contains a sub directory for every app.
Each sub directory is named by his package, following Androids app naming convention:
tld.author.appname-N
Where N represents a number greater or equal to 1
e.g. for Firefox it will look something like:
org.mozilla.firefox-1
Inside every app directory you will find a base.apk which is representing the installed app.
So if you want Firefox simply download:
/data/app/org.mozilla.firefox-1/base.apk
using adb pull/scp or copy it to your sdcard and download it using MTP.
Cheers
it is in
File Explorer--> mnt/sdcard
Install ES file explorer. Go to Home Page there will be link App...under that you will find all the apps installed on sd card or phone memory.. select app and share...enjoy...
On lineage 14, Android 7 , all sdcard apps are stored in /mnt/expand/
And apk in folder "app"

Where did the code in apk file go after installed from Market?

This is a very interesting thing. I have an APK file, com.company.app.apk. When installed to an emulator by using Eclipse, by using the following code to get the apk's file name:
String fileName = activity.getPackageManager().getApplicationInfo(
activity.getPackageName(), PackageManager.GET_META_DATA).publicSourceDir;
I get a pathname like this com.company.app-1.apk. The file size is the same as the apk file I built.
Now when I publish this app to Market, and install it to a real device (Android 2.3), the same code returned a pathname like this: com.company.app-2.zip. Note that the file extension has changed to .zip and, most importantly, the file size is significantly smaller than the original size.
Now if I transfer these two files to my PC and use WinZip to open them, I found one really interesting thing:
The one installed on emulator by Eclipse has exactly the same stuff as I expected. Namely: the code ('com' folder), the resource ('res' folder), the signature ('META-INF' folder), the assets ('assets' folder), and the manifest file (AndroidManifest.xml). However, the one installed on a real device by Market has only two parts: the resource, and the manifest file.
Question: I think when installed from Market, the .apk file is split into two (or more) files. One file is pointed to by ApplicationInfo.publicSourceDir, which contains only the resource. How can I get the pathname to the other file(s)?
ADDED: I have two versions of the same app, one is paid using Google's Vendor Licensing Service, the other is free. The above mentioned phenomenon happens only to the paid version. Why?
Correction: When I said the 'com' folder exists in the installed apk file in the first case, I should be more clear. The code per se, the *.java files, are not in the 'com' folder. As a matter of fact, the 'com' folder contains only a few garbage files that were inadvertently left there during the build process. If not for those garbage files, I don't think the 'com' folder would be there in the first place.
I think you are not right. The market works in the following way: you choose an application and push a button to install it. After that market sends the intent to gtalk service to install the application. This service downloads apk file that you've uploaded to the market and when finishes it installs this apk. Just during the installation can some changes happen. It seems to me that from the application during the installation classes.dex file is extracted and from this file optimized dex (.odex) is produced and put in the separate directory. That's why you see the difference in the files.
Ok, here is what I've found out, in case this helps someone out there:
When Market installs the free version of my app, the apk file is installed to /data/app/com.company.app.apk, the file content is exactly the same as I built it, same file size, same everything.
For the paid version that uses Market Vendor Licensing, the apk file itself is installed to /data/app-private/com.company.app.apk. This is the same file as I released. However, the resources are extracted and installed to another file /data/app/com.company.app.zip, note the file extension. This zip file contains only resources, so it's significantly smaller. But the .apk file in /data/app-private has everything, so the file size is the same as I built it.
ApplicationInfo.publicSourceDir always points to the file in /data/app, so it's /data/app/com.company.app.zip in the paid version's case, and /data/app/com.company.app.apk for the free version. For the paid version, I obtained the pathname from publicSourceDir, then replace.app with app-private, and replace .zip with .apk to get the original file.
If I install the apk directly to an emulator, then there is only one file and is always installed under /data/app.

apk file parsing

Each and every android application is bundled as an apk file. When an apk file is installed different entites (files) of the application are stored in different parts of the system. For example i have found that real player stores its files in the following places of the android file system
/data/data/com.real.RealPlayer
/data/app/com.real.RealPlayer-1.apk
/data/dalvik-cache/data#app#com.real.RealPlayer-1.apk#classes.dex
/data/system/packages.list
/data/system/packages.xml
/data/data/com.sec.android.app.twlauncher/databases/launcher.db
How can i do this for every installed application on my phone/emulator?? Is it the right way to parse apk file and find the places where all the parts of the app are stored?? Any ideas?
On normal non-rooted phones an application can see only its own files, due to security restrictions.

Categories

Resources