Merge "Don't crash when wiping backup data redundantly in the local transport"
diff --git a/core/java/com/android/internal/backup/LocalTransport.java b/core/java/com/android/internal/backup/LocalTransport.java
index e7c3948..eed3e67 100644
--- a/core/java/com/android/internal/backup/LocalTransport.java
+++ b/core/java/com/android/internal/backup/LocalTransport.java
@@ -166,10 +166,13 @@
if (DEBUG) Log.v(TAG, "clearBackupData() pkg=" + packageInfo.packageName);
File packageDir = new File(mDataDir, packageInfo.packageName);
- for (File f : packageDir.listFiles()) {
- f.delete();
+ final File[] fileset = packageDir.listFiles();
+ if (fileset != null) {
+ for (File f : fileset) {
+ f.delete();
+ }
+ packageDir.delete();
}
- packageDir.delete();
return BackupConstants.TRANSPORT_OK;
}
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java
index bd12270..bd8ae17 100644
--- a/services/java/com/android/server/BackupManagerService.java
+++ b/services/java/com/android/server/BackupManagerService.java
@@ -4693,6 +4693,8 @@
mTransport.clearBackupData(mPackage);
} catch (RemoteException e) {
// can't happen; the transport is local
+ } catch (Exception e) {
+ Slog.e(TAG, "Transport threw attempting to clear data for " + mPackage);
} finally {
try {
// TODO - need to handle failures