[AOSP]What is the most elegant way of striping AOSP of its pre-installed packages? - Android Q&A, Help & Troubleshooting

I am trying to gradually stripe AOSP out of its default apps. But I wonder if the method I am going to apply is correct and is the most effective.
After looking through ways of doing that I have come to the following method: (example app - "package_name")
1. Pick particular app and find out its "LOCAL_PACKAGE_NAME"
2. Use "envsetup.sh" provided command "mgrep package_name"
3. Look at the output to determine where package_name is mentioned
4. Remove lines of code containing package_name from makefiles
Click to expand...
Click to collapse
I have also stumbled upon this solution:
Instead of modifying bunch of .mk files in AOSP in many folders, you can add a new module, a stub, and disable modules in its Android.mk using LOCAL_OVERRIDES_PACKAGES. If a module still appear in target, you'll probably need to add to LOCAL_OVERRIDES_PACKAGES another modules which added undesired packages via LOCAL_REQUIRED_MODULES.
Click to expand...
Click to collapse
But sadly I am not aware yet how one builds a new "module, a stub" so I can't apply this method as of now.
Are there any steps I can take to make sure a particular app is removed from my build completely without harming anything. What do you think is the most elegant solution to this specific task if there is one? What(literature/docs/website)would be useful for me to get familiar with making "scratch-surface" changes to AOSP code like the abovementioned case?
Thanks in advance for your responses!
P.S If any extra information is needed I am ready to specify
If that matters what I am trying to remove at the moment: Calculator; Calendar; Camera; Clock; Contacts; Files; Gallery; Messaging; Music; Phone; Search; WebView

Related

[MOD] [HACK] Modifying stock Mms.apk to change user-agent

I have been reading around on the net about people previously modifying stock Mms apps on different Android based devices to change the user-agent used when sending MMS.
I can extract all the files, modify them and recompile and push back to my phone. But the strings I'm editing currently are having no effect on the messaging, or they're just causing the Mms app to FC when you add an image to the message.
Is there anyone out there that could help me with this as I'm sure a lot of people would benefit from this.
I can provide the Mms.apk extracted with the contents of classes.dex extracted too if anyone requires them.
So far I've edited the following files:
/com/android/mms/transaction/HttpUtils.smali
/com/android/mms/MmsConfig.smali
But literally only made small changes to various strings.
I hope there's someone who can help me out.
You do know the source of mms.apk is available right?
This is why I'm asking for help.
Last time I asked about the source someone told me that the latest stuff wasn't available.
This has already been done and the source is here, and the commit that added user agent selection is here.
If you want to see the code for the true stuck Mms, that can be found here.
Compiled for you and attached. There's also a whole bunch of extra bits that aren't in the stock Mms.apk like black background, customizable notifications, and other features that have been added in.
ChainsDD said:
This has already been done and the source is here, and the commit that added user agent selection is here.
If you want to see the code for the true stuck Mms, that can be found here.
Compiled for you and attached. There's also a whole bunch of extra bits that aren't in the stock Mms.apk like black background, customizable notifications, and other features that have been added in.
Click to expand...
Click to collapse
Awesome work! Works great on my Liquid.
appreciate posting the question and the Mms.apk. looks and works great on my N1.
ChainsDD said:
This has already been done and the source is here, and the commit that added user agent selection is here.
If you want to see the code for the true stuck Mms, that can be found here.
Compiled for you and attached. There's also a whole bunch of extra bits that aren't in the stock Mms.apk like black background, customizable notifications, and other features that have been added in.
Click to expand...
Click to collapse
Thanks for the info, I had seen one previously modified but it wasn't for the nexus one. I'll give this a try later.
Can I ask how you compile a single app from the git repo? I was having trouble doing it earlier and found the only way it would work successfully is if I compiled the entire OS image and took out the app I wanted. I'm clearly doing something wrong
Using ubuntu 32bit, I have the git repo already sync'd.
As far as I know, the only way to compile a single app is to compile the whole OS. Once you've compiled it all, you can just type 'make (app you want to compile)', for example 'make Mms', or 'make Launcher2', from the root directory of the source. Capitalization is critical, the apps are located in packages/apps and the folder name is what you use to make each. Once an app is compiled, it'll be located in out/target/product/passion/system/app.
ChainsDD said:
As far as I know, the only way to compile a single app is to compile the whole OS. Once you've compiled it all, you can just type 'make (app you want to compile)', for example 'make Mms', or 'make Launcher2', from the root directory of the source. Capitalization is critical, the apps are located in packages/apps and the folder name is what you use to make each. Once an app is compiled, it'll be located in out/target/product/passion/system/app.
Click to expand...
Click to collapse
Thanks, I'll try that on this current build I just compiled and see what happens.
Are there any adverse effects of compiling the stock OS and recompiling an app to then copy to a different version of the OS? I obviously don't run stock OS on my device, I run Cyanogens ROM.
Just want to make sure I could compile on 2.1-update1 and run on Cyanogens.
Often times there's no problem with that, but it's usually best to use a build environment that matches your run environment. You can download the full CM source from his github much the same was you did the stock android source, full instructions here. The only thing those instructions leave out is that after you've synced up, you need to plug your N1 in and from the source root run
Code:
cd vendor/google/passion
./extract-files.sh
That pulls in the required binaries that aren't open sourced yet.
does this work on non-rooted phones?
No. And it's implemented in just about all the custom ROMs now.
i'm about to root my phone, does this app resize pix and stuff like Handcent?
Any words for MMS mod for sense rom?
Hey there, i am just wondering weather you finally succeeded to modify your mms.apk
I am on htc with sense rom, updated to latest one. after update mod mms from cm keeps giving me FC...no longer able to use mms... i want to mod the mms.apk. any help will be very useful.
Thanks!

