Can we trigger the TRIM command on Android?
Android 4.3 uses the TRIM command to erase blocks of flash that are unused by the filesystem. This could improve our chances of securely deleting data on Android.
MountService issues the TRIM command once every 24 hours if the device is idle and charged, as determined by
Investigate whether we can broadcast any of the intents issued by
IdleMaintenanceService to cause a TRIM on demand, e.g. in a panic button situation after deleting the database.
We can broadcast an intent with the action
"com.android.server.IdleMaintenanceService.action.FORCE_IDLE_MAINTENANCE", but it's not clear whether that has any effect - nothing shows up in the logs on a Galaxy Nexus with Android 4.3 when the intent is broadcast.
IdleMaintenanceService decides (due to receiving the above intent or otherwise) that it's time to run idle maintenance tasks, it broadcasts an intent with the action
"android.intent.action.ACTION_IDLE_MAINTENANCE_START". According to the
Intent javadoc, that intent "can only be sent by the system":
Alternatively, we might be able to invoke
android.app.ActivityManagerNative.getDefault().performIdleMaintenance() via reflection. The method in question was added in September 2013:
It's included in the
kitkat-release branch but not the
jb-release branch, so we'd need a phone with 4.4 to test this.