Saturday, February 13, 2016

De-bloating / customized stock ROM HOWTO

De-bloating / customized ZenPad Z580CA stock ROM HOWTO


Get the reference full firmware (not just the over-the-air (OTA) patch) from Asus (will be mirrored here)

Unzip it; start modifications:

1) Debloating: remove from system/app and system/priv-app the unwanted subdirectories. Compare the original lists:

../ORIGINALS/UL-P01M-JP-4.6.1.0-user/system/app/:
AffiliateLauncher             AWS                   DMClient                   IBook                 Music2                    PicoTts                           Stk                      WeatherTime
AsusAs                        BasicDreams           DocumentsUI                InstantPage           MyASUS                    PlayTo                            Street                   WebViewGoogle
ASUSBrowser                   BbblerActors          DownloadProviderUi         IntelCamera           MyFrame                   PlusOne                           StylusDataService        WhatsNext
AsusConfigUpdater             Bluetooth             DrBooster                  IrisService           MyWater                   PowerHistory                      Syndor                   Yahoo
AsusDrawRes                   BookLiveDownloader    Drive                      Keyboard              NoiseField                PowerSaving2                      SystemUpdate             YouTube
AsusMirror                    BrowserProviderProxy  DriveActivator             KeyChain              Omlet-stub                PrintSpooler                      talkback                 ZenUIHelp
AsusSensorService             CaptivePortalLogin    Flipfont                   Kindle                PackageInstaller          PuffinBrowser                     TaskManager              ZinioReader
AsusSetupWizard               CertInstaller         Galaxy4                    LatinImeGoogle        PacProcessor              QuickMemo                         Transformer              ZinioSettingsProvider
AsusSplendidCommandAgent      Chrome                Gmail2                     LiveWallpapers        PAIStub                   QuickMemoService                  Tripadvisor
AsusVisualMasterCommandAgent  CleanMaster           GoogleCalendarSyncAdapter  LiveWallpapersPicker  PartnerBookmarksProvider  QuickPanel                        UpdateLauncher
ASUSWebView                   ConfigUpdater         GoogleContactsSyncAdapter  LocationPicker        PCLinkBinary              QuickSearch                       UserDictionaryProvider
ATOKIME                       CWSClientService      Hangouts                   Lockscreen            PCLinkManager             RemoteLink                        Videos
AudioWizard                   DataTransfor          HdmiSettings               Maps                  PhaseBeam                 SensorCal                         VisualizationWallpapers
AudioWizardView               DeskClock             HoloSpiralWallpaper        MobileManager         PhotoFrameWidget          sl_installer                      VppSettings
AwareResource                 DLNAService           HTMLViewer                 MobileManagerService  PhotoTable                SMMI_TEST_V5.1.13_CSC_L1L2_Z580C  WAPPushManager

../ORIGINALS/UL-P01M-JP-4.6.1.0-user/system/priv-app/:
AppLocker                   AsusEasyLauncher     AsusLiveDemoUI    AsusSystemUI               ContactsProvider         GoogleBackupTransport     ituxd                ProxyHandler         SuperNote          ZenCircle
ASUSAppInstallationService  AsusEmail            AsusMusic         AsusTask                   DefaultContainerService  GoogleFeedback            ManagedProvisioning  SettingsProvider     Telecom
AsusBackup                  ASUSGallery          AsusPhotoCollage  AsusVisualMaster           DownloadProvider         GoogleLoginService        MediaProvider        SetupWizard          TelephonyProvider
AsusCalculator              ASUSGalleryBurst     AsusQuickSearch   AsusZenUIServices          ExternalStorageProvider  GoogleOneTimeInitializer  MicroFilm            SharedStorageBackup  TeleService
AsusCalendar                AsusKidsLauncher     AsusSettings      BackupRestoreConfirmation  FileManager2             GooglePartnerSetup        MmsService           ShareRimBinary       Velvet
AsusCamera                  AsusLauncher         AsusSmartCrop     CalendarProvider           FusedLocation            GoogleServicesFramework   MusicFX              Shell                VpnDialogs
AsusContacts                AsusLiveDemoService  AsusSplendid      CMSKeyV3                   GmsCore                  InputDevices              Phonesky             SoundRecorder        WallpaperCropper

