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.

Sunday, February 7, 2016

Rooting the Asus ZenPad S 8.0 Z580CA tablet

Rooting the ZenPad S 8.0 Z580CA tablet

Asus ZenPad S 8.0 Z580CA product shot

 


The tablet in subject is a very slim and portable high resolution 8' 4:3 device by Asus. Different variants are available; here the model with an Intel Atom Z3560 and 2GB RAM / 16 GB SSD will be considered (full specifications: here).

Instructions are provided for a standard Linux desktop, in particular a Debian stable 8.3 distribution "Jessie". For Windows, see i.e. here. Japanese notes: here.

Enable "Developer mode" on the tablet: "Settings" -> "About device" -> tap "Build number" many times. Confirm and look for the new "Developer options" entry appearing among the "Settings". Tap the "USB Debugging" box to enable it.
Download or copy into the device UPDATE-SuperSU-v2.46.zip (mirror here).

Connect the provided USB cable to an available desktop port, and verify that root can see the device: issue (as root) on a desktop terminal the command:
# adb devices 

Reboot into the bootloader:

# adb reboot bootloader

Verify that fastboot can still see the device:
# fastboot devices

If lsusb shows it but fastboot returns nothing, it can be a known issue with the utility version provided by the desktop Linux distribution is too old. Try a more recent one from Debian 'testing' for instance, or a recompiled i686 binary is provided here (mirror) from the XDA forum by senior developer Vampirefo (but beware of the security risks - safe hex is better! ;-).

Download on the desktop the last Intel Fastboot Tethered Temporary Recovery Session Launcher (FBRL; mirror here) and unpack it under /tmp/FBRL/.

Move to such directory and issue (as root) on a desktop terminal the following 4 commands:

# 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

... and check on the device screen that each one completes without problems. Select 'Reboot' to continue.

Insert a microSD card (important: make sure it is formatted as 'FAT32', not 'exFAT', for compatibility reasons: under Linux, the filesystem must be created with mkfs.vfat, not mkfs.exfat) in which the UPDATE-SuperSu-v2.46.zip binary 

Select: Install zip, read it in from 'External SD', proceed with installation and then reboot into the new, rooted state.
Enjoy things like i.e. Linux Deploy for availability of a really open source, complete system!