Consider top level nomedia while checking the directory dirty

Previously, we checked directory dirty state for current directory. This
would skip scanning the subdirectory because dirty state is set for top
level nomedia directory. Nomedia file in subdirectory is never marked as
dirty.
Hence, scanning the top level nomedia directory or directly scanning the
subdirectory will always skip all subdirectories of nomedia directory.
Apps that bypass database operations were not be able to clean stale
database rows by scanning the directory because we always skip scanning
the dirty subdirectory.

This CL fixes the issue by checking the top level nomedia directory for
dirty status. We also track the directory dirty status for
subdirectories in mIsDirectoryDirty. This removes additional dirty state
check for subdirectories of nomedia directories.

Bug: 175117940
Test: atest
android.scopedstorage.cts.host.ScopedStorageHostTest#testScanDoesntSkipDirtySubtree

Change-Id: Ifc68116754a0a8860cadd1af3fad645f6c8beb51
(cherry picked from commit bbcc98bdf614993836a16400bc4c4a1bf2427355)
1 file changed