Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit acc0043a authored by Jerry Zhang's avatar Jerry Zhang Committed by android-build-merger
Browse files

Merge "Call access(2) on all files/dirs modified by Mtp" into pi-dev am: 01f41f96

am: 73e4d170

Change-Id: I12a754ef36e72a3913d641012da3b0419e64c161
parents c5c75c8b 73e4d170
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -35,6 +35,9 @@ import android.provider.MediaStore;
import android.provider.MediaStore.Audio;
import android.provider.MediaStore.Files;
import android.provider.MediaStore.MediaColumns;
import android.system.ErrnoException;
import android.system.Os;
import android.system.OsConstants;
import android.util.Log;
import android.view.Display;
import android.view.WindowManager;
@@ -560,6 +563,13 @@ public class MtpDatabase implements AutoCloseable {
            return MtpConstants.RESPONSE_GENERAL_ERROR;
        Path newPath = obj.getPath();
        boolean success = oldPath.toFile().renameTo(newPath.toFile());
        try {
            Os.access(oldPath.toString(), OsConstants.F_OK);
            Os.access(newPath.toString(), OsConstants.F_OK);
        } catch (ErrnoException e) {
            // Ignore. Could fail if the metadata was already updated.
        }

        if (!mManager.endRenameObject(obj, oldPath.getFileName().toString(), success)) {
            Log.e(TAG, "Failed to end rename object");
        }
+4 −4
Original line number Diff line number Diff line
@@ -104,10 +104,10 @@ public class MtpStorageManagerTest {
        mainStorageDir = createNewDir(TEMP_DIR_FILE);
        secondaryStorageDir = createNewDir(TEMP_DIR_FILE);

        StorageVolume mainStorage = new StorageVolume("1", mainStorageDir, "", true, false, true,
                false, -1, UserHandle.CURRENT, "", "");
        StorageVolume secondaryStorage = new StorageVolume("2", secondaryStorageDir, "", false,
                false, true, false, -1, UserHandle.CURRENT, "", "");
        StorageVolume mainStorage = new StorageVolume("1", mainStorageDir, mainStorageDir,
                "", true, false, true, false, -1, UserHandle.CURRENT, "", "");
        StorageVolume secondaryStorage = new StorageVolume("2", secondaryStorageDir,
                secondaryStorageDir, "", false, false, true, false, -1, UserHandle.CURRENT, "", "");

        objectsAdded = new ArrayList<>();
        objectsRemoved = new ArrayList<>();