Update AOSP built-in system app - android

Lets say we have downloaded, built and flashed AOSP source code. Now a change to a system app is made (e.g. changed a constant in the packages/apps/Nfc package).
The next step is to build it, and there are two ways to do it:
cd packages/apps/Nfc; mm
or
mmm Nfc
This will create out/target/product//system/app/NfcNci/NfcNci.apk file
Which is the proper way to update the system app?
I tried using adb install NfcNci.apk but no success:
~/android/aosp-7.1.2-3.10-v2/out/target/product/kugo/system/app/NfcNci$ adb install NfcNci.apk
Failed to install NfcNci.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install com.android.nfcnci without first uninstalling.]
~/android/aosp-7.1.2-3.10-v2/out/target/product/kugo/system/app/NfcNci$ adb install -r NfcNci.apk
Failed to install NfcNci.apk: Failure [INSTALL_FAILED_INVALID_APK: Package couldn't be installed in /data/app/com.android.nfcnci-1: Package /data/app/com.android.nfcnci-1/base.apk code is missing]

Found a way to easily 're-install' the app itself (let's put Settings app as an example):
mmm packages/apps/Settings # Build the module
adb root ; adb remount # Restart adbd as root and mount /system as writable
adb push out/target/product/<device_name>/system/priv-app/Settings /system/priv-app # Push the built files to the device
Then force-close and restart the app (by swiping it from Recents). No need to reboot device in order to take changes
NOTE: Depending on the app, the path may be on system/app instead of /system/priv-app

Another way is to:
copy the new apk to the sdcard of the device with adb push
mount /system read write: mount -o rw,remount,rw /system
copy your new .apk from /sdcard over your old .apk in /system/app
remove the .odex file of your old .apk
reboot the device
For development you can use a simple script for this steps.

Check build/envsetup.sh file - there's also commands mmp and mmmp to build and push a module to connected device. Also adb sync can be used to sync whole image, so if you updated a module, changed files will be pushed to device.
Also you can put the changed files via regular `adb push' and reboot device.
I do not know if system apps can be updated via adb install, probably yes, but I think you need to increment build number in the manifest file.
I do not think you can uninstall a system app with adb install -r, as apps can't be removed from system partition, only from data. I do not know why you are getting INSTALL_FAILED_INVALID_APK in that case, may be because app manager can't uninstall the base system apk indeed.

Related

What is the right way to turn an app into a system app under Android Oreo and above?

I have tried several methods to turn an app into a system app but even if in some case I managed to install the app inside /system/priv-app the app was not running as a system app as I could figure out by checking running the command "adb shell ps".
So please could someone tell me if I missed something or if there is some limitation linked to Lineage or may be Magisk or TWRP to have an app runing as a system app ?
I have tried with Lineage 15.1 (Oreo) and magisk 21.2 the phone is a Samsung S5 using TWRP 3.5.0_9-0 as system Recovery
First method was to
1 making a copy of the app folder to the internal storage
2 renaming that copied Folder with a short name without dot (like renaming com.example.myapp folder to Myapp Folder)
3 renaming the apk from base.apk to Myapp.apk
4 uninstalling the app
5 under TWRP recovery mode mount the system partiton and copying the Myapp folder to system/priv-app directory
6 chmod 755 Myapp Folder
7 chmod 644 Myapp.apk
8 wipe Dalvilk Cache and rebooting
Steps 2 and 3 might be useless it was just because I noticed the Priv-app directory used these naming Scheme for apps inside this folder
I tried this method under Lineage 17.1 and Magisk 21.4 but then the phone was not able to reboot until I delete the newly created folder inside Priv-app
I also tried another method using Magisk Systemize (Terminal) module but the result was the same (the app was running but not as a system app)
I also tried to put the app into System/app folder but the result was the same
As I have never seen that it was mentionned in any posted method explaning how to turn an app into a system app, the installed app was not signed with the platform key and the manifest was not including android:sharedUserId="android.uid.system"
Thanks in advance to those that will try to help.
I would try the following, after making sure I don't have a user copy of the installed app (somewhere in /data).
Get to root shell at first.
adb root && adb remount
Use /system/app path for system apps and /system/priv-app for privileged apps.
(for priv-app path you also need to create a priv-app-whitelist.xml with the said permissions, https://source.android.com/devices/tech/config/perms-allowlist)
adb shell mkdir -p /system/app/AppName
adb push AppName.apk /system/app/AppName
adb reboot
Not sure how are u confirming if the app is running as a system app or not?

Which target to build after making a change to a system service in AOSP?

I am trying to verify a small change I have made in the Activity Manager service (mostly logs that I have added). I am using the android-8.1.0_r42 aosp version and using its emulator.
I am using an eng build.
I have done a module makes (mm) and then, make services which generated the services.jar, services.odex, etc. However, I am unable to remount the system partition on the emulator (command used: mount -o rw, remount /system, on the ADB shell, but doing a push(adb push) of any of the generated services binary is failing due to reading the only partition).
So I regenerated the system.img by doing a - make snod. However, my changes are not consumed in the emulator instance I launched after generating the new system.img.
Is there a way I can verify my changes without doing a top-level full build, which takes quite a long?
It could be the case that DM-verity is enabled and prevents you from writing to the system partition after remounting.
Assuming you are working with a userdebug version, try the following:
adb root
adb disable-verity
adb reboot
adb root
adb remount
Now you should be able to push your files to the remounted partition without getting the read-only error.

Installing Android System-App on Emulator does not work

I have a System App that is capable of performing some system level tasks (Ex: remote reboot etc.). I want to try this out in the Android-Dev-Studio Emulator.
I have googled for it and this is what I've found so far:
Build the .apk
adb remount
adb push [MyApp.apk] /system/app/ (this is /system/priv-app in API Level 19+)
adb shell chmod 644 /system/app/[MyApp.apk]
adb reboot
I have done all of this. I've tried copying my apk to both folders "/system/app/" and "/system/priv-app/" folders. Regardless, when I reboot the emulator does not show anything and gets stuck.
According to this question reboot does not work for emulators which I also noticed to be correct, since the copied .apk file is lost upon restart.
What am I missing here?
I am compiling and building for SDKVersion - 21. So which folder should I copy my system app to? (/system/app/ or /system/priv-app)?
Also if reboot does not work for emulators, how do I get the app installed and running?
What's android version of your emulator?
The "/system/app/" and "/system/priv-app/" directory structure have been changed since Android L, you should use:
adb push MyApp.apk /system/priv-app/MyApp/

aggressive adware irremovable apk on android

A few days ago I received complaints from several customers who told me that "adware is installed automatically on your device Krono NET K5". I made invesigar and found a few apk on / system / app that had different permissions to the usual "rw-r - r--". I could erase the few simple steps in a shell:
adb shell "su -c 'mount -o rw, remount /'"
adb shell "su -c 'rm /system/app/156.apk'"
adb shell "su -c 'rm /system/app/Launcher0607wxDjbOa.apk'"
adb shell "su -c 'rm /system/app/Sync.apk'"
adb shell "su -c 'rm /system/app/SettingProvider.apk'"
(Note that a suspect name as there is a apk using the system call SettingsProvider.apk with letter s)
So far everything worked properly, however there is a apk which is the main cause of all adware and causing the discharge cone apk other battery savers, system cleaners, among others. This application is:
"/system/app/providerdown.apk" Permits "rwsr-sr-x"
I tried to remove it by the above method, I tried to change the permissions to remove it and it has not worked. I tried to install a recovery to eliminate apk thence Aroma File Manager (CWM, TWRP) MTK but this device does not support any custom recovery for devices MTK.
Any idea? Thanks in advance (sorry for my bad english)
I have same problem. You will have to be rooted for this, but i guess you have root because of that code you wrote, and the fact that app somehow gains root access and installs itself in system. Only thing I did to make things easier is:
Download Avast to your phone.
Download Clean Master to your phone and with Clean master make backup of your avast apk.
Go to your stock recovery. I used an app from google store to boot to recovery but any way is good.
Clean cache and do a factory reset.
Boot the device.
DO NOT CONNECT DEVICE TO ANY NETWORK.
Just skip all the stuff like login to your google account and other settings.
Find your Avast apk in the sd card and install it.
Turn on firewall and block all acces to TimeService-that is the name that apk uses when seen from android system.
Go to android system and disable time service. It is probably version 1.1.6
You will still have malware in your device but it wont make mess anymore.
I would like the permanent solution too.

Install APK from SD card no file browser Android phone

I need to install an APK on a phone with no built in file browser, and no connection (wifi/mobile). The LG Optimus M has no built in file browser... Not sure why, but it is making things very difficult. I was thinking if I could put an app in a special place on an SD card, or auto-run an APK install.
ADB is also not an option due to usb driver issues. I know this is pretty limited...
EDIT: I got down voted because you didn't read? There is no wifi/mobile connection available. Downloading a file manager etc. from market not an option.
Enable usb debugging
Install the drivers and android sdk
Connect the phone through usb to your computer
Call the following program from the command prompt: adb install
application.apk
Adb will now install your application
According to the about of just running adb, you can use the following command line arguments:
adb install [-l] [-r] [-s] [--algo <algorithm name> --key <hex-encoded key> --iv <hex-encoded iv>] <file>
- push this package file to the device and install it
('-l' means forward-lock the app)
('-r' means reinstall the app, keeping its data)
('-s' means install on SD card instead of internal storage)
('--algo', '--key', and '--iv' mean the file is encrypted already)
Why not download one of the MANY file browsers in the market? May I suggest my favorite which is Astro File Manager
If you have a terminal emulator app on the device, you can put MyApp.apk on the SD card and run this, which should open the package installer:
am start -a "android.intent.action.VIEW" -d "file:///mnt/sdcard/external_sd/MyApp.apk" -t "application/vnd.android.package-archive"
You might need to change that path depending on your device — see How can I determine storage directory from ADB?
You will also need to enable the Unknown Sources option in the device settings.
Why not download astro file manager? it works great. Other than that I would host the apk on a server and download it from the phone.

Categories

Resources