[Q] Various android-related queries

I have managed to compile (from source) and install CM7.2 on my HTC dream, but my questions below are related to Android:
1. Is there a way to find out which packages (.apk) were installed on my system and if so, how do I do that?
2. Is there a way to find out each package dependencies (I need to figure out this as I am bent on removing the vast amount of guff installed on the phone - I won't need 90% of this stuff)?
3. Similarly to 2 above - is there a way to look at dependencies of a package not yet installed on my system (i.e. the .apk file)?
4. How do I actually remove a package for good from the system?
5. Similarly to 3 above, how do I actually install a package from within the root system - I know I can do this via adb, but is there a way to do this inside the, say, command line terminal?
6. Is there a way to alter (understand remove) certain program permissions which I could see "granted" to a particular program/package? I know there are various ways to look at these, but I wish to remove permissions I am not happy being granted to that particular program/package.
And one last a bit more advanced query: I would like to build a single package from the source tree and then install the resulting .apk file on my system.
Basically, I will try to upgrade a package with a new revision and add a few patches to the package source of my own before compiling it and building it again.
I usually build the whole lot (all packages + the rootfs image itself) with "mke bacon", but if I want to alter the source and build a single package how do I do that?
I am not very familiar with the Android make system, so I don't want to go heads-first into something and make a real mess of it.
Thanks a lot for any assistance given.

[Q][SOLVED, partially] modifying environment variable DIRECTORY_DCIM system-wide

Hello,
Problem:
My Meizu MX3 (runs Flyme os 3 based on android 4.2.2) has preset "Camera" in the DIRECTORY_DCIM environment variable. Most of the camera apps respect this setting and they are saving photos in the Camera instead of the DCIM. This causes problems with automatic syncing, because photos are obviously expected to be in the DCIM.
Partial solutions:
I tried symlinking the two dirs, but as far as i know it is not possible in the FUSE used since the 4.2.2.
mount -o bind led to the duplicity in the gallery app and i don't consider it too "clean" solution.
I ended up with modifying source of Focal open source camera not to read DIRECTORY_DCIM env var, but rather just to save the picture into the DCIM directly.
Is there a way to change this variable on boot? I don't want to use any 3rd party apps for simple things like this. Editing init.rc led to nothing, because it is always replaced by the default one from the ramdisk.
Thanks in advance.
Have you tried making an init.d script to export the value you want? I haven't looked at the source code so I don't know if that'll make a difference, but that's the only thing I can think of, short of modifying the API call using e.g. Xposed (somewhat similar to what this mod does.)
You may want to link the SO question you also created, in case you get a working answer there, so anyone stumbling on this page will find the way to that.
The init.d dir was not on my phone, so i tried creating it. Scripts from there do not get run on the startup, which brings me back to the problem with editing init.rc.
I will probbly just keep using modified camera until they release Ubuntu mobile for mx3 - which according to rumors could be soon
Thank you for your time
Sent from my M353 using XDA Premium 4 mobile app
Check if in your init.rc there is something like
Code:
service flash_recovery /system/etc/install-recovery.sh
Then you can edit/create that script and enable running init.d scripts with:
Code:
busybox run-parts /system/etc/init.d
search on this forum for more info
Sent from my ZP980 using Tapatalk
Thank you, your guide worked and my scripts in init.d now get executed
Sadly, exporting the variable in script residing in init.d does nothing (the script itself gets executed, i tried echoing "test" in file). There must be something, which keeps reseting the DIRECTORY_DCIM to its original value, or else i'm out of ideas
Or am i assuming incorrectly, that Java code
Code:
Environment.DIRECTORY_DCIM
should read env variable settable by
Code:
export DIRECTORY_DCIM="DCIM"
?
Actually now that you say that I checked my init.rc and I don't have that. Plus if I try
Code:
echo DIRECTORY_DCIM
I have nothing, so at least for me it's not set there.
Sent from my ZP980 using Tapatalk
For me echoing the varible also returns nothing, but reading it by Java returns "Camera".
Since it was my only clue, i hoped it could be reset by exporting DIRECTORY_DCIM (since android docs states that
android.os.Environment provides acces to environment vars) I guess i was wrong.
Is there any other kind of emvironment variables, i am not aware of?
Sent from my M353 using Tapatalk
I checked that variable is hardcoded in the android.os.Environment class.
I can think of three methods to test to change that but I didn't test any:
Use exposed framework to change the call that gets DIRECTORY_DCIM, if that's possible it's probably the best choice.
Edit and compile again android.os.Environment (I have no idea how to do that or if it's even possible)
Make a script that monitors your X folder to move pictures to DCIM folder
I can help you with the last one
The xposed is great idea, but unfortunately it doesn't work. It says "unknown option -- c" which as far as i know has something to do with bad (probably outdated?) version of SU. Meizu's firmware is probably more customized android than i previously thought.
Now i'm using the solution you also advised - i am automatically moving media from Camera to DCIM - i was hoping for more clean solution, but i guess this is as close as i'll ever get (don't get me wrong, it works as it is supposed to. I'm just a perfectionist )
Thank's for your time.
np I'm a perfectionist too and it's always cool to learn how things work and can be hacked
Sent from my ZP980 using Tapatalk

[Q] [APK] How to edit compiled APK name/version

Hi!
I want to repack some built APK and edit its name/version.
AndroidManifest.xml contains this information, but it becomes binary after compiling.
I see only these options:
Manual reverse-engineering (requires deep knowledge of APK format);
Using "android-apktool" (good idea, but I'm trying to avoid third-party tools as I write my own code for my software);
Forget the whole idea.
What do you think of it? Maybe there is another way (or another less multifunctional third-party tool than "android-apktool")?
Any ideas would be helpful.
kefir500 said:
Hi!
I want to repack some built APK and edit its name/version.
AndroidManifest.xml contains this information, but it becomes binary after compiling.
I see only these options:
Manual reverse-engineering (requires deep knowledge of APK format);
Using "android-apktool" (good idea, but I'm trying to avoid third-party tools as I write my own code for my software);
Forget the whole idea.
What do you think of it? Maybe there is another way (or another less multifunctional third-party tool than "android-apktool")?
Any ideas would be helpful.
Click to expand...
Click to collapse
In my opinion Option 2 is the best and quickest way around this problem. Reverse engineering is much too complicated and forgetting the ide is a no-go for developer.

AOSP Development - Android 10 - Creating System Service

Hello Everyone,
This is regarding modifying AOSP and trying to add my own system service as part of the system for customized application. I have tried all the places I could from documentation on source.android.com to trying to post a query on their official Google Groups and also tried out reading out books on AOSP. Unfortunately the OS code is changing so rapidly the documentation is rather old and not up to date. And now this seems to be my last hope to find a lead on how to achieve this.
(This is the first time I am posting so please guide me in case of discrepancies)
So, I am trying to create a system service from scratch and bake it inside the AOSP build. The steps I figured out and followed are as following:
1. Create an AIDL file inside frameworks/base/core/java/android/os/IFooService.aidl
2. Create the implementation in frameworks/base/services/core/java/com/android/server/FooService.java
3. Modify SystemServer.java at frameworks/base/services/java/com/android/server/SystemServer.java and use the ServiceManager to start the service.
4. I need to specify SELinux permissions which I wasn't able to figure out even after checking out whatsoever documentation I can find online. So I went to device/google/bonito/BoardConfig-common.mk file and added BOARD_KERNEL_CMDLINE += androidboot.selinux=permissive text to ensure I get through the SELinux enforcement (though I know its a temporary solution).
5. I modified Android.bp file under frameworks/base to include IFooService.aidl file during compilation.
Unfortunately, after I successfully built the project and try to flash it on the Pixel 3a, the system is stuck at boot with Android logo.
I could see the service was successfully started after checking logcat and logcat -b but dies soon after. I can see that's the case with all the other services too. So probably its the boot time issue. Secondly, I can see the SEPolicy warning but the permissive parameter is set to 1 so that shouldn't be the issue. But still the Android doesn't boots up.
So my question is, is this the right way to define a new system service? I also read that it is not recommended to make changes to original files and try to create new service in the vendor directory. In this article https://devarea.com/aosp-creating-a-system-service/ it does just that by creating a persistent app inside the vendor directory and hosting the service inside. I tried even that but the build fails. And I could see the SELinux implementation has changed a lot with a need to include version compatibility changes which has to be incorporated manually but there is very limited and too confusing documentation regarding that!
Please guide me on what I might be doing wrong and how to resolve it? I have tried AOSP books, documentation and browsing the source code in last 30 days but with no luck.
I am also planning to share a comprehensive sample with the community post this because I feel it could help many people trying incorporate new system services and the documentation is also few and far between.
I'll add the actual code and logs if anyone can help me finding a way.
Thanks,
Gaurav

Categories

Resources