[Moto G 4G Android Development] minimale_ldz:
Introduction

This ROM is based on lost101's work, that you can read about here. I used his Retail EU 5.1 ROM (Optimized) v1.1 for XT1039 as a base of my own "project" of further debloating and removing as much Google's stuff as possible. The main aim is to use clean and stable Android and improve privacy. My work is simply removing things from system/app and system/priv-app folders and testing if everything still works, and by "works" I mean that I can use my phone as a daily driver and depend on it.

Disclaimer

Even if everything works 100% fine for me I take no responsibility for anything that happens to anyone else's device after flashing my ROM. If you want to try it, do it on your own risk.

Description

This is Retail EU 5.1 ROM (Optimized) v1.1 for XT1039 by lost101 with the following modifications:

ver 0.9

Files removed from system/app folder:

- atfwd

- BasicDreams

- Calculator

- CalendarGoogle

- com.motorola.android.settings.diag_mdlog

- Exchange2

- Facelock

- FMRadioservice

- FMRecordService

- GoogleContactsSyncAdapter

- HoloSpiralWallpaper

- LiveWallpapers

- LiveWallpapersPicker

- NoiseField

- PartnerBookmarksProvider

- PhaseBeam

- PhotoTable

- Piktures

- PrintSpooler

- SoundRecorder

- UserDictionaryProvider

- VisualizationWallpapers

Files removed from system/priv-app folder:

- AudioEffects

- BackupRestoreConfirmation

- CalendarProvider

- ContextEngineClient

- CQATest

- Email

- EmaraPhoneExtns

- GoogleBackupTransport

- GoogleFeedback

- Moodles

- MotCamera

- Phonesky

- PreloadContacts

- WallpaperCropper

Files added to system/app folder:

- SimpleExplorer

ver 0.9.2

Files removed from system/app:

- BrowserProviderProxy

- LatinIMEGoogle

- HTMLViewer

- SimpleExplorer

Files removed from system/priv-app:

- CellBroadcastReceiver

- WapPushSI

Files removed from system/etc/permissions:

- com.google.maps.xml

- com.google.android.media.effects.xml

- com.google.widevine.software.drm.xml

- com.motorola.camera.xml

- com.motorola.context.xml

- com.motorola.gallery.xml

- com.motorola.software.fmradioservice.xml

- com.motorola.software.fmrecording.xml

Files removed from system/network:

- com.google.android.maps.jar

- com.google.android.media.effects.jar

- com.google.widevine.software.drm.jar

- com.motorola.gallery.jar

Files removed from system/vendor:

- PittPatt folder and its content

Files removed from system/usr/srec/en-US:

- all files

Files added to system/app:

- AnySoftKeyboard

- MIxplorer

ver 1.0_beta

Files removed from system/app:

- ConfigUpdater

Files removed from system/priv-app:

- GmsCore

- GoogleLoginService

- GoogleOneTimeInitializer

- GooglePartnerSetup

- GoogleServicesFramework

- MotoOneTimeInitializer

- SetupWizard

- SetupWizardExt

- StorageOptimizer

Files added to system/bin:

- sqlite3 (downloaded here). Please continue reading to see why you need it

build.prop changes:

- "ro.setupwizard.mode=OPTIONAL" changed to "ro.setupwizard.mode=DISABLED"

Flashing

1. Boot into TWRP

(2. Backup)

3. Format data (Wipe>Format data>yes)

4. Transfer ROM to SD card/Local storage

5. Wipe>Factory reset

6. Install

7. Reboot

Remove SIM card before initial boot. This is to avoid download of any automatic "updates" using your mobile data during initial setup of your device.

Initial boot and initial setup (v0.9 & 0.92 only)

a) Skip connecting to WiFi network

b) On "About your privacy" screen go to privacy settings and disable the following:

- Help improve Motorola products (enabled by default)

- Enhanced device support (enabled by default)

c) Skip adding your name

d) On "Google services" screen disable the following:

- Use Google's location service (enabled by default)

- Help improve location services (enabled by default)

- Help improve your Android experience (enabled by default)

Initial boot and initial setup (v1.0_beta only)

