Deal with apps known to LocalTransport backend but with no data

An app might have backed something up and later deleted it, in which
case it will have a directory in the LocalTransport bookkeeping but
with no actual dataset.  Skip these packages at restore time, since
we know a priori that there will be nothing to do.

Change-Id: I85853097bc65ed60e5efd217ee6553b50459e445
diff --git a/core/java/com/android/internal/backup/LocalTransport.java b/core/java/com/android/internal/backup/LocalTransport.java
index 2fe2494..a604d84 100644
--- a/core/java/com/android/internal/backup/LocalTransport.java
+++ b/core/java/com/android/internal/backup/LocalTransport.java
@@ -233,7 +233,9 @@
         if (mRestorePackages == null) throw new IllegalStateException("startRestore not called");
         while (++mRestorePackage < mRestorePackages.length) {
             String name = mRestorePackages[mRestorePackage].packageName;
-            if (new File(mDataDir, name).isDirectory()) {
+            // skip packages where we have a data dir but no actual contents
+            String[] contents = (new File(mDataDir, name)).list();
+            if (contents != null && contents.length > 0) {
                 if (DEBUG) Log.v(TAG, "  nextRestorePackage() = " + name);
                 return name;
             }