and a debloated, but still pretty fat one:

system/app/:
AffiliateLauncher             ATOKIME               CaptivePortalLogin  DocumentsUI                IBook           Maps                      PlusOne           RemoteLink         TaskManager              WebViewGoogle
AsusAs                        AudioWizard           CertInstaller       DownloadProviderUi         InstantPage     MobileManager             PowerHistory      SensorCal          Transformer              WhatsNext
AsusConfigUpdater             AudioWizardView       Chrome              Drive                      IntelCamera     MobileManagerService      PowerSaving2      sl_installer       Tripadvisor              YouTube
AsusDrawRes                   AwareResource         CleanMaster         Flipfont                   IrisService     PackageInstaller          PrintSpooler      Stk                UpdateLauncher           ZenUIHelp
AsusMirror                    AWS                   ConfigUpdater       Gmail2                     Keyboard        PacProcessor              PuffinBrowser     Street             UserDictionaryProvider
AsusSensorService             BasicDreams           CWSClientService    GoogleCalendarSyncAdapter  KeyChain        PAIStub                   QuickMemo         StylusDataService  Videos
AsusSetupWizard               Bluetooth             DataTransfor        GoogleContactsSyncAdapter  LatinImeGoogle  PartnerBookmarksProvider  QuickMemoService  Syndor             VisualizationWallpapers
AsusSplendidCommandAgent      BookLiveDownloader    DLNAService         HdmiSettings               LocationPicker  PicoTts                   QuickPanel        SystemUpdate       VppSettings
AsusVisualMasterCommandAgent  BrowserProviderProxy  DMClient            HTMLViewer                 Lockscreen      PlayTo                    QuickSearch       talkback           WAPPushManager

system/priv-app/:
AppLocker            AsusSettings   AsusVisualMaster           ContactsProvider         GmsCore                   GooglePartnerSetup       MediaProvider  ProxyHandler         Shell              TeleService
AsusLauncher         AsusSmartCrop  AsusZenUIServices          DefaultContainerService  GoogleBackupTransport     GoogleServicesFramework  MicroFilm      SettingsProvider     SoundRecorder      Velvet
AsusLiveDemoService  AsusSplendid   BackupRestoreConfirmation  DownloadProvider         GoogleFeedback            InputDevices             MmsService     SetupWizard          SuperNote          VpnDialogs
AsusLiveDemoUI       AsusSystemUI   CalendarProvider           ExternalStorageProvider  GoogleLoginService        ituxd                    MusicFX        SharedStorageBackup  Telecom            WallpaperCropper
AsusQuickSearch      AsusTask       CMSKeyV3                   FusedLocation            GoogleOneTimeInitializer  ManagedProvisioning      Phonesky       ShareRimBinary       TelephonyProvider

2) Manually change the build restrictions/details as desired (allow tethering; remove fake shutter sound upon taking photos etc.):
edit the file system/build.prop
[...]
ro.camera.sound.forced=0
[...]

3) Recompress the image: from within its root directory containing:
$ ls
boot.img  droidboot.img  file_contexts  ifwi.zip  l_recovery.fstab  META-INF  partition.tbl  recovery  splash.img  system

$ zip ../UL-P01M-JP-4.6.1.0-user-DEBLOATED.zip -r *
For the above selection of utilties, a debloated 4.6.1 stock ROM is made available here.

4) Prepare a fat32 (i.e. not an 'extended FAT': better compatibility) microSD card:
# cfdisk /dev/mmcblk0
then 'New', 'Change type' to: b (W95 fat32), 'Write' and 'Quit'

# mkfs.vfat /dev/mmcblk0p1 -n SD16GB_fat

5) Copy there the zipped image. Add any additional extras desired, like SuperSU to root the device:

