copy app between android phones without intermediate storage
Goal
copy Signal from an old phone to a new phone without storing the content.
Prerequisites
- ADB with root on both phones
- attached to a linux via USB on both phones
- Signal installed on new phone but not started (or data wiped)
Steps
- List devices
olly@lnx:~$ adb devices List of devices attached oldDevice device (source) newDevice device (target)
- Enable root shell
olly@lnx:~$ adb -s oldDevice root olly@lnx:~$ adb -s newDevice root
- Show old permission
olly@lnx:~$ adb -s oldDevice shell ls -alZ /data/data/org.thoughtcrime.securesms/ total 160 drwxrwx--x 12 u0_a88 u0_a88 u:object_r:app_data_file:s0:c512,c768 4096 2018-01-01 00:00 . drwxrwx--x 161 system system u:object_r:system_data_file:s0 1337 2018-01-01 00:00 .. drwxrwx--x 2 u0_a88 u0_a88 u:object_r:app_data_file:s0:c512,c768 4096 2018-01-01 00:00 app_captures drwxrwx--x 2 u0_a88 u0_a88 u:object_r:app_data_file:s0:c512,c768 4096 2018-01-01 00:00 app_download_internal drwxrwx--x 2 u0_a88 u0_a88 u:object_r:app_data_file:s0:c512,c768 1337 2018-01-01 00:00 app_parts drwxrwx--x 2 u0_a88 u0_a88 u:object_r:app_data_file:s0:c512,c768 4096 2018-01-01 00:00 app_textures drwxrwx--x 2 u0_a88 u0_a88 u:object_r:app_data_file:s0:c512,c768 4096 2018-01-01 00:00 app_webview drwxrwx--x 4 u0_a88 u0_a88 u:object_r:app_data_file:s0:c512,c768 4096 2018-01-01 00:00 cache drwxrwx--x 2 u0_a88 u0_a88 u:object_r:app_data_file:s0:c512,c768 4096 2018-01-01 00:00 code_cache drwxrwx--x 2 u0_a88 u0_a88 u:object_r:app_data_file:s0:c512,c768 4096 2018-01-01 00:00 databases drwxrwx--x 6 u0_a88 u0_a88 u:object_r:app_data_file:s0:c512,c768 4096 2018-01-01 00:00 files lrwxrwxrwx 1 root root ? 46 2018-01-01 00:00 lib -> /data/app/org.thoughtcrime.securesms-2/lib/arm drwxrwx--x 2 u0_a88 u0_a88 u:object_r:app_data_file:s0:c512,c768 4096 2018-01-01 00:00 shared_prefs
- Show new permission
olly@lnx:~$ adb -s newDevice shell ls -alZ /data/data/org.thoughtcrime.securesms/ total 16 drwx------ 2 u0_a82 u0_a82 u:object_r:app_data_file:s0:c512,c768 4096 2018-01-01 00:00 . drwxrwx--x 154 system system u:object_r:system_data_file:s0 1337 2018-01-01 00:00 .. lrwxrwxrwx 1 root root u:object_r:app_data_file:s0 46 2018-01-01 00:00 lib -> /data/app/org.thoughtcrime.securesms-1/lib/arm
- Copy data
olly@lnx:~$ adb -s oldDevice shell cd /data/data/org.thoughtcrime.securesms/ \&\& find . -maxdepth 1 -mindepth 1 -not -type l \| tar cpf - --files-from - | adb -s newDevice shell tar xpf - -C /data/data/org.thoughtcrime.securesms
- Copy key material
olly@lnx:~$ adb -s oldDevice shell tar cpf - /data/misc/keystore/user_0/.10088_chr_USRSKEY_SignalSecret | adb -s newDevice shell tar xpf - -C /data/misc/keystore/user_0/.10082_chr_USRSKEY_SignalSecret olly@lnx:~$ adb -s oldDevice shell tar cpf - /data/misc/keystore/user_0/10088_USRSKEY_SignalSecret | adb -s newDevice shell tar xpf - -C /data/misc/keystore/user_0/10082_USRSKEY_SignalSecret
- Adapt permissions
olly@lnx:~$ adb -s newDevice shell cd /data/data/org.thoughtcrime.securesms/ \&\& find . -maxdepth 1 -mindepth 1 -not -type l -exec chown u0_a82:u0_a82 {} -R \; olly@lnx:~$ adb -s newDevice shell chown u0_a82:u0_a82_cache /data/data/org.thoughtcrime.securesms/cache -R olly@lnx:~$ adb -s newDevice shell chown keystore:keystore /data/misc/keystore/user_0/.10082_chr_USRSKEY_SignalSecret olly@lnx:~$ adb -s newDevice shell chown keystore:keystore /data/misc/keystore/user_0/10082_USRSKEY_SignalSecret
- Adapt SELinux
olly@lnx:~$ adb -s newDevice shell cd /data/data/org.thoughtcrime.securesms/ \&\& find . -maxdepth 1 -mindepth 1 -not -type l -exec chcon u:object_r:app_data_file:s0:c512,c768 {} -R \;