summaryrefslogtreecommitdiff
path: root/core/java/android/app/ActivityThread.java
diff options
context:
space:
mode:
authorZim <zezeozue@google.com>2019-12-12 10:54:45 +0000
committerZim <zezeozue@google.com>2019-12-12 12:40:51 +0000
commite59cb735f33e1ee5524073fe9fb2c417efcda6fe (patch)
tree3a8cdba4935cdf8d2a34fba3877c46ed043b697e /core/java/android/app/ActivityThread.java
parent44cf6950cfd081878803e1793c59d467e0dc7004 (diff)
Revert "Remove the rename() interceptor"
This reverts I0f9ac456104759887c0410fe64acc32cab19b62b And adds an additional check to only fallback handle the EXDEV from paths on /storage We are bringing back the interceptor because the implementation of scoped storage in R uses a FUSE filesystem mounted on /sdcard with an sdcardfs filesystem mounted on /sdcard/Android/<package> (for now, just /sdcard/Android in Ic17a5751b5a94846ee565ff935644a078044ab06) Test: atest android.appsecurity.cts.ExternalStorageHostTest#testExternalStorageRename with FUSE enabled passes Bug: 135341433 Change-Id: I7876bfe00890f24559576f260ba456afb07e9482
Diffstat (limited to 'core/java/android/app/ActivityThread.java')
-rw-r--r--core/java/android/app/ActivityThread.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 49a8e2f3f816..93b6454edcf3 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -7395,6 +7395,24 @@ public final class ActivityThread extends ClientTransactionHandler {
super.remove(path);
}
}
+
+ @Override
+ public void rename(String oldPath, String newPath) throws ErrnoException {
+ try {
+ super.rename(oldPath, newPath);
+ } catch (ErrnoException e) {
+ if (e.errno == OsConstants.EXDEV && oldPath.startsWith("/storage/")) {
+ Log.v(TAG, "Recovering failed rename " + oldPath + " to " + newPath);
+ try {
+ Files.move(new File(oldPath).toPath(), new File(newPath).toPath());
+ } catch (IOException e2) {
+ throw e;
+ }
+ } else {
+ throw e;
+ }
+ }
+ }
}
public static void main(String[] args) {