How to adjust the threshold for the "storage low" event? There's almost no Android user (and certainly no regular visitor of our site) who hasn't heard of the "insufficient storage" error – or even experienced it him/herself. That there must be at least 10% of storage free on /data sounds ridiculous at least when the total space on that partition goes at or beyond 8 GB. Thus we quite frequently have questions on this topic here.

On one of the latest I've done some investigation of the relevant code, and discussed that in my answer. Let me quote the relevant code-block (taken from the latest code) here again:

 * This class implements a service to monitor the amount of disk
 * storage space on the device.  If the free storage on device is less
 * than a tunable threshold value (a secure settings parameter;
 * default 10%) a low memory notification is displayed to alert the
 * user. If the user clicks on the low memory notification the
 * Application Manager application gets launched to let the user free
 * storage space.


Now please focus on lines 2+3:


  If the free storage on device is less than a tunable threshold value (a secure settings parameter; default 10%)


(emphasis mine). So here comes my question:



TL;DR: If that threshold is tunable, how to tune it?



Is it something in settings we overlooked all those years? Is this supposed to be "tuned" by the "ROM bakers" only? Or, taking the hint of a "secure settings parameter", is there some app utilizing the WRITE_SECURE_SETTINGS permission to take care of that? By which means are we supposed to address this (if at all)?
Low storage threshold is the minimum value of the two:


sys_storage_threshold_percentage (default is 5%, was 10% on Android 7 and older). It's multiplied with the total storage size to get threshold value in bytes. This setting is there since the early days of Android.
sys_storage_threshold_max_bytes (default is 500 MiB). This setting was added in Android 4.


In JellyBean both settings were moved from secure namespace to global. And the logic to calculate low threshold was moved from DeviceStorageMonitorService to StorageManager.

If the 5% of total space on /data is greater than 500 MiB, the threshold is always 500 MiB. In order to set the threshold to even smaller value, e.g. to 100 MB:

~$ settings put global sys_storage_threshold_max_bytes 100000000