Android

SSH for Android

SSH on Android

Step by step

Usage

Configuration ADB/SCRCPY via wireless

Android device v10+ must be paired first to work by wireless.

https://developer.android.com/tools/adb#connect-to-a-device-over-wi-fi-android-11+

Setup public key authentication

Resources

https://github.com/termux
https://wiki.termux.com/wiki/Remote_Access
https://wiki.termux.com/wiki/Main_Page https://joeprevite.com/ssh-termux-from-computer/ https://github.com/dmdhrumilmistry/Termux-SSH

Remote screen

https://github.com/Genymobile/scrcpy

# Drag and drop files in the scrcpy window (default is /sdcard/Download)
scrcpy --tcpip=192.168.66.178 --push-target=/sdcard/Documents/

# Window scaled to local optimized (no audio, etc)
scrcpy --tcpip=192.168.66.178 --no-audio

# Full optimized cmdline
scrcpy --tcpip=androidtv-01 --no-audio --max-size=1024 --push-target=/sdcard/Documents/

Avoid the nagging USB authorization screen

# requires root
- Go to C:\Users<profile_name>.android\adbkey.pub
- Copy the file to any location in your phone using USB cable.
- Using Root Explorer, move the adbkey.pub onto this location: /data/misc/adb/
- rename it from adbkey.pub to adb_keys and allow read and write permissions
- Reboot the device.

Keyboard

Switch fullscreen mode MOD+f
Rotate display left MOD+← (left)
Rotate display right MOD+→ (right)
Resize window to 1:1 (pixel-perfect) MOD+g
Resize window to remove black borders MOD+w | Double-left-click¹
Click on HOME MOD+h | Middle-click
Click on BACK MOD+b | Right-click²
Click on APP_SWITCH MOD+s | 4th-click³
Click on MENU (unlock screen)⁴ MOD+m
Click on VOLUME_UP MOD+↑ (up)
Click on VOLUME_DOWN MOD+↓ (down)
Click on POWER MOD+p
Power on Right-click²
Turn device screen off (keep mirroring) MOD+o
Turn device screen on MOD+Shift+o
Rotate device screen MOD+r
Expand notification panel MOD+n | 5th-click³
Expand settings panel MOD+n+n | Double-5th-click³
Collapse panels MOD+Shift+n
Copy to clipboard⁵ MOD+c
Cut to clipboard⁵ MOD+x
Synchronize clipboards and paste⁵ MOD+v
Inject computer clipboard text MOD+Shift+v
Enable/disable FPS counter (on stdout) MOD+i
Pinch-to-zoom Ctrl+click-and-move
Drag & drop APK file Install APK from computer
Drag & drop non-APK file Push file to device

Copy-paste

Any time the Android clipboard changes, it is automatically synchronized to the computer clipboard.

Any Ctrl shortcut is forwarded to the device. In particular:

Ctrl+c typically copies
Ctrl+x typically cuts
Ctrl+v typically pastes (after computer-to-device clipboard synchronization)

This typically works as you expect.

The actual behavior depends on the active application though. For example, Termux sends SIGINT on Ctrl+c instead, and K-9 Mail composes a new message.

To copy, cut and paste in such cases (but only supported on Android >= 7):

MOD+c injects COPY
MOD+x injects CUT
MOD+v injects PASTE (after computer-to-device clipboard synchronization)

In addition, MOD+Shift+v injects the computer clipboard text as a sequence of key events. This is useful when the component does not accept text pasting (for example in Termux), but it can break non-ASCII content.

WARNING: Pasting the computer clipboard to the device (either via Ctrl+v or MOD+v) copies the content into the Android clipboard. As a consequence, any Android application could read its content. You should avoid pasting sensitive content (like passwords) that way.

Some Android devices do not behave as expected when setting the device clipboard programmatically. An option --legacy-paste is provided to change the behavior of Ctrl+v and MOD+v so that they also inject the computer clipboard text as a sequence of key events (the same way as MOD+Shift+v).

To disable automatic clipboard synchronization, use --no-clipboard-autosync

