Android: Difference between revisions

From miki
Jump to navigation Jump to search
Line 304: Line 304:
adb pull /data/media/0/TWRP
adb pull /data/media/0/TWRP
</source>
</source>

To restore the backup on a '''different''' phone (but same model):
* Copy the old TWRP backup on the new phone.
* Make a small backup using TWRP (eg. boot partition).
* Move the old TWRP backup to the same directory as the new partition. Eg: Move content of {{file|TWRP/BACKUPS/410060be455971c1/}} to {{file|TWRP/BACKUPS/4100598bc8bb9153/}}.
* Restore the old backup.
The move is necessary because TWRP uses the phone serial number to locate the backups.


== Troubleshooting ==
== Troubleshooting ==

Revision as of 08:09, 27 July 2020

Links

On this wiki

How-To

Sync phones

For instance to sync old and new phones.

Contacts
  • Sync via Google Account.
Calendar
  • Sync via Google Account.
Color Notes
  • Sync via Google Account.
SMS/MMS/Call logs
  • Use SMS Backup & Restore app.
Photos
  • Sync via samba share (using for instance ES Explorer app).

Transfer Samsung to Xiaomi

Install Mi Mover application on both phones [1].

  • On source, select I'm a sender. On target, select I'm recipient.

Backup with Helium (ClockWorkMod Carbon)

Do not use backup to Internal SD since the internal files cannot be exported. Copying these files from another phone, or as a backup restore, does not work. This method of backup save/restore is not supported, as indicated in the Helium Wiki.

Instead to do the backup:

  • Start Helium.
  • Start the PC server.
  • Connect via the PC, select the set of applications and start the backup.
Advices and troubleshooting
  • Exclude MoboPlayer. Backup fails when the app is selected.
  • Exclude GBoard. Huge size for little gains.
  • Exclude Translate. Huge size for little gains.

Privacy

Upgrade the device

Odin

Flashing tool on Windows. Meaning of BL, AP... [2]:

  • BL means Boot Loader.
  • AP means Android Partition. Was PDA before.
  • CP means Core Processor.
  • CSC means Consumer Software Customization. This specifies the features your Android device gets according to its geographical location and carrier.

Upgrade Samsung Alpha

I used Odin on Windows. Probably it was possible to do it on Linux via Heimdall.

  • Download the latest firmware for Samsung Alpha:
  • Install Samsung device drivers.
  • Download and start Odin
  • Extract (unzip) the firmware file
  • Open Odin v3.12.7
  • Reboot Phone in Download Mode (press and hold Home + Power + Volume Down buttons)
  • Connect phone and wait until you get a blue sign in Odin
  • Add the firmware file to AP / PDA
  • Make sure re-partition is NOT ticked
  • Click the start button, sit back and wait few minutes

If we rooted the device, we get a FAILED message in Odin. Now we follow this guide:

  • Follow the same procedure as above, but flash the CF-Auto-Root image for rooting the device (add the file to AP / PDA in Odin).

Root the device

Root Samsung Alpha

The simplest is to use Odin on Windows:

  • Open Odin,
  • Download the CF-Auto-Root files corresponding to the current build.
  • In my case, I have a Samsung Alpha G850F, with firmware G850FXXS2CQD3. Pick the file corresponding to that build number.
  • From downloaded file, extract the file image.tar.md5.
  • Add file image.tar.md5 to AP.
  • Click Start.

On Linux, follow this guide:

  • Download the CF-Auto-Root files corresponding to the current build.
  • In my case, I have a Samsung Alpha G850F, with firmware G850FXXS2CQD3. Pick the file corresponding to that build number.
  • From downloaded file, extract the files cache.img and recovery.img.
  • Install heimdall and heimdall-gui, then run sudo heimdall-frontend.
  • Power off the phone. Press Volume down, Menu and Power button. Press Volume Up to proceed at warning message.
  • Go to Utilities tab, click Detect to make sure device is detected.
  • In the same tab, click Save As then Download to start downloading the PIT. Save the file locally, next to the other .img files.
  • Go to the Flash tab, click Browse, and open the PIT file that was saved previously.
  • Click Add to add a partition file, and select RECOVERY as Partition Name, and select the file recovery.img as the File.
  • Click Add to add a partition file, and select CACHE as Partition Name, and select the file cache.img as the File.
  • Select No Reboot.
  • Click Start. On Success, you should get a message Flashing successful or similar. If not, and instead get a detaching device from interface or such, restart the process, but don't reboot the mobile phone.
  • While pressing Volume Up, unplug the Usb cable, then keep pressing on Volume Up + Power button to force an emergency restart.
  • Wait for device to update.

