Skip to content

Instantly share code, notes, and snippets.

@deobald
Last active November 22, 2019 15:05
Show Gist options
  • Save deobald/d807a12d35ed6d1286cde7cebd41580d to your computer and use it in GitHub Desktop.
Save deobald/d807a12d35ed6d1286cde7cebd41580d to your computer and use it in GitHub Desktop.
How to get a full (all-time) summary of hours meditated from the Dhamma.org app

One-time Setup

  1. get the 'adb' binary: install android debug tools

  2. Settings -> About -> Tap Build Number 7 times to enable Developer options

  3. install a version of OpenSSL with zlib support so you can open the android backup

cd ~
curl https://www.openssl.org/source/openssl-1.1.1d.tar.gz -o openssl-1.1.1d.tar.gz
tar -zxvf openssl-1.1.1d.tar.gz
cd openssl-1.1.1d
./config zlib
make
sudo make install
which openssl
# => /usr/bin/openssl (this is not the OpenSSL you just installed)
ls /usr/local/bin/openssl # should return a binary that has zlib support

Procedure to Count All-Time Hours

  1. plug your phone into your computer

  2. Settings -> Developer -> USB Debugging: On

  3. Backup the Dhamma.org app data

adb backup -f ~/org-dhamma-backup -noapk org.dhamma

...unlock your phone, do not enter a password for the backup, click "do the backup"

  1. Turn the backup into a .tar file
dd if=org-dhamma-backup bs=24 skip=1|/usr/local/bin/openssl zlib -d > org-dhamma-backup.tar
  1. Get the logbook from the .tar file
tar -tvf org-dhamma-backup.tar | grep apps/org.dhamma/db/dhamma.org # might return errors; that's ok
tar -xf org-dhamma-backup.tar apps/org.dhamma/db/dhamma.org  # still returns errors, but it works
  1. Run this query against the 'db/dhamma.org' file you just extracted, using any SQLite client:
select count(FILE_DURATION) from LOGBOOK_DATA where FILE_DURATION like '1 hr %';
  1. TADA! You now know the total number of hours you've meditated!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment