```bash
APP_ID=org.thoughtcrime.securesms

# On source device:

adb -e shell am force-stop $APP_ID
adb -e pull -a /data/data/$APP_ID/

# On target device:

adb -e shell am force-stop $APP_ID
APP_OWNERSHIP=$(adb -e shell stat --format %U:%G /data/data/$APP_ID/)
echo "APP_OWNERSHIP: $APP_OWNERSHIP|"

adb -e shell rm -R /data/data/$APP_ID/
tar cz $APP_ID/ | pv -s $(du -sh $APP_ID/ | cut -d $'\t' -f 1 | cut -d ',' -f 1) | adb -e shell tar xz -C /data/data/
adb -e shell chown -R $APP_OWNERSHIP /data/data/$APP_ID/
adb -e shell chcon -R u:object_r:app_data_file:s0 /data/data/$APP_ID/
adb -e shell monkey -p $APP_ID 1
```

does not restore Signal app state contrarily to others apps on LineageOS 23.2 `adb root`, why?
Apr 26, 7:19pm

Your script is a standard approach for migrating Android app data between devices using adb, but Signal (org.thoughtcrime.securesms) is a special case due to its security model. Here’s why your method fails for Signal, and what you can do instead:


Why Signal’s Data Doesn’t Restore This Way

1. Signal’s Encrypted Database

Signal stores its messages and media in an encrypted SQLite database (signal-db). The encryption key is tied to the device’s hardware-backed keystore (Android’s KeyStore system). When you copy the /data/data/org.thoughtcrime.securesms/ directory, the encrypted database is copied, but the encryption key is not. Without the key, Signal cannot decrypt the database on the new device.

2. Android’s App-Specific Keys

  • Signal uses Android’s KeyStore to generate and store encryption keys.
  • These keys are device-bound and cannot be exported or transferred via adb.
  • Even with adb root, you cannot access or transfer these keys.

3. SELinux Context

Your script sets the SELinux context (chcon -R u:object_r:app_data_file:s0), but Signal may require additional or different contexts for its files, especially for encrypted data.

4. App-Specific Restrictions

Signal may detect that it’s running on a new device (via hardware IDs, keystore, or other checks) and refuse to use the copied data for security reasons.


How to Properly Transfer Signal Data

Official Method: Signal’s Built-in Transfer

Signal supports end-to-end encrypted backups and device transfer features:

  1. On the source device:
    • Open Signal → Settings → Chats and Media → Chat Backup → Enable backups (encrypted with a 30-digit passphrase).
    • Or use Signal’s device transfer feature (Settings → Advanced → Transfer Account to Another Device).
  2. On the target device:
    • Install Signal and use the same phone number.
    • During setup, choose "Transfer from another device" and scan the QR code from the source device.

Alternative: Manual Transfer (Advanced)

If you must use adb, you need to preserve the keystore:

  1. Root both devices (LineageOS adb root is not enough; you need full root access).

  2. Dump the keystore keys from the source device:

    bash
    adb -e shell su -c "cat /data/misc/keystore/user_0/<key_files> > /sdcard/keystore_dump"
    • This is highly device-specific and may not work on all ROMs.
  3. Copy the keystore to the target device and restore permissions.

  4. Copy Signal’s data as you did, then reboot.

    ⚠️ Warning:

    • This is not officially supported and may break Signal or your device.
    • Signal explicitly discourages this method for security reasons.

Why Other Apps Work

Most apps do not use hardware-backed encryption for their data. Their databases are either:

  • Unencrypted, or
  • Encrypted with keys stored in /data/data/<app>/ (which your script copies).

Signal is an exception due to its focus on security.


Key Takeaway

  • Signal’s data is tied to the device’s keystore. Copying the app data alone is insufficient.
  • Use Signal’s built-in transfer or backup features for a reliable, secure migration.
  • Manual adb methods are not recommended and may fail due to encryption and security checks.

Question: Are you trying to transfer Signal to a new device, or are you experimenting with backups? If it’s a transfer, the built-in feature is the safest path.

Apr 26, 7:19pm

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.

Le Chat can make mistakes. Check answers. Learn more