Unroot Samsung Alpha

References:

First remove _SuperSU_

  • Open SuperSU.
  • In Settings, select Full unroot.

Then reboot phone in Download mode (VolDown + Home + Power):

  • Start Odin on Windows
  • Click on AP, and add the stock firmware (*.tar.md5 file).
  • In Options, select F. Reset Time and Auto Reboot, and _ONLY_ those.
  • Click Start.

In my case, Odin said FAILED. Rebooting the device said we have to connect to Keil in recovery mode. In fact the solution is simple [3]:

  • Unpack the stock firmware archive.
  • Remove/delete the file hidden.img.
  • Repack the file, and give it same name but with .tar extension (so remove .md5).
  • Flash that file as above in Odin (add to _AP_, etc).
  • Flashing will be really fast, and phone will reboot.

Deodex / Xposed

BusyBox

BusyBox is often cited as requirement to Deodex, etc. So let's install it. We need the busy box app and busybox commands.

  • Install BusyBox [4].

Deodexing

That* was a bloody step. All instructions were very messy, hidden in lengthy forums, where authors just keep saying incomplete information. Finally the most helpful ressources:

  • [5] The initial forum about deodexing. But
  • Windows based.
  • Incomplete instructions on how to extract the file.
  • referenced program failed to deodex some files.
  • Obscure instructions for flashing back.
  • More guidance on deodexing 5.0.2
  • Here they explain how to flash files back. But instructions was not correct for my phone.

First extract the files using ADB.

  • Plug phone in USB.
adb pull /system system
adb pull /system/priv-app priv-app
adb pull /system/app app
adb pull /system/framework framework
adb pull /system/bin bin
adb pull /system/build.prop Build.prop

Then Deodex files with svadev tool.

  • Use version 5.5.
  • Requires jre 64-bit 8.
This process will create new folders `app`, `framework` and `priv-app`, and also some folders `dex` and `odex`.
Process failed on file `./priv-app/SamsungLinkPlatform/arm/SamsungLinkPlatform.odex.xz`

Then Copy back `SamsungLinkPlatform.odex.xz` to deodexed system files.

  • Also remove folder `dex` and `odex`.

Then Copy the folders `app`, `framework` and `priv-app` to phone SDCARD root.

adb shell
su
stop
mount -o rw,remount /system/ /system/