ROMs

ROMs

Redmi Note 8

Codename: gingko

To find product name : fastboot getvar product 

Telegram groups:

t.me/rn8discussions
t.me/RedmiNote8Official

Forum XDA

https://forum.xda-developers.com/redmi-note-8

TWRP

https://forum.xda-developers.com/redmi-note-8/how-to/guide-unlocking-bootloader-twrp-rooting-t4031831

Unlocking phone

https://forum.xda-developers.com/t/guide-all-about-unlocking-bootloader-twrp-and-rooting-redmi-note-8-8t.4031831/

USB Debugging (with security)

This requires root, shell access with su, and a way to edit text files as root. I used Termux and and android root file manager that can edit text files.

First, run the following command (su first, to switch to root):

setprop persist.security.adbinstall 1

If you also want to enable "USB debugging (Security settings)", for granting permissions, simulating UI input, etc. via ADB, run the following command too:

setprop persist.security.adbinput 1

Next, we need to edit the edit the file

/data/data/com.miui.securitycenter/shared_prefs/remote_provider_preferences.xml

so that MIUI actually lets us do these things:

Add the following line to the XML file (with all the other ones, before the closing tag):

<boolean name="security_adb_install_enable" value="true" />

TWRP

Was in TWRP 3.3.1-9
To install the correct TWRP version, check the "base" of the TWRP indicated after the version number. E.G. :
twrp-3.6.2_9-0-ginkgo.img is a base Android 9-0
twrp-3.5.2_10-2-ginkgo.img is a base Adndroid 10-2
twrp-3.7.0_12-1-ginkgo.img is a base Adndroid 12-1

Some Android versions cannot decrypt your data folder because of incompatibility issues. Simply downgrade to a lower Android base TWRP.

# To check current recovery tool (with phone powered up)
adb reboot recovery

# Boot to recovery
adb reboot bootloader
# Confirm correctly in fastboot
fastboot devices
# Install latest TWRP
cd "/home/wes/Documents/Cellulaires-ROMs/Redmi Note 8"
fastboot flash recovery twrp-3.7.0_12-1-ginkgo.img
# Shutdown phone then "Volume Up + Power" to enter recovery
fastboot reboot

First time installation

You might need to use Lineage OS recovery the first time to initialize a factory reset. Simply follow the instruction here : https://wiki.lineageos.org/devices/ginkgo/install/variant1#installing-a-custom-recovery-using-fastboot
Sideload the custom ROM rather than Lineage.

ArrowOS

No need to follow this, simply install by sideloading + app within OS
Since Redmi Note 8 has no ramdisk, a special guide is required.

Reconfigure some apps

Some apps require to re-login after restoration :

Some interesting modules

https://github.com/Magisk-Modules-Repo/ssh

Lineage OS

https://wiki.lineageos.org/devices/ginkgo/variant1/

Boot to Fastboot/bootloader

adb reboot bootloader 

Flash vbmeta file (to disable boot security feature)

fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img 

Flash and boot to recovery TWRP

fastboot flash recovery twrp-3.3.1-9-ginkgo-mauronofrio.img 
fastboot boot twrp-3.3.1-9-ginkgo-mauronofrio.img 

Format Data

TWRP > Wipe > Format Data (not in advanced mode) - No reboot to system 

Reboot in recovery

TWRP > Reboot > Recovery 

Wipe again

TWRP > Wipe > Advanced > Cache, data, dalvik, system 

Flash Disable_DM-Verity_ForceEncrypt

https://forum.xda-developers.com/android/software/universal-dm-verity-forceencrypt-t3817389/ 

Flash ROM

Flash Magisk

Reboot to ROM

Reboot to recovery

Generate and Install Smali Patcher module in Magisk

Flash nanodroid setup (to configure nanodroid) - doesn't works.

Flash nanodroid

Source:
https://forum.xda-developers.com/showpost.php?p=81403899&postcount=37

Install smali patcher for signature spoofing

https://forum.xda-developers.com/apps/magisk/module-smali-patcher-0-7-t3680053

