Skip to content

Instantly share code, notes, and snippets.

@typebrook
Last active June 2, 2022 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save typebrook/72ece30d197dfac00f5065fa40d86d3b to your computer and use it in GitHub Desktop.
Save typebrook/72ece30d197dfac00f5065fa40d86d3b to your computer and use it in GitHub Desktop.
1922 SMS message statistics
# Backup telephony data as telephony.ab
adb backup -apk com.android.providers.telephony -f telephony.ab &>/dev/null

# Extract .ab file with tail, pigz and tar
# Notice we need to ignore the first 24 bytes and then fo decoding
tail -c +25 telephony.ab | pigz -d | tar -xf -

# Get JSON data with files: XXXXXXsms_backup
for sms in **/*sms_backup; do 
    pigz -d <$sms; 
done | jq -c '.[]|select(.address=="1922")' >1922.sms

# Count how many SMS messages with address = 1922
wc -l 1922.sms

# Get the first and the last time of SMS messages
jq -r .date 1922.sms | sort | sed -n 's/...$//;1p;$p' | xargs -I{} date -d @{}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment