Don't allow renaming top level directory to another top level directory

We shouldn't allow renaming top level directory to another top level
directory for non-legacy apps. Even though this was the intended
behavior, we failed enforcing this restriction because of incorrect
nesting of "if" and "else if" statements. This Cl corrects the nesting
of "if" and "else if" to enforce the restrictions correctly on both old
and new path.

Bug: 159913101
Test: atest ScopedStorageHostTest#testCantRenameToTopLevelDirectory
Change-Id: I41bac778162483cd8d7825b491d90d5698d02d1d
diff --git a/src/com/android/providers/media/MediaProvider.java b/src/com/android/providers/media/MediaProvider.java
index 772ee64..0be8891 100644
--- a/src/com/android/providers/media/MediaProvider.java
+++ b/src/com/android/providers/media/MediaProvider.java
@@ -2074,7 +2074,8 @@
                 // Rename not allowed on paths that can't be translated to RELATIVE_PATH.
                 Log.e(TAG, errorMessage +  "Invalid path.");
                 return OsConstants.EPERM;
-            } else if (oldRelativePath.length == 1 && TextUtils.isEmpty(oldRelativePath[0])) {
+            }
+            if (oldRelativePath.length == 1 && TextUtils.isEmpty(oldRelativePath[0])) {
                 // Allow rename of files/folders other than default directories.
                 final String displayName = extractDisplayName(oldPath);
                 for (String defaultFolder : sDefaultFolderNames) {
@@ -2084,7 +2085,8 @@
                         return OsConstants.EPERM;
                     }
                 }
-            } else if (newRelativePath.length == 1 && TextUtils.isEmpty(newRelativePath[0])) {
+            }
+            if (newRelativePath.length == 1 && TextUtils.isEmpty(newRelativePath[0])) {
                 Log.e(TAG, errorMessage +  newPath + " is in root folder."
                         + " Renaming a file/directory to root folder is not allowed");
                 return OsConstants.EPERM;