The web is replete with advice to encrypt Android phones before resetting the phone for recycling. Using my old-school computer understanding (which may be out of date), the reason is that "normal" deletion simply marks file space as free for future use without overwriting the contents.
I am using CyanogenMod 12 with a 1st generation Moto G, so most of the online info isn't applicable. Since I am not a developer (either for Android of any other environment), I have to find the least technically involved method possible to encrypt and reset. For encryption, I found Lekensteyn's answer to be helpful. For some reason, however, my adb shell does not support pipelines, so my slight modification is, verbatim (except for the password and resulting Hex for the ASCII):
root@falcon_umts:/ # head -1 | tr -d '\n' | hexdump -ve '1/1 "%.2x"'
head -1 | tr -d '\n' | hexdump -ve '1/1 "%.2x"'
FF00FF00FFroot@falcon_umts:/ # vdc cryptfs enablecrypto wipe password 6d6f746f47
vdc cryptfs enablecrypto wipe password 6d6f746f47
200 0 -1
This process took a split second, so I'm not sure if it worked. From the background I've found online, encryption should take a good portion of an hour. Is there any way to check whether the phone is encrypted? I can still use the adb shell commands "ls" and "find" on the /data directory, though I'm not sure if that is the right path for me to worry about. I'm only interested in making the user-specific data inaccessible, i.e., Contacts, Calendar, personally created folders in File Manager, logins for GMail (IMAP) and Exchange Server. I have no apps or media files that I need to protect, nor do I have any cloud accounts apart from email accounts above (though I did use the Google store to download a PDF reader once).
Just from playing around (without necessarily a full appreciation), the "mount" command returns a whole whack of entries, while "ls mnt" only returns a handful.
Based on this site, the next step after ensuring encryption is to use Factory Reset. However, TWRP also has a Wipe function, with options to "Advance Wipe" and "Format Data". "Advance Wipe" has checkboxes for "Dalvik Cache", "Data", "Internal Storage", "Cache", "System", "USB OTG", which don't all have similarly named folders under the path "/" (so I'm not sure if they map to the file hierarchy). "Format Data" is described as wiping, so I'm not clear on whether this does the requisite overwriting of physical bits in the nonvolatile memory. For that matter, the above Stack Exchange solution isn't clear about this either, and I am assuming that the overwriting with indecipherable data is thing being sought in the encryption.
In summary, the questions about safely erasing the phone are:
- Is the encryption meant to do the required overwriting?
- Does the above Stack Exchange solution accomplish this? 2a. Since it happened so fast, how can I confirm its success?
- Is the /data folder tree that I should be focused on?
- Is the Settings->Factory Reset sufficent after #2?
- Does the default TWRP wipe accomplish this, along with erasure?
- Is the "Advance Wipe" or "Format Data" feature needed?
I am assuming that #4 is not required after #5 and/or #6.
P.S. I'm operating under the following constraints: I don't want to use Nuke My Phone because I no longer want to connect it to the internet, and I don't want to install any apps. I might try
dd if=/dev/urandom of=random.txt bs=1G count=2 if I can't sort about my issue above, but the last thing I want to end up with is a crippled system that is only half cleansed. I will also look into how to extract the data critical parts for destruction, as I'm not interested in selling the phone. I'm avoiding upgrades to CM because it needs a TWRP upgrade, which requires a bootloader upgrade, which I'm reluctant to do ever since Motorola's handset division got sold overseas. Note that this page misses many of the points of interest, as it doesn't clarify whether "wiping" does the requisite overwriting, nor the odd encryption behaviour that I encounter.
2017-11-05 UPDATE: I have been unable to get the original ROM to install in order to enable encryption of the solid state drive. Based on the prospects of wear levelling, I have doubts about the effectiveness anyway. At this point, my only certain solution is to disassemble the device as much possible, separate away the components that are obviously not electronic, then physically pulverize the rest with a hammer (and with the components in a milk bag to keep them from scattering).