Thrilleratplay / LOSdiet

LineageOS without the carbs
https://thrilleratplay.github.io/LOSdiet/
MIT License
10 stars 0 forks source link

Port to latest versions of Lineage OS? #9

Open TroyRobinson opened 3 years ago

TroyRobinson commented 3 years ago

Thank you for making this incredible tool for paring down Lineage OS. What would one need to edit in the LOSdiet's output files to have them work fully with the latest versions of LineageOS?

Thrilleratplay commented 3 years ago

If you know the package names to remove, go into the menu and check "Expert mode", at the bottom there is text area where you can paste in the name of any additional package.

Sorry, I have not had time to maintain this over the years. For a more robust and permanent solution, fork this project and edit the apkData.csv. If I remember correctly, this is the only file that needs to be modified to alter the list. All of the magic happens locally in the browser; no special service is needed. The page can be hosted locally with any simple http server or through Github pages, like how I currently have it.

TroyRobinson commented 3 years ago

Thank you so much for the brief, @Thrilleratplay! I have little-to-no experience with ROMs & flashing. If I was to test flashing a file outputted from this old version of LOSdiet in with a recent LineageOS ROM version, is there any potential of bricking the phone, so long as I avoid the LOSdiet expert mode? I'm just trying to disable the app store and browser to essentially make a dumb phone, even on factory reset. BTW, I receive your software and answers without any legal expectations / I'm responsible for breaking my own phone. Thanks again!

Thrilleratplay commented 3 years ago

@TroyRobinson I am not going to say there is "no chance" of bricking your phone, especially with Google implementing new security measures in each version, but that is very unlikely. In expert mode, there is chance you will mess up your device but in a way that can be fixed.

Given that you are new to custom roms, let me try to walk you through the basics of how this works and hopefully that will be enough to correct any issue you create. What seems like black magic and unicorns is actually something very simple. If you are familiar with Linux/Unix systems, then this simple and it is an init script. If not, this is a series of commands that runs every time Android boots. All it does is, when LineageOS loads, it will loop through the apps listed and try to remove them from various system app locations. If it finds them, it removes them if not it continues on. That is it. The reason this runs every time Android boots is because LineageOS reinstalls them when an update is flashed, this will re-remove them before boot completes so it looks like they were never there. Knowing this, the Uninstall Zip just removes the script so the next time LineageOS is flashed, the apps will reappear. Ta da! As long as you can flash the uninstall zip and LinageOS rom in recovery either by the menu or via sideloading, you should be able to revert any changes.

I appreciate the understanding that this is simply a tool for you to use at your own risk. Don't get made at the gun manufacture if you shoot yourself in the foot. Although, if new to flashing customs roms, I would probably wait to become more comfortable with the various quirks or use an older device to play around with. In either case, always backup your data before flashing anything

TroyRobinson commented 3 years ago

Thank you so much, @Thrilleratplay! That is a really helpful and demystifying explanation of what's involved, particularly: "If it finds them, it removes them if not it continues on" Also, good to know about the uninstall method. And wise advice. Thanks again! - Troy

TroyRobinson commented 3 years ago

@Thrilleratplay Thank you again for your gracious support. Noob-question: your set-up instructions read 'use "Make ZiP" to create "Flashable ZIP."' I've tried flashing this Zip to my Lineage OS phone via ADB Sideloading with TWRP* and also via Fastboot although the files I've removed in the LOSdiet selection before making the zip (e.g. the browser) are still appearing in my phone after sideloading and phone boot-up. Can you provide a few instructions on what to do with the zip in the flashing process?** Thanks again!

*https://android.gadgethacks.com/how-to/sideload-flashable-zips-android-with-twrp-0176529/ ** https://android.gadgethacks.com/how-to/complete-guide-flashing-factory-images-android-using-fastboot-0175277/

Thrilleratplay commented 3 years ago

@TroyRobinson Depending on the LineageOS version you are using, this may no longer without significant changes. I am using Lineage 18. Using my laptop, I ran adb shell pm list packages -f | grep -i jelly. Jelly is the name of Lineage's browser. The result was:

package:/system/product/app/Jelly/Jelly.apk=org.lineageos.jelly

Looking at the line that removed the apk in the resulting zip file you can see that is does not even check the /system/product/app/ directory and the apk file is no longer named "org.lineageos.jelly.apk".

If your end goal is to no longer see unused apps from your app drawer, it is a lot easier to use a launcher that allows app hiding. This is what I have been doing and I use Lawnchair which is available through F-Droid. If you wanted to actually remove the apks, then the paths and app name would need to be updated to remove the newer apk. Sorry, I don't have the bandwidth to make these changes.

TroyRobinson commented 3 years ago

Thank you for that explanation and app tip, @Thrilleratplay! I am attempting to permanently remove the browser (to be replaced with a minimalist-focus browser that can't be reverted). Based on what you're saying, I could (1.) edit the resulting zip's files to point to the new location of the Jelly browser in the later LineageOS versions, (2.) repackage the zip, and (3.) then flash the modified zip to my phone? (via ADB sideloading or a better way?)

Thrilleratplay commented 3 years ago

@TroyRobinson Correct. If unzipped, the file should be addon.d/20-LOSdiet.sh (there may be another directory level or two depending on how it is extracted but make sure when rezipping the directory structure are the same as the original zip). Effectively, it will be something like this:

#!/sbin/sh
#
# /system/addon.d/20-LOSdiet.sh
# During a LineageOS upgrade this script removes user selected apps

if [[ "$1" == "post-restore" ]] || [[ "$1" == "" ]]; then
     rm -rf /system/product/app/Jelly/Jelly.apk* && echo "Removed Jelly"

    # REMOVE MORE APPS HERE
    # rm -rf  <FULL PATH TO APP>* && echo "Removed <APP NAME>"
fi

Make sure the file is saved in Unix format and rezip or replace the existing file in the original zip. Provided no file names are changed, the uninstall file should still work with your changes. Sideload it or copy it to the phone and install zip, which ever is easier for you. If it does not work, I think an error will appear in adb logcat

TroyRobinson commented 3 years ago

Thank you much for the direction! I'll give it a go.

Jogai commented 2 years ago

For everyone finding this, here is a nice alternative: https://github.com/0x192/universal-android-debloater