OSDN Git Service

Don't crash when external storage is unmounted
authorChristopher Tate <ctate@google.com>
Thu, 13 Jul 2017 22:18:38 +0000 (15:18 -0700)
committerChristopher Tate <ctate@google.com>
Fri, 14 Jul 2017 23:00:36 +0000 (16:00 -0700)
commit11179b40c6c2bed0a88fded3c0d89e56f2cce1cb
treefe465ee08588aba4610abe009ad23b7103d458ad
parent183f9ac26302e1f677df8d698c1f7c570bb22014
Don't crash when external storage is unmounted

In particular, don't NPE if an app calls getExternalFilesDir() while
external storage is unmounted.  We were making assumptions about the
length of the array returned by the "tell me about all the external
locations" method, but in unmounted cases that array can be zero-sized.

(And similar for getObbDir() and getExternalCacheDir().)

Bug: 63604311
Test: manual
Change-Id: I4dec828161245047182e6fd39a0df10dd1681ba2
core/java/android/app/ContextImpl.java