Fix File.isHidden and File.listRoots.

Not only were the old implementations of these methods over-complicated, they
were both incorrect. We now pass all our existing tests plus the jtreg tests.

Bug: 2281992
diff --git a/libcore/luni/src/main/java/java/io/File.java b/libcore/luni/src/main/java/java/io/File.java
index 7977750..c74d96e 100644
--- a/libcore/luni/src/main/java/java/io/File.java
+++ b/libcore/luni/src/main/java/java/io/File.java
@@ -232,9 +232,10 @@
         }
     }
 
-    private static native byte[][] rootsImpl();
-
-    private static native boolean isCaseSensitiveImpl();
+    // BEGIN android-removed
+    // private static native byte[][] rootsImpl();
+    // private static native boolean isCaseSensitiveImpl();
+    // END android-removed
 
     /**
      * Lists the file system roots. The Java platform may support zero or more
@@ -245,15 +246,7 @@
      * @return the array of file system roots.
      */
     public static File[] listRoots() {
-        byte[][] rootsList = rootsImpl();
-        if (rootsList == null) {
-            return new File[0];
-        }
-        File result[] = new File[rootsList.length];
-        for (int i = 0; i < rootsList.length; i++) {
-            result[i] = new File(Util.toString(rootsList[i]));
-        }
-        return result;
+        return new File[] { new File("/") };
     }
 
     /**
@@ -850,10 +843,12 @@
         if (security != null) {
             security.checkRead(path);
         }
-        return isHiddenImpl(properPath(true));
+        return getName().startsWith(".");
     }
 
-    private native boolean isHiddenImpl(byte[] filePath);
+    // BEGIN android-removed
+    // private native boolean isHiddenImpl(byte[] filePath);
+    // END android-removed
 
     // BEGIN android-changed
     private native boolean isReadableImpl(byte[] filePath);
diff --git a/libcore/luni/src/main/native/java_io_File.cpp b/libcore/luni/src/main/native/java_io_File.cpp
index bca745f..f3e8ea6 100644
--- a/libcore/luni/src/main/native/java_io_File.cpp
+++ b/libcore/luni/src/main/native/java_io_File.cpp
@@ -38,36 +38,6 @@
     STAT_TYPE_FILE = 0x0004
 };
 
-/*
- * private static native byte[][] rootsImpl()
- *
- * Returns the linux root in an array of byte arrays
- */
-// TODO: why don't we just do this in Java?
-static jobject java_io_File_rootsImpl(JNIEnv* env, jclass clazz) {
-    // TODO: why two NUL bytes?
-    jbyte rootStrings[3];
-    rootStrings[0] = '/';
-    rootStrings[1] = '\0';
-    rootStrings[2] = '\0';
-
-    jbyteArray rootName = env->NewByteArray(3);
-    env->SetByteArrayRegion(rootName, 0, sizeof(rootStrings), rootStrings);
-
-    jclass arrayClass = env->FindClass("[B");
-    if (arrayClass == NULL) {
-        return NULL;
-    }
-
-    jobjectArray result = env->NewObjectArray(1, arrayClass, NULL);
-    if (result == NULL) {
-        return NULL;
-    }
-    env->SetObjectArrayElement(result, 0, rootName);
-    return result;
-}
-
-
 class Path {
 public:
     Path(JNIEnv* env, jbyteArray pathBytes)
@@ -197,23 +167,6 @@
     return ((doStat(env, pathBytes) & STAT_TYPE_FILE) != 0);
 }
 
-// TODO: why isn't this done in Java instead?
-static jboolean java_io_File_isHiddenImpl(JNIEnv* env, jobject obj, jbyteArray pathBytes) {
-    Path path(env, pathBytes);
-
-    if (!java_io_File_existsImpl(env, obj, pathBytes)) {
-        return JNI_FALSE;
-    }
-
-    for (int i = path.size() - 1; i >= 0; --i) {
-        if(path[i] == '.' && i > 0 && path[i - 1] == '/') {
-            return JNI_TRUE;
-        }
-    }
-
-    return JNI_FALSE;
-}
-
 static jboolean java_io_File_isReadableImpl(JNIEnv* env, jobject, jbyteArray pathBytes) {
     Path path(env, pathBytes);
     return (access(&path[0], R_OK) == 0);
@@ -407,14 +360,12 @@
 
 static JNINativeMethod gMethods[] = {
     /* name, signature, funcPtr */
-    { "rootsImpl",          "()[[B",  (void*) java_io_File_rootsImpl },
     { "deleteDirImpl",      "([B)Z",  (void*) java_io_File_deleteDirImpl },
     { "deleteFileImpl",     "([B)Z",  (void*) java_io_File_deleteFileImpl },
     { "existsImpl",         "([B)Z",  (void*) java_io_File_existsImpl },
     { "getCanonImpl",       "([B)[B", (void*) java_io_File_getCanonImpl },
     { "isDirectoryImpl",    "([B)Z",  (void*) java_io_File_isDirectoryImpl },
     { "isFileImpl",         "([B)Z",  (void*) java_io_File_isFileImpl },
-    { "isHiddenImpl",       "([B)Z",  (void*) java_io_File_isHiddenImpl },
     // BEGIN android-changed
     { "isReadableImpl",     "([B)Z",  (void*) java_io_File_isReadableImpl },
     { "isWritableImpl",    "([B)Z",   (void*) java_io_File_isWritableImpl },