Android: Difference between revisions

From miki
Jump to navigation Jump to search
 
(4 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 277: Line 281:


== Backup ==
== 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 ==
== System - TWRP ==
Use TWRP application to install custom recovery partition, and create/restore backups.
Use TWRP application to install custom recovery partition, and create/restore backups.
Line 410: Line 421:


Note that <code>adb root</code> does not work on production phone.
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}-.*")