6) Umount the microSD card and place it back into the device. Reboot it into Droidboot: either connect via USB (after enabling 'USB debugging' under 'Settings'->'Developer mode') and issue:
$ adb reboot bootloader

or reboot it, keeping Volume UP and Power pressed together, until the android logo with service hat shows up.

7) Download the Intel Fastboot Tethered Temporary Recovery Session Launcher (FBRL; mirror of the relevant files here) and unpack i.e. under /tmp/FBRL the files:

-rw-r--r-- 1 root root  410105 May 16  2015 recovery.launcher
(MD5SUM: 572cc4351881656cf4df7d538f60dd7f)
-rw-r--r-- 1 root root  183198 May 16  2015 recovery.trigger.new
(MD5SUM: d3c12ee127f87437a8e94470f193dc57)
-rw-r--r-- 1 root root  174902 May 16  2015 recovery.trigger.original
(MD5SUM: a1047156addd80ae14284816e0de94df)
-rw-r--r-- 1 root root 3560544 Dec 27  2014 recovery.zip
(MD5SUM: 49e8bb46834dccb1ef95a2bb9b55a9db)

8) Connect the USB cable, and from such directory issue:

# fastboot devices (verify connectivity. If nothing shows up, an obsolete version of the utility may be installed. Get a new one, for instance a recent Debian package for your desktop architecture).

Then, if things seem fine:
# fastboot flash /tmp/recovery.zip recovery.zip
# fastboot flash /tmp/recovery.launcher recovery.launcher
# fastboot flash /system/bin/cp recovery.trigger.original
# fastboot oem backup_factory

Device will reboot into a custom CWM recovery, and show (slowly, line after line):
Tethered Recovery Launcher Concept
social-design-concepts. 05/16/2015
[...]
After some more information listing, it will refresh and show a new menu in blue.

9) Select:
9a) Wipe data/factory reset;
9b) Advanced->wipe Dalvik cache->Yes - Wipe Dalvik Cache
9c) Mounts and Storage -> Format /system -> Yes - Format
9d) Format /data and /data/media (/sdcard) -> Yes - Format
go back;
9e) install zip -> choose zip from external card -> Select UL-P01M-JP-4.6.1.0-user-DEBLOATED.zip -> Yes - Install UL-P01M-JP-4.6.1.0-user-DEBLOATED.zip
(it will take some minutes - BE PATIENT!)
9f) Repeat with any desired additional zip file placed into the microSD (i.e. the last stable UPDATE-SuperSU-v2.46.zip (mirror here) for root access), and go back;

10) Reboot system now -> Yes - fix root
The device will restart; the message 'Android is upgrading' will show up shortly. All done! ;-)

CURRENT ISSUES / LIMITATIONS:

1) I've tried to make initially even Gmail optional; this seems to work at first, however it will soon require the user to upgrade 'Google Play Services' from the Play Store. Which works... except that then the service will keep crashing and restarting, with the error message 'Unfortunately Google Play services has stopped'.

2) Minor annoyance: many removed package will be still automatically downloaded at the first boot; but they can be now cleanly removed.

3) After debloating, the /system partition does not need to be so large. As shipped, 'df' at 'adb shell' gives (as root) it to be around 2.8GiB, but it could be now wiser to reduce its size.

I haven't touched the partiton table yet, just to keep on the safe side. The file 'partition.tbl' would allow to simply reduce its default size (just changing the number of blocks (in units of 512 bytes?) where /system should end, and hence /data begins). It is called by the script: 'META-INF/com/google/android/updater-script', but only if the is_osip function returns 'true' (see i.e. this presentation)

However, a following OTA update will expect to find enough space, and thus break if these parameters are modified.

Enjoy a cleaner device! Mirror copy of the above debloated & /system/etc/hosts -filtered stock ROM is here.

4 comments:

  1. Does the boot-loader not need to be unlocked for this to work?

    ReplyDelete
  2. mine is already rooted, maay I just flash the zip from twpr?

    ReplyDelete