OSDN Git Service

Force closed at settings application when delete Misc files
authorPredrag Stanojevic <predrag.stanojevic@sonymobile.com>
Tue, 15 May 2012 13:01:02 +0000 (15:01 +0200)
committerHenrik Baard <henrik.baard@sonymobile.com>
Fri, 18 Jan 2013 07:56:19 +0000 (08:56 +0100)
NullPointerException in MiscFilesHandler.java, missing check to
ensure that dir.list() does not return null.

Change-Id: I13aac19949826b385610fd1fee2befb411684023

src/com/android/settings/deviceinfo/MiscFilesHandler.java

index 1e0cc46..93e352b 100644 (file)
@@ -144,8 +144,8 @@ public class MiscFilesHandler extends ListActivity {
         // Returns true if all deletions were successful.
         // If a deletion fails, the method stops attempting to delete and returns false.
         private boolean deleteDir(File dir) {
-            if (dir.isDirectory()) {
-                String[] children = dir.list();
+            String[] children = dir.list();
+            if (children != null) {
                 for (int i=0; i < children.length; i++) {
                     boolean success = deleteDir(new File(dir, children[i]));
                     if (!success) {
@@ -283,4 +283,4 @@ public class MiscFilesHandler extends ListActivity {
             return view;
         }
     }
-}
\ No newline at end of file
+}