Android: Difference between revisions

From miki
Jump to navigation Jump to search
 
(20 intermediate revisions by the same user not shown)
Line 6: Line 6:
;On this wiki
;On this wiki
* '''[[Android apps]]'''
* '''[[Android apps]]'''

=== emulator ===
* [https://www.bluestacks.com/ bluestacks] — tried with Clash Royale, works ok it seems.
* [https://www.memuplay.com/ Memu play] — used by Merluchon in the clan family la Presspinpintes to play Clash Royale.


== How-To ==
== How-To ==
Line 20: Line 24:
;Photos
;Photos
* Sync via samba share (using for instance ''ES Explorer'' app).
* Sync via samba share (using for instance ''ES Explorer'' app).

=== Transfer Samsung to Xiaomi ===
Install '''Mi Mover''' application on both phones [https://www.reddit.com/r/Xiaomi/comments/azk0cq/best_way_to_migrate_data_from_samsung_to_xiaomi/].
* On source, select ''I'm a sender''. On target, select ''I'm recipient''.


=== Backup with Helium (ClockWorkMod Carbon) ===
=== Backup with Helium (ClockWorkMod Carbon) ===
Line 64: Line 72:
If we rooted the device, we get a '''FAILED''' message in Odin. Now we follow this [https://forum.xda-developers.com/galaxy-alpha/general/tutorial-flashing-fails-odin-t3216985 guide]:
If we rooted the device, we get a '''FAILED''' message in Odin. Now we follow this [https://forum.xda-developers.com/galaxy-alpha/general/tutorial-flashing-fails-odin-t3216985 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).
* 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).

=== Heimdall ===
<source lang=bash>
heimdall download-pit --output alpha.pit
heimdall print-pit # We see that system partition is called SYSTEM
heimdall flash --pit alpha.pit --SYSTEM system.img --no-reboot
</source>


== Root the device ==
== Root the device ==
Line 72: Line 87:


=== Root Samsung Alpha ===
=== Root Samsung Alpha ===
The simplest is to use Odin on Windows:
From [http://www.all-things-android.com/content/how-root-samsung-mobile-device this guide]:
* Open Odin,
* Download the [https://desktop.firmware.mobi/ 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 {{file|image.tar.md5}}.
* Add file {{file|image.tar.md5}} to AP.
* Click Start.

On Linux, follow [http://www.all-things-android.com/content/how-root-samsung-mobile-device this guide]:
* Download the [https://desktop.firmware.mobi/ CF-Auto-Root] files corresponding to the current build.
* Download the [https://desktop.firmware.mobi/ 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.
:* In my case, I have a Samsung Alpha G850F, with firmware ''G850FXXS2CQD3''. Pick the file corresponding to that build number.
Line 87: Line 110:
* While pressing ''Volume Up'', unplug the Usb cable, then keep pressing on ''Volume Up + Power'' button to force an emergency restart.
* 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.
* Wait for device to update.

; Using Heimdall CLI
<source lang="bash">
heimdall download-pit --output alpha.pit
heimdall print-pit # We see that system partition is called SYSTEM
heimdall flash --pit alpha.pit --RECOVERY recovery.img --CACHE cache.img --no-reboot
</source>

=== Unroot Samsung Alpha ===
References:
* https://itechify.com/2016/08/26/unroot-samsung-galaxy-alpha-g850f/

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 ({{file|*.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 [https://forum.xda-developers.com/galaxy-alpha/general/tutorial-flashing-fails-odin-t3216985]:
* Unpack the stock firmware archive.
* Remove/delete the file {{file|hidden.img}}.
* Repack the file, and give it same name but with {{file|.tar}} extension (so remove {{file|.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 ===
Line 160: Line 213:
* https://www.xda-developers.com/how-to-install-twrp/
* https://www.xda-developers.com/how-to-install-twrp/


We flash via App:
We flash via Playstore '''TWRP App''' (requirse root):
* Install TWRP App.
* Install TWRP App.
:* Select image (.img), select *Flash to Recovery*.
:* Select image (.img), select *Flash to Recovery*.
* {{red|TODO:}} Should have backed up original recovery first. Do it on Isa's phone, or can we recover one from original ROM?
* {{red|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:
Alternative: Command-line instructions to flash
* On Samsung using Odin. We'll replace the recover partition and boot into it at first boot [https://twrp.me/samsung/samsunggalaxyalpha.html],[https://www.theandroidsoul.com/how-to-install-twrp-recovery-using-odin/]. Because firmware may replace the recovery partition, we must go into recovery mode at the very first reboot.
:* In Odin, click '''AP''', and add {{file|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)
<source lang="bash">
<source lang="bash">
# Rebook in bootloader mode.
# !!! DO NOT WORK ON SAMSUNG - this simply reboots in normal mode -
adb reboot bootloader
adb reboot bootloader

fastboot flash recovery twrp-2.8.x.x-xxx.img
fastboot flash recovery twrp-2.8.x.x-xxx.img
fastboot reboot
fastboot reboot
</source>
</source>


== Install Xposed ==
=== Install Xposed ===
First we need to know which CPU we have:
First we need to know which CPU we have:
* Install google app *CPU Z*
* Install google app *CPU Z*
Line 216: Line 277:
* Pray.
* Pray.


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

== Backup ==
=== Signal with SyncThing ===
* In Signal, go to Chat, and enable backup.
* Choose a 2-depth folder, ie {{file|signal/backup}}.
* Write down passphrase, and create a backup.
* Signal should have created a backup file as {{file|signal/backup/*.backup}}.
* Tell SyncThing to backup the parent folder, ie the folder {{file|signal/}}, '''not the folder containing the''' {{file|*.backup}} files, or SyncThing sync files {{file|.stfolder}} will get deleted [https://community.signalusers.org/t/signal-deleting-syncthing-folder-marker-stfolder-in-signal-backup/3311/4], [https://www.reddit.com/r/signal/comments/caoxvs/trying_to_sync_signalbackups_with_syncthing/].

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

{{note| Note that TWRP backup '''{{red|DOES NOT CONTAIN}}''' data storage. So the content of {{file|/data/media/0}} is '''{{red|NOT SAVED}}'''.}}

{{note| '''NEVER USE {{red|FIX PERMISSIONS}}''' ON LOLLIPOP. It will BRICK the device, forcing reflashing the SYSTEM partition.}}

=== Export backups to PC ===
Using [https://www.howtogeek.com/240655/how-to-copy-twrp-android-backups-to-your-pc-for-safe-keeping/ adb]:
* Boot into TWRP recovery.
<source lang="bash">
adb devices # Just to verify devices is detected
adb pull /sdcard/TWRP TWRP
</source>
To push back the backups:
<source lang="bash">
adb push TWRP /sdcard/TWRP
</source>

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

=== More complete backup/restore ===
* See [https://tadej.ja.nez.si/android-internal-storage-backup.html this page] to backup {{file|/data/media/0}}. Too bad, we get an error <code>error: closed</code> from adb when using <code>exec-out</code>.
<source lang="bash">
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
</source>

So here some stuff we did. First pull the whole DCIM (no need to keep permissions):
<source lang="bash">
cd /some/path/for/the/backup
adb pull /data/media/0/DCIM
adb shell
cd /data/media/0/DCIM
rm -rf *
</source>
Then make a tar of the whole storage data, to keep the permissions:
<source lang="bash">
cd ..
tar cvf DCIM/backup-alpha-mpe-202007.tar --exclude=DCIM .
adb pull /data/media/0/DCIM/backup-alpha-mpe-202007.tar
</source>

Then backup the data partition with TWRP, and pull it:
<source lang="bash">
# Backup data partition with TWRP apss
adb pull /data/media/0/TWRP
</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.

Note that we cannot push files > 4GB. If necessary, we must split the TAR file:
<source lang="bash">
# On PC
split -b 1G backup-alpha-mpe-20200726.tar backup.tar.part
adb push backup-alpha-mpe-20200726.tar.part* /data/media/0

# On mobile
cd /data/media/0
cat backup.tar.part* | tar xvf -
</source>

Then restore DCIM:
<source lang="bash">
adb push DCIM /data/media/0
</source>

Finally, in TWRP, wipe the ''cache'' and ''dalvik cache'' partition (alternatively, wipe the phone first before restoring the backup).


== Troubleshooting ==
== Troubleshooting ==
Line 251: Line 396:
* [https://play.google.com/store/apps/details?id=com.fsck.k9&hl=en K-9 Mail].
* [https://play.google.com/store/apps/details?id=com.fsck.k9&hl=en K-9 Mail].
* [https://play.google.com/store/apps/details?id=org.kman.AquaMail&hl=en Aqual Mail - Email app].
* [https://play.google.com/store/apps/details?id=org.kman.AquaMail&hl=en Aqual Mail - Email app].

=== Fix "Permission denied" in adb shell on root phone ===

<source lang="bash">
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
</source>

The problem is that the <code>adb shell</code> does not run as root. For this, simply starts <code>su</code>:
<source lang="bash">
su
# root@slte:/ #
</source>
The <code>#</code> prompts indicates we are root.

Note that <code>adb root</code> does not work on production phone.

== Tips ==
=== Clean up space on Android Pie ===
The principle:
* Storage is consumed by application code, data and cache.
* To recover space, delete the three: first data and cache, then uninstall the application.
* Built-in application cannot be uninstalled but they can be disabled.

For each app:
# Go to settings, applications, select app, go to storage, and select clean data (this should clear both data and cache).
:Note: if application is disabled, you can't clean the data. Enable the application first.
# If possible from there, select uninstall. Otherwise go to Google Play, select application, and select uninstall.
## If application is built-in, disable also application auto-update.
## Back to settings, applications, select app, and disable applications.

=== Restore WhatsApp photo timestamps ===
When photo are restored, they lose their timestamps.

Here a small script to restore them from the filename [https://gist.github.com/oripwk/40fcfe1497b677f86953c2ee811809df]:
<source lang="bash">
# when restoring WhatsApp in a new phone, all the timestamps of media files will be reset to today.
# this script will restore the original modification time of the files

# cd WhatsApp/Media
while read path; do
f=$(basename "$path");
touch -m -d "${f:4:4}-${f:8:2}-${f:10:2}T12:00:00z" "${path}";
done < <(find . -regextype posix-extended -regex ".*/[[:alpha:]]{3}-[[:digit:]]{8}-.*")
</source>

Latest revision as of 20:47, 12 March 2023

Links

On this wiki

emulator

  • bluestacks — tried with Clash Royale, works ok it seems.
  • Memu play — used by Merluchon in the clan family la Presspinpintes to play Clash Royale.

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).

Heimdall

heimdall download-pit --output alpha.pit
heimdall print-pit           # We see that system partition is called SYSTEM
heimdall flash --pit alpha.pit --SYSTEM system.img --no-reboot

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.
Using Heimdall CLI
heimdall download-pit --output alpha.pit
heimdall print-pit           # We see that system partition is called SYSTEM
heimdall flash --pit alpha.pit --RECOVERY recovery.img --CACHE cache.img --no-reboot

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

Signal with SyncThing

  • In Signal, go to Chat, and enable backup.
  • Choose a 2-depth folder, ie signal/backup.
  • Write down passphrase, and create a backup.
  • Signal should have created a backup file as signal/backup/*.backup.
  • Tell SyncThing to backup the parent folder, ie the folder signal/, not the folder containing the *.backup files, or SyncThing sync files .stfolder will get deleted [9], [10].

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.
 ✐  NEVER USE FIX PERMISSIONS ON LOLLIPOP. It will BRICK the device, forcing reflashing the SYSTEM partition.

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. First pull the whole DCIM (no need to keep permissions):

cd /some/path/for/the/backup
adb pull /data/media/0/DCIM
adb shell
cd /data/media/0/DCIM
rm -rf *

Then make a tar of the whole storage data, to keep the permissions:

cd ..
tar cvf DCIM/backup-alpha-mpe-202007.tar --exclude=DCIM .
adb pull /data/media/0/DCIM/backup-alpha-mpe-202007.tar

Then backup the data partition with TWRP, and pull it:

# Backup data partition with TWRP apss
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.

Note that we cannot push files > 4GB. If necessary, we must split the TAR file:

# On PC
split -b 1G backup-alpha-mpe-20200726.tar backup.tar.part
adb push backup-alpha-mpe-20200726.tar.part* /data/media/0

# On mobile
cd /data/media/0
cat backup.tar.part* | tar xvf -

Then restore DCIM:

adb push DCIM /data/media/0

Finally, in TWRP, wipe the cache and dalvik cache partition (alternatively, wipe the phone first before restoring the backup).

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. [11]

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 [12]. 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 [13], [14].

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.

Tips

Clean up space on Android Pie

The principle:

  • Storage is consumed by application code, data and cache.
  • To recover space, delete the three: first data and cache, then uninstall the application.
  • Built-in application cannot be uninstalled but they can be disabled.

For each app:

  1. Go to settings, applications, select app, go to storage, and select clean data (this should clear both data and cache).
Note: if application is disabled, you can't clean the data. Enable the application first.
  1. If possible from there, select uninstall. Otherwise go to Google Play, select application, and select uninstall.
    1. If application is built-in, disable also application auto-update.
    2. Back to settings, applications, select app, and disable applications.

Restore WhatsApp photo timestamps

When photo are restored, they lose their timestamps.

Here a small script to restore them from the filename [15]:

# when restoring WhatsApp in a new phone, all the timestamps of media files will be reset to today.
# this script will restore the original modification time of the files

# cd WhatsApp/Media
while read path; do
  f=$(basename "$path");
  touch -m -d "${f:4:4}-${f:8:2}-${f:10:2}T12:00:00z" "${path}";
done < <(find . -regextype posix-extended -regex ".*/[[:alpha:]]{3}-[[:digit:]]{8}-.*")