Query only necessary columns in ChooserActivity.extractFileInfo().
ChooserActivity started querying the content URI with a null projection
since Q, which means a default projection that includes all columns.
However, ChooserActivity.extractFileInfo() actually only needs the file
name and flags, so querying all columns usually means reading
unnecessary information that may involve disk access, and it's called on
the main thread.
For example, ExternalStorageProvider returns the file size and last
modified time when it sees a null projection, and it is calling
File.length() and File.lastModified() for them. In other file providers,
it is also possible for this to trigger a network request for such
information, which will result in a NetworkOnMainThreadException that
crashes the android:ui process.
So to improve stability and performance, we should provide a projection
that only contains the columns that we are actually interested in.
Bug: 218105374
Test: ChooserActivityTest
Change-Id: I2ab9c6f03e7034a5347bfe3a3d3b2d6ea505059c
1 file changed