No initial setup as Setup Wizard has been removed

Post-installation setup (v0.9 & 0.9.2 only)

1. Turn WiFi off and go to Google Settings:

a) in "Ads" tab opt out of interest-based ads and reset advertising ID

b) in "Location" tab turn location on - when "Improve location accuracy?" pop-up appear choose "DISAGREE" and turn location back off

c) in "Security" tab disable "Allow remote lock and erase", "Improve harmful app detection" and "Scan device for security threats" options (all enabled by default). These steps are essential if you want to disable Google Play Services

2. Go to phone's Settings:

a) Language & input > Spell checker (only ver 0.9. For later versions see post #2):

- while it's on by default enter Google Spell Checker settings and disable "Look up contact names" option (enabled by default)

- Turn Spell checker off

b) Language & input > Google Keyboard (only ver 0.9. For later versions see post #2):

- in "Accounts and Privacy" tab disable "Improve Google Keyboard" option (enabled by default)

- in "Preferences" tab disable "vibrate on key press" and "sound on key press" options (it saves some battery)

- in "Text correction" tab disable "Block offensive words", "Auto-correction", "Show correction suggestions", "Personalised suggestions","Suggest contact names" and "Next-word suggestions" options (all enabled by default)

c) Sound & notification > other sounds:

- disable "Dial pad tones", "Screen locking sounds", "Touch sounds", "Vibrate on touch" options (all enebled by default) to save some battery

d) WiFi > Advanced > disable "Scanning always available" option. It will save your battery and protect your privacy as some sensitive data (eg. saved network names and addresses) is being broadcasted by your device. If you want to keep scanning on you can protect yourself with eg. PryFi

e) Wireless & networks > More > Emergency broadcast - turning them off will save some RAM and battery life

f) Apps > All > disable the following:

- Browser message

- Downloads

- Google account manager*

- Google one time init*

- Google partner setup*

- Google play services*

- Google services framework*

- Messenger

- Motorola one time init*

- Motorola services*

- Photos

- Setup*

- Setup Wizard*

*In case you're wondering why they were not removed from the ROM - they're all being used during initial boot and setup. If you remove them from the ROM the system won't start. If you remove them from the system/priv-app folder after installation you won't be able to do factory reset.

g) Open Dialer and go to Settings > Advanced > turn "Nearby places" off

4. Use Simple Explorer to install all the apps you want. I'd suggest installing firewall and setting it up before inserting SIM card and turning WiFi back on to avoid any unnecessary and unwanted downloads. I personally use AFWall+ (XDA thread, download)

Post-installation setup (v1.0_beta only)

After your device boots you will find the Setup Wizard is not launching. This is normal since all GApps have been removed. Everything seems normal and ready to use, however some crucial UI functions (Home button and quick settings) are disabled - this is also normal. Home button is disabled to prevent user escaping Setup Wizard before it's completed - same for Quick Settings - you can't access them before setup is done. In normal situation unlocking UI functions is handled by Setup Wizard and GmsCore services, but since they've been removed from this ROM you have to do it manually:

1. Go to Settings > About phone > tap Build number 7 times to unlock Developer options > back > Developer options > enable USB debugging

2. Connect the phone to PC and execute the following commands with ADB:

adb shell
su
sqlite3 /data/data/com.android.providers.settings/databases/settings.db
insert into global (name, value) VALUES('device_provisioned', 1);
insert into secure (name, value) VALUES('user_setup_complete', 1);
.quit
reboot

Your UI is now restored and your phone is ready to use. Please refer to setup instructions for versions 0.9 and 0.9.2 for general ideas what can/should be done next.

Known issues

- FC of Language & input menu in Settings after going back from "Language", "Spell checker" and "Google Keyboard"

Battery life

I'm using ver 1.0 beta (I guess it's not beta anymore as it proved to be working and stable). The battery life is exceptional. Overnight drain is around 0.1-0.2% per hour so you can expect your battery to go down no more than 1-2% when you sleep. BetterBatteryStats (big thanx to chamonix for the free XDA edition of his app) shows that my device stays in deep sleep for about 98% of time. Please note I've got all sync services disabled as well as wifi scanning and all radios but phone (which is in 2G mode all the time), I also use Greenify and the biggest battery drainer seems to be Gravity Screen I use to automate screen on/off with flip cover. Don't be surprised if your phone stays on in standby mode for more than 3 weeks if left in one place with good network signal (vs. official 8.8 days).