cp -r /sdcard/system-deodexed/app/* /system/app/
find /system/app/ -name "*odex*" | xargs rm

cp -r /sdcard/system-deodexed/framework/* /system/framework/
find /system/framework/ -name "*odex*" | xargs rm

cp -r /sdcard/system-deodexed/priv-app/* /system/priv-app/
find /system/framework/ -name "*odex*" | xargs rm

cp /sdcard/system-deodexed/priv-app/SamsungLinkPlatform/arm/SamsungLinkPlatform.odex.xz /system/priv-app/SamsungLinkPlatform/arm/
find /system/priv-app/ -name "*odex*"
mount -o ro,remount /system/ /system/
reboot

Install TWRP

TWRP is a MUST-HAVE application for anyone tinkering with the firmware, to ease recovery in case of failure / soft brick, or to install new customizations (as zip file).

Reference:

We flash via Playstore TWRP App (requirse root):

  • Install TWRP App.
  • Select image (.img), select *Flash to Recovery*.
  • TODO: Should have backed up original recovery first. Do it on Isa's phone, or can we recover one from original ROM?

Without root access, there are two alternatives:

  • On Samsung using Odin. We'll replace the recover partition and boot into it at first boot [7],[8]. Because firmware may replace the recovery partition, we must go into recovery mode at the very first reboot.
  • In Odin, click AP, and add twrp-2.8.x.x-xxx.tar.
  • Click start, and immediate press VolUp + Home + Pwr on the phone.
  • Wait until recovery is started.
  • Flash via ADB and bootloader (does not work on Samsung)
# Rebook in bootloader mode.
# !!! DO NOT WORK ON SAMSUNG - this simply reboots in normal mode - 
adb reboot bootloader

fastboot flash recovery twrp-2.8.x.x-xxx.img
fastboot reboot

Install Xposed

First we need to know which CPU we have:

  • Install google app *CPU Z*
  • --> Exynos (octa core, ARM architecture).

Some forums on installing Xposed:

The post giving specific instruction for the Alpha G850F!
This is custom ZIP files for Samsung. Refer to link below for APK.
  • Download `xposed-v75-sdk21-arm-arter97-exynos_requestConcurrentGC.zip`.
This is generic APK (to install), and generic ZIP files (DO NOT install)
  • Download`XposedInstaller_3.1.5.apk`.
  • Copy XposedInstaller_3.1.5.apk and xposed-v75-sdk21-arm-arter97-exynos_requestConcurrentGC.zip to /sdcard on phone.
  • Install APK.
  • Reboot and launch TWRP (*VolUp-Home-Power* button).
  • ==> Error: *Firmware must be deodexed* !?!
  • ==> We look into .zip file, in META-INF folder we find a script with that error message:
  • It looks for a folder `/system/firmware/arm`. Let's delete it!
  • Looking into folder, we have two files:
boot.art
boot.oat
  • Let's remove all empty arm dir
adb shell
su
stop
mount -o rw,remount /system/ /system/

rm -rf /system/framework/arm
find /system/app -name arm|xargs rmdir
find /system/framework -name arm|xargs rmdir
find /system/priv-app -name arm|xargs rmdir

mount -o ro,remount /system/ /system/
reboot
  • Then go in TWRP recovery, install the zip file, clean dalvik/cache, reboot.
  • Pray.

Install Xposed modules

Open Xposed app, install modules, enable modules...

Backup

System - TWRP

Use TWRP application to install custom recovery partition, and create/restore backups.

 ✐  Note that TWRP backup DOES NOT CONTAIN data storage. So the content of /data/media/0 is NOT SAVED.

Export backups to PC

Using adb:

  • Boot into TWRP recovery.
adb devices                  # Just to verify devices is detected
adb pull /sdcard/TWRP TWRP

To push back the backups:

adb push TWRP /sdcard/TWRP

We can also copy via termux, but it requires root access, and moving file around, which is less convenient.

More complete backup/restore

  • See this page to backup /data/media/0. Too bad, we get an error error: closed from adb when using exec-out.
adb exec-out 'tar --create --exclude=data/media/0/TWRP data/media/0 2>/backup-errors.txt' | \
gzip --best | \
dd of=BACKUP_NAME-$(date +%Y%m%d).tar.gz && \
adb shell cat /backup-errors.txt

So here some stuff we did:

cd /some/path/for/the/backup
adb pull /data/media/0/DCIM
adb shell
cd /data/media/0/DCIM
rm -rf *
cd ..
tar cvf DCIM/backup-alpha-mpe-202007.tar --exclude=DCIM .
adb pull /data/media/0/DCIM/backup-alpha-mpe-202007.tar
# Backup data partition with TWRP
adb pull /data/media/0/TWRP

To restore the backup on a different phone (but same model):

  • Copy the old TWRP backup on the new phone.
  • Make a small backup using TWRP (eg. boot partition).
  • Move the old TWRP backup to the same directory as the new partition. Eg: Move content of TWRP/BACKUPS/410060be455971c1/ to TWRP/BACKUPS/4100598bc8bb9153/.
  • Restore the old backup.

The move is necessary because TWRP uses the phone serial number to locate the backups.

Troubleshooting

Frozen widget

  • Try restarting the launcher. On Samsung, Force stop TouchWiz in the application manager (TouchWiz is apparently Samsung's custom launcher).

Enable developer mode

  • On Samsung, go to SettingsAbout devicetap 7x on Build number. [9]

Get android log

  • Enable USB debugging phone (see developer settings)
  • Connect phone to USB
  • Run
adb logcat

WiFi troubleshooting

Popup : Currently unable to download. Please try again later

Got the message for years when leaving plane mode. Turn out to be an MMS message that I couldn't download [10]. To fix, find the culprit MMS (the one with a Download button), and delete it!

Samsung Email: "Loading messages..." popup when trying to reply to a message

This is a issue due to an update of Android System WebView released on December 5th 2017 [11], [12].

Fix:

  • Go to Application Manager → all → Android System WebView, then select Uninstall update (but might come back at next udpate), or Disable (which might have side-effect on other applications).

Some users reported side-effects of the fix:

  • Instagram pictures not updating.

Alternatives to Samsung Emails:

Fix "Permission denied" in adb shell on root phone

adb shell
# * daemon not running. starting it now on port 5037 *
# * daemon started successfully *
# shell@slte:/ $ 
cd /storage/emulated/legacy/Pictures/Screenshots
# shell@slte:/storage/emulated/legacy/Pictures/Screenshots $ 
ls
# Screenshot_2018-06-19-14-52-49.png
# shell@slte:/storage/emulated/legacy/Pictures/Screenshots $ 
ls -l
# lstat './Screenshot_2018-06-19-14-52-49.png' failed: Permission denied

The problem is that the adb shell does not run as root. For this, simply starts su:

su
# root@slte:/ #

The # prompts indicates we are root.

Note that adb root does not work on production phone.