android: Fixed CIA installation failure in vanilla variant

This introduces a very hacky way of telling TranslateFilePath that a path is already native and doesn't need translating. I don't like this very much, but addressing this in any other way is very much outside of the scope of this PR.
This commit is contained in:
OpenSauce04 2026-03-07 23:22:28 +00:00 committed by OpenSauce
parent 8e1ffc1bdc
commit 7ad6621f91
3 changed files with 20 additions and 5 deletions

View file

@ -703,7 +703,7 @@ object NativeLibrary {
if (pathSegment.startsWith("primary:")) { // User directory is located in primary storage
val primaryStoragePath = Environment.getExternalStorageDirectory().absolutePath
return primaryStoragePath + dirSep + virtualPath + dirSep
return primaryStoragePath + dirSep + virtualPath
} else { // User directory probably located on a removable storage device
val storageIdString = pathSegment.substringBefore(":")
val removablePath = RemovableStorageHelper.getRemovableStoragePath(storageIdString)

View file

@ -1,4 +1,4 @@
// Copyright 2023 Citra Emulator Project
// Copyright Citra Emulator Project / Azahar Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
@ -12,9 +12,11 @@ import androidx.core.app.NotificationCompat
import androidx.work.ForegroundInfo
import androidx.work.Worker
import androidx.work.WorkerParameters
import org.citra.citra_emu.NativeLibrary
import org.citra.citra_emu.NativeLibrary.InstallStatus
import org.citra.citra_emu.R
import org.citra.citra_emu.utils.FileUtil.getFilename
import androidx.core.net.toUri
class CiaInstallWorker(
val context: Context,
@ -131,7 +133,7 @@ class CiaInstallWorker(
installProgressBuilder.setOngoing(true)
setProgressCallback(100, 0)
selectedFiles.forEachIndexed { i, file ->
val filename = getFilename(Uri.parse(file))
val filename = getFilename(file.toUri())
installProgressBuilder.setContentText(
context.getString(
R.string.cia_install_notification_installing,
@ -140,7 +142,13 @@ class CiaInstallWorker(
selectedFiles.size
)
)
val res = installCIA(file)
var fileFinal: String
if (BuildUtil.isGooglePlayBuild) {
fileFinal = file
} else {
fileFinal = "!" + NativeLibrary.getNativePath(file.toUri())
}
val res = installCIA(fileFinal)
notifyInstallStatus(filename, res)
}
notificationManager.cancel(PROGRESS_NOTIFICATION_ID)

View file

@ -308,9 +308,16 @@ bool MoveAndRenameFile(const std::string& src_full_path, const std::string& dest
}
std::string TranslateFilePath(const std::string& filepath) {
// "!" at front of path indicates an already-native path.
// This is hacky, but I don't know how else we can do this without a lot of quite invasive
// changes to how Android file IO works.
// TODO: We should definitely change this in favour of a real solution down the line.
if (filepath.front() == '!') {
return filepath.substr(1);
}
std::optional<std::string> userDirLocation = GetUserDirectory();
if (userDirLocation) {
return *userDirLocation + filepath;
return *userDirLocation + "/" + filepath;
}
return "";
}