[Samsung Galaxy A3, A5, A7 (2017) ROMs, Kernels, Re] jf581746:
Debloated Stock ROM with encryption + root + microG

Thank you Obifur for your suggestion to just debloat stock ROM myself - brilliant :)

I agree that current custom ROMs have too many drawbacks: unstable, bad camera quality for low light, no wifi calling, echo for calls, some devs don't respect open source towards community, no reproducible builds.

I changed Obifur's solution to add encryption for a rooted, debloated, google-free result. I used Magisk+EdXposed for microG+Signature-Spoofing+debloating instead of patching binaries and removing/adding system apps. This way you can hopefully upgrade stock by just flashing with CSC_Home and reinstalling Magisk to boot image.

Result -- tested on Device: Galaxy SM-A320FL (A3 2017)

Stock ROM with all features but without google

MicroG completely working (geo location services, fake playstore)

Rooted, system-less (Magisk)

Samsung encryption working

Not working:

SafetyNet (there seems to be a Magisk module that might help)

No possibility to Mount/backup data partition from TWRP, due to proprietary Samsung encryption

DM-Verity must be disabled, although most steps are system-less

Detailed Steps -- Remarks: Stick to the steps, I try to explain the order where necessary

Preparations

Stock ROM from: https://www.sammobile.com/ (you need to register)

Download any ROM of your region and possibly carrier (I preferred an 'open' build, without branding). Usually you can change language, but some features may be blocked by ROM or carrier depending on chosen CSC. After updating to a new ROM you may not be able to downgrade, depending on the bootloader bits, so choose wisely.

Odin3 from https://xdaforums.com/showthread.php?t=2711451

Custom recovery TWRP: https://dl.twrp.me/a3y17lte

Disable_DM-Verity script (*.zip) from https://xdaforums.com/android/software/universal-dm-verity-forceencrypt-t3817389

adb may be needed for reboot/sideload/shell, alternatively any Terminal Emulator App for direct android shell access

Backup internal user data, remove SIM + SD card

Flash ROM

Boot to Download Mode: press Vol- + Home + Power

Odin: flash ROM: BL, AP, CP, CSC (just keep "Auto-Reboot")

-> Reboots to system, prepares ROM, encryption. Wait until welcome screen!

Reboot to Download Mode

Odin: flash custom recovery TWRP on AP slot (https://dl.twrp.me/a3y17lte/), (disable "Auto-Reboot")

Reboot to Recovery: press Power + Vol- and when screen off: Power + Home + Vol+

Reboot to sytem would reinstall stock recovery

Format Data to trigger re-encryption after disabling DM-Verity

Disable DM-Verity using the

Disable_DM-Verity_XXX.zip

file (Keep encryption, you may keep quota)

I used sideload and adb, otherwise rename it correctly

Reboot to System (wait for Samsung logo to disappear -> data partition encrypted)

Do this step! Otherwise DM-Verity will not be disabled completely and you may do all steps from the top again

Reboot to recovery

Install Magisk

-> Log: "Mounting /system" (would break DM-Verity)​

Replace Google with microG

Reboot to System: Take Welcome Wizard

"Require pattern when device turns on" (before encrypted with default password)

Activate Developer options + Allow USB debugging

Play-Store -> Setting: Disable Updates (otherwise uninstalling updates needed before installing microgG)

Connect Wifi (restrict background apps if you like)

Magisk Manager -> "Download"

Riru Core (for EdXposed)

Riru EdXposed (SandHook, for signature Spoofing)

BusyBox for Android NDK (for Debloater + App Systemizer)

Debloater (for debloating Google and any apps)

App Systemizer (for converting microG apps to system apps)

Reboot System

Debloat Google apps that conflict with microG:[FONT=&quot]

https://github.com/microg/android_packages_apps_GmsCore/wiki/Prerequisites

[/FONT]

Use 'debloat' command using adb shell or Terminal Emulator App (su command needed in advance)

GmsCore, GoogleBackupTransport, GoogleFeedback, GoogleLoginService, GoogleOneTimeInitializer, GooglePartnerSetup, GoogleServicesFramework, Phonesky, SetupWizard, Velvet (disable by number)

Install EdXposed Manager (dummy App is already installed, execute it, follow Github link and install APK) -> Enable in Manager

[FONT=&quot]F-Droid[/FONT]​

Install F-Droid.apk

Add MicroG repository

Reboot System (ignore warnings because of missing google services)

Install from F-Droid:

GmsCore, GsfProxy, FakeStore, DroidGuardHelper (Uninstall any updates from system apps in case they appear installed)

Optional: NLP backends: Mozilla, Local GSM, Nominatim

Systemize to priv-app: GmsCore, GsfProxy, FakeStore (https://github.com/microg/android_packages_apps_GmsCore/issues/462)

Use 'systemize' command using adb shell or Terminal Emulator App (su command needed in advance)

EdXposed Manager, "Download": Install FakeGApps (-> Signature Spoof MicroG Apps) -> Enable

MicroG Settings app: Grant privileges, Add Google account, Register, Enable Cloud Messaging, Enable SafetyNet, activate NLP backends, System Settings: Locating Method High Accuracy

Reboot system

Test and finish system

MicroG tests: Self-Check in Settings, 'Push notification Tester' app

Insert SIM and SD card

Prepare Apps (F-Droid + privileged app Magisk module, Aurora Store + Arora services Magisk module, XPrivacyLua, ...)

Finally, debloat all the Google/Samsung/Microsoft/Branding bloat, if you like...

Enjoy again :)