Don't read more than 4096 chars in FileUtils#readString

FileUtils#readString() is used to read directory path from .nomedia
file. As most of the filesystems have upper limit of 4096 chars for path
of the file, it's safe to read only 4096 bytes from the file. Adding
upper limit for readString will help in avoiding OutOfMemoryError while
reading a large renamed .nomedia file.

FileUtils#readString() is used for reading the directory path from
.nomedia file to decide if it was already scanned before.
When .nomedia file size is greater than 4096 bytes, we will not read
directory path from the .nomedia file. Instead, we will treat this file
as empty .nomedia file, and continue scanning the parent directory as
hidden directory.

Bug: 174333283
Test: atest
com.android.providers.media.util.FileUtilsTest#testString

Change-Id: Iebcb8ee0be65867dd98f3edffe3c0a0effdc9c4c
Merged-In: Iebcb8ee0be65867dd98f3edffe3c0a0effdc9c4c
(cherry picked from commit e64f5bbb85ed413e111061e8e80722989bafed4e)
2 files changed