In everyday use, which for me means having the phone on 24/7, making a few calls a day and some 1 hour of WiFi/4G internet browsing daily I usually have to charge it once every 3-4 days. Please note I try to keep my battery between 90-10%, so I rarely charge it 100%.

Life after Google

You can try using Micro GmsCore to access Play Store content, and here are some alternatives:

1. Interesting and useful apps in F-Droid store:

- Adaway (system-wide ad blocker)

- AFWall+ (very nice firewall. I use it in whitelist mode because it blocks internet access to all apps by default)

- Etar (calendar. Won't work without Google calendar service and account)

- K-9 mail (bit ugly but awesome mail client)

- Open camera (stock camera replacement)

- Wifi automatic (turns wifi off when you lock the screen which saves battery and improves security. Bugged a little and randomly disables wifi from time to time)

- SMSsecure (messaging app with encryption)

- 920 Editor (text editor)

- Document Viewer (self explanatory)

- Network Log (self explanatory)

2. Other interesting and useful apps around the web (mostly on XDA):

- ApkTrack (app updates tracker),

- Calc+ (calculator),

- CoolTool (CPU and RAM usage and other info display),

- DejaOffice (office app that looks a bit outdated, but it's the only calendar app to work without Google services I found so far),

- Disconnect.me (private web searches; the app FC right after starting it, probably due to lack of Google search services available)

- DriveDroid (turns the phone into Linux live USB),

- ES File Explorer (file explorer),

- Firefox (web browser),

- Gravity Screen (Turning screen off and on without using physical power button),

- Greenify (apps hibernator),

- KWGT (custom widget maker),

- LiveBoot (Chainfire's app that replaces boot animation with system log display),

- maps.me (open source google maps alternative),

- MiXPlorer (file explorer),

- MoboClean (permissions manager),

- Naked Browser (web browser),

- NetGuard (no-root firewall),

- NeutriNote (notes),

- Nova Launcher (launcher)

- Open Camera (same as F-Droid app),

- Parasol (community based permission manager),

- PryFi (WiFi security),

- QuickPic (gallery),

- Recently ("close all apps" button in recents window),

- Recordr (sound recording app),

- Servicely (services management. Think twice before installing and using it :) - developer's G+ site, developer's APKMirror downloads

- SD Maid (cleaning tool),

- Super Backup (apps, sms, call logs, etc. backup),

- Titanium Backup (data backup),

- True phone (dialer),

- VLC (media player),

- WifiKill (WiFi killer),

- Wifi Protector (WiFi security, anti-wifikill),

- Xposed (sdk22 arm version is the right one for XT1039)

You can find more interesting apps and links on this XDA forum

3. Software that may help you secure your device - sufficientlysecure.org

4. More security software - Secure Mobile Apps

5. XDA Labs (alpha version of XDA app store)

6. Firefox browser add-on that lets you download apk files directly from google play store (without Google account connected to your device) in case you can't find desired app anywhere else.

7. Alternative app-stores, .apk mirrors, etc. - use at your own risk. So far I only tried Amazon's store - the pro is that it exists, the cons are that it requires tons of permissions, has very unfriendly interface, takes a lot of space, and the apps you download will only work as long as the store's app is installed.

Credits and thanks

Motorola for making such a good device

lost101 - creator of original ROM

DF1E - creator of Simple Explorer

HootanParsa - creator of MIxplorer

Menny Even Danan and all creators of AnySoftKeyboard

_that and all people behind TWRP for their work

Sqlite3 developers

All the developers who share useful information and solutions in the web

Download

XT1039_Retail_EU_51_Optimized_v1.1_mod_v0.9.zip

XT1039_Retail_EU_51_Optimized_v1.1_mod_v0.9.2.zip

XT1039_Retail_EU_51_Optimized_v1.1_mod_v1.0_beta.zip