Baseband

Version

Firmware Baseband (BAR_GEN_PACK)
V11.0.8.0.PCOMIXM 1.252721.1.260983.1
V11.0.7.0.PCOMIXM 1.246073.2.252721.1
20.1.16 (China) 1.241207.1.242935.1
V11.0.6.0.PCOMIXM 1.239860.1.241207.1
V11.0.3.0.PCOMIXM 1.223797.1.225109.3
ROMs

Sauvegarde des cellulaires

Sauvegarde cellulaires

https://sebsauvage.net/wiki/doku.php?id=backup-telephone
https://alexandre.deverteuil.net/post/synchronizing-files-across-phone-laptop-nas-with-nextcloud-and-syncthing/

Rapport

Valider le contenu du stockage:

# Vue globale du stockage
df -h
cd /data/
du -m | awk '$1 >= 100' | sort -g # List directories above 100 MB
du -am -d1 | awk '$1 >= 100' | sort -g # List all above 100 MB at depth level 1
du -am -d2 | awk '$1 >= 100' | sort -g # List all above 100 MB at depth level 2

Étapes

# Pré-requis - récup du cell id
adb devices -l
  1. Backup des apps avec neobackups

  2. Backup Signal
    Settings/Chats/Chats backup/Create backup
    (passphrase in keepass)

    adb -s <cellulaire id> pull -a /sdcard/Documents/Backup_signal ~/Documents/sauvegarde
    
  3. Backup Markor

    adb -s <cellulaire id> pull -a /sdcard/Documents/markor ~/Documents/sauvegarde
    
  4. Sauvegarde des settings

    mkdir /sdcard/Documents/backup_settings
    su - # passe en root
    cp /data/system/users/0/* /sdcard/Documents/backup_settings/
    
  5. Copie local de la sauvegarde

    adb -s <cellulaire id> pull -a /sdcard/backup_neobackup ~/Documents/sauvegarde
    
  6. Copie de la sauvegarde vers le nouveau cell

    adb -s <cellulaire id> push ~/Documents/sauvegarde/backup_neobackup /sdcard/
    
  7. Installation des apps minimums

    adb -s <cellulaire id> install ~/Documents/Cellulaires-ROMs/magisk-v28.apk
    adb -s <cellulaire id> install ~/Documents/Cellulaires-ROMs/droid-ify-v0.6.3.apk
    adb -s <cellulaire id> install ~/Documents/Cellulaires-ROMs/auroraStore-4.6.2.apk
    adb -s <cellulaire id> install ~/Documents/Cellulaires-ROMs/neo_Backup_838_release.apk
    
  8. Restauration des apps via Neobackup

  9. Configuration des connexions pour les apps

    • Signal
    • Viber
    • Whatsapp
    • Facebook (Messenger)
    • Desjardins
    • Wise
    • Picard
    • Proton Mail
    • Proton VPN
    • Tuta
    • Manuvie
    • ...etc...

Configuration EasySSHFS

wes
192.168.66.103
remote path : ~/Documents/sauvegarde
(create folder in Android home named "sauvegarde")

Ressources

https://github.com/newhinton/Round-Sync
Outil pour sync 1-direction basé sur rclone

ROMs

ADB Configuration script

ADB Config

Check logs using logcat

$ pm list packages | grep -i seed
package:com.stevesoltys.seedvault
$ logcat -e seedvault
# or use a simple grep
logcat | grep 'vault'
# This is specific to SeedVault (https://github.com/seedvault-app/seedvault/blob/android15/logcat-verbose.sh)
set -ex

adb shell setprop log.tag.BackupManagerService VERBOSE
adb shell setprop log.tag.BackupManagerConstants VERBOSE
adb shell setprop log.tag.BackupTransportManager VERBOSE
adb shell setprop log.tag.KeyValueBackupJob VERBOSE
adb shell setprop log.tag.KeyValueBackupTask VERBOSE
adb shell setprop log.tag.TransportClient VERBOSE
adb shell setprop log.tag.BackupAgent VERBOSE
adb shell setprop log.tag.PMBA VERBOSE

Navigate through the slots

To flash permanently, first switch/select any slot you want or it will automatically flashed to the active slot.

# Check current active slot
adb shell getprop ro.boot.slot_suffix
fastboot getvar current-slot

# Switching slots
fastboot set_active other  //switch to inactive slot
fastboot set_active (a or b)  //switch to specified slot

Check current slot and baseband version

adb shell getprop | grep -Ei '(gsm.*baseband|slot_suffix)'

Have both slots (A/B) with same verity/verification configuration

fastboot flash vbmeta --disable-verity --disable-verification --slot=all vbmeta.img

Secure phone (to review)

#!/bin/bash
adb root
adb remount
adb pull /system/build.prop .
sed -i "s/ro.secure=0/ro.secure=1/" build.prop
sed -i "s/ro.debuggable=1/ro.debuggable=0/" build.prop
adb push build.prop /system/build.prop
rm build.prop
ROMs

Play Integrity/SafetyNet

Play Integrity

USB Debugging authorization

Copy public key

HK1 RBOX X4

HK1RBOX-X4

Amlogic S905X4

Specifications (adb shell getprop)

ro.product.build.fingerprint]: [Amlogic/ah212/ah212:11/RQ3A.210805.001.A1/user12212324:user/release-keys]
[ro.product.build.id]: [RQ3A.210805.001.A1]

GPU (adb shell dumpsys SurfaceFlinger | grep GLES ) :

GLES: ARM, Mali-G31, OpenGL ES 3.2 v1.r25p1-01bet0-6a4488b89-0567174f3.3ce44ab07ffe09dde7ee2f5999c7dd83

Backup original ROM

https://slimboxtv.ru/obnovlenie-proshivki-s-soxraneniem-dannyx-v-usb-burning-tool/

Custom ROM

https://slimboxtv.ru/transpeed-x4-x4s/

Procedure:

Configuration

Troubleshooting

Infos

https://androidpctv.com/firmware-hk1-rbox-vontar-x4-transpeed-x4-rom/

Resources

https://en.aptoide.com/

https://apkpure.com/

https://modyolo.com/ott-navigator-iptv.html

Advanced Charging Controller (ACC)

Link

https://github.com/VR-25/acc
https://xdaforums.com/t/advanced-charging-controller-acc.3668427/

Config

Configure day and night profiles (aka "Smart Charging")

#= Profile without charge cooldown
# Profil Jour
acc -c a ": day profile; at 6:00 \"acc -s rc=75 pc=80 mcc=750 mcv=4100; acc -n 'Switched to day profile'\""
# Profil Nuit
acc -c a ": night profile; at 21:00 \"acc -s rc=45 pc=50 mcc=500 mcv=3900; acc -n 'Switched to night profile'\""

#= Profile with charge cooldown
# Profil Jour
acc -c a ": day profile; at 6:00 \"acc -s rc=75 pc=80 mcc=750 mcv=4100 cch=50 cp=5; acc -n 'Switched to day profile'\""
# Profil Nuit
acc -c a ": night profile; at 21:00 \"acc -s rc=45 pc=50 mcc=500 mcv=3900 cch=50 cp=5; acc -n 'Switched to night profile'\""

Informations importantes

Ever wondered why lithium ion batteries aren't sold fully charged? They're usually ~40-60% charged. Why is that? Keeping a battery fully drained, almost fully drained or 70%+ charged for a long times, leads to significant (permanent) capacity loss

The maximum voltage actually defines the percentage of battery, 4200 mV ~95%, 4100 mV ~80%

Always Limit the Charging Current If Your Battery is Old and/or Tends to Discharge Too Fast

This extends the battery's lifespan and may even reduce its discharge rate.

If your device does not support custom current limits, use a dedicated ("slow") power adapter.

Exemples

ADB Commands

Basic ADB Commands

# List connected devices
adb devices -l

# Run shell
adb shell
## Run "su" to elevate to root within the box