From 853810b59fa7bd26cff4d7c969452e5c6f3bd56c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 24 Feb 2026 14:30:02 +0100 Subject: [PATCH 1/6] Some java modernization, cleanup --- android/AndroidManifest.xml | 4 -- .../ppsspp/AudioFocusChangeListener.java | 3 ++ .../src/org/ppsspp/ppsspp/CameraHelper.java | 47 +++++++++---------- android/src/org/ppsspp/ppsspp/ContentUri.java | 8 ---- .../src/org/ppsspp/ppsspp/InfraredHelper.java | 3 -- .../src/org/ppsspp/ppsspp/LocationHelper.java | 19 +------- android/src/org/ppsspp/ppsspp/NativeApp.java | 1 - .../src/org/ppsspp/ppsspp/PpssppActivity.java | 18 +++---- .../org/ppsspp/ppsspp/SimpleFileChooser.java | 24 +++++----- .../src/org/ppsspp/ppsspp/SizeManager.java | 29 ++++-------- .../src/org/ppsspp/ppsspp/TextRenderer.java | 7 +-- 11 files changed, 56 insertions(+), 107 deletions(-) diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 1de3a43c78..592419e6fb 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -111,10 +111,6 @@ - - diff --git a/android/src/org/ppsspp/ppsspp/AudioFocusChangeListener.java b/android/src/org/ppsspp/ppsspp/AudioFocusChangeListener.java index 02a74576b5..e8e0072f17 100644 --- a/android/src/org/ppsspp/ppsspp/AudioFocusChangeListener.java +++ b/android/src/org/ppsspp/ppsspp/AudioFocusChangeListener.java @@ -3,6 +3,8 @@ package org.ppsspp.ppsspp; import android.media.AudioManager; import android.media.AudioManager.OnAudioFocusChangeListener; +import androidx.annotation.Keep; + public class AudioFocusChangeListener implements OnAudioFocusChangeListener { // not used right now, but we may need to use it sometime. So just store it // for now. @@ -21,6 +23,7 @@ public class AudioFocusChangeListener implements OnAudioFocusChangeListener { } } + @Keep public boolean hasAudioFocus() { return hasAudioFocus; } diff --git a/android/src/org/ppsspp/ppsspp/CameraHelper.java b/android/src/org/ppsspp/ppsspp/CameraHelper.java index 996d84284d..61719a82c5 100644 --- a/android/src/org/ppsspp/ppsspp/CameraHelper.java +++ b/android/src/org/ppsspp/ppsspp/CameraHelper.java @@ -1,6 +1,5 @@ package org.ppsspp.ppsspp; -import android.annotation.TargetApi; import android.content.Context; import android.graphics.ImageFormat; import android.graphics.Rect; @@ -13,6 +12,8 @@ import android.view.Display; import android.view.Surface; import android.view.WindowManager; +import androidx.annotation.Keep; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; @@ -124,31 +125,28 @@ class CameraHelper { return output; } - private final Camera.PreviewCallback mPreviewCallback = new Camera.PreviewCallback() { - @Override - public void onPreviewFrame(byte[] previewData, Camera camera) { - // throttle at 16 ms - long currentTime = SystemClock.elapsedRealtime(); - if (currentTime - mLastFrameTime < 16) { - return; - } - mLastFrameTime = currentTime; + private final Camera.PreviewCallback mPreviewCallback = (previewData, camera) -> { + // throttle at 16 ms + long currentTime = SystemClock.elapsedRealtime(); + if (currentTime - mLastFrameTime < 16) { + return; + } + mLastFrameTime = currentTime; - int cameraRotation = getCameraRotation(); - byte[] newPreviewData = rotateNV21(previewData, mPreviewSize.width, mPreviewSize.height, - mTargetWidth, mTargetHeight, cameraRotation); - YuvImage yuvImage = new YuvImage(newPreviewData, ImageFormat.NV21, mTargetWidth, mTargetHeight, null); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); + int cameraRotation = getCameraRotation(); + byte[] newPreviewData = rotateNV21(previewData, mPreviewSize.width, mPreviewSize.height, + mTargetWidth, mTargetHeight, cameraRotation); + YuvImage yuvImage = new YuvImage(newPreviewData, ImageFormat.NV21, mTargetWidth, mTargetHeight, null); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); - // convert to Jpeg - Rect crop = new Rect(0, 0, mTargetWidth, mTargetHeight); - yuvImage.compressToJpeg(crop, 80, baos); - NativeApp.pushCameraImageAndroid(baos.toByteArray()); - try { - baos.close(); - } catch (IOException e) { - Log.e(TAG,"Camera I/O exception: " + e); - } + // convert to Jpeg + Rect crop = new Rect(0, 0, mTargetWidth, mTargetHeight); + yuvImage.compressToJpeg(crop, 80, baos); + NativeApp.pushCameraImageAndroid(baos.toByteArray()); + try { + baos.close(); + } catch (IOException e) { + Log.e(TAG,"Camera I/O exception: " + e); } }; @@ -158,6 +156,7 @@ class CameraHelper { mSurfaceTexture = new SurfaceTexture(10); } + @Keep static ArrayList getDeviceList() { ArrayList deviceList = new ArrayList<>(); if (PpssppActivity.isVRDevice()) { diff --git a/android/src/org/ppsspp/ppsspp/ContentUri.java b/android/src/org/ppsspp/ppsspp/ContentUri.java index 69c8ae9cab..603570c92e 100644 --- a/android/src/org/ppsspp/ppsspp/ContentUri.java +++ b/android/src/org/ppsspp/ppsspp/ContentUri.java @@ -58,14 +58,6 @@ public class ContentUri { } } - private static final String[] columns = new String[] { - DocumentsContract.Document.COLUMN_DISPLAY_NAME, - DocumentsContract.Document.COLUMN_SIZE, - DocumentsContract.Document.COLUMN_FLAGS, - DocumentsContract.Document.COLUMN_MIME_TYPE, // check for MIME_TYPE_DIR - DocumentsContract.Document.COLUMN_LAST_MODIFIED - }; - private static String cursorToString(Cursor c, String prefixLowercase) { final int flags = c.getInt(2); // Filter out any virtual or partial nonsense. diff --git a/android/src/org/ppsspp/ppsspp/InfraredHelper.java b/android/src/org/ppsspp/ppsspp/InfraredHelper.java index 073879fa54..660932717c 100644 --- a/android/src/org/ppsspp/ppsspp/InfraredHelper.java +++ b/android/src/org/ppsspp/ppsspp/InfraredHelper.java @@ -3,11 +3,8 @@ package org.ppsspp.ppsspp; import android.content.Context; import android.hardware.ConsumerIrManager; import android.hardware.ConsumerIrManager.CarrierFrequencyRange; -import android.os.Build; import android.util.Log; -import androidx.annotation.RequiresApi; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; diff --git a/android/src/org/ppsspp/ppsspp/LocationHelper.java b/android/src/org/ppsspp/ppsspp/LocationHelper.java index 06a3365d30..a9b8d2c8ba 100644 --- a/android/src/org/ppsspp/ppsspp/LocationHelper.java +++ b/android/src/org/ppsspp/ppsspp/LocationHelper.java @@ -1,6 +1,5 @@ package org.ppsspp.ppsspp; -import android.annotation.TargetApi; import android.content.Context; import android.location.GnssStatus; import android.location.GpsSatellite; @@ -16,8 +15,6 @@ import android.util.Log; import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; -import java.util.Iterator; - class LocationHelper implements LocationListener { private static final String TAG = LocationHelper.class.getSimpleName(); private static final int GPGGA_ID_INDEX = 0; @@ -37,7 +34,6 @@ class LocationHelper implements LocationListener { mLocationEnable = false; } - @SuppressWarnings("deprecation") void startLocationUpdates() { Log.d(TAG, "startLocationUpdates"); if (!mLocationEnable) { @@ -56,22 +52,12 @@ class LocationHelper implements LocationListener { } }; mLocationManager.registerGnssStatusCallback(mGnssStatusCallback); - mNmeaMessageListener = new OnNmeaMessageListener() { - @Override - public void onNmeaMessage(String message, long timestamp) { - onNmea(message); - } - }; + mNmeaMessageListener = (message, timestamp) -> onNmea(message); mLocationManager.addNmeaListener(mNmeaMessageListener); } else { mGpsStatusListener = this::onGpsStatus; mLocationManager.addGpsStatusListener(mGpsStatusListener); - mNmeaListener = new GpsStatus.NmeaListener() { - @Override - public void onNmeaReceived(long timestamp, String nmea) { - onNmea(nmea); - } - }; + mNmeaListener = (timestamp, nmea) -> onNmea(nmea); mLocationManager.addNmeaListener(mNmeaListener); } mLocationEnable = true; @@ -85,7 +71,6 @@ class LocationHelper implements LocationListener { } } - @SuppressWarnings("deprecation") void stopLocationUpdates() { Log.d(TAG, "stopLocationUpdates"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { diff --git a/android/src/org/ppsspp/ppsspp/NativeApp.java b/android/src/org/ppsspp/ppsspp/NativeApp.java index 82519d4790..e951f66023 100644 --- a/android/src/org/ppsspp/ppsspp/NativeApp.java +++ b/android/src/org/ppsspp/ppsspp/NativeApp.java @@ -2,7 +2,6 @@ package org.ppsspp.ppsspp; // Note that the display* methods are in NativeRenderer.java -import android.annotation.SuppressLint; import android.os.Build; import android.util.Log; import android.view.InputDevice; diff --git a/android/src/org/ppsspp/ppsspp/PpssppActivity.java b/android/src/org/ppsspp/ppsspp/PpssppActivity.java index d8e94af9ad..b94c204950 100644 --- a/android/src/org/ppsspp/ppsspp/PpssppActivity.java +++ b/android/src/org/ppsspp/ppsspp/PpssppActivity.java @@ -1240,7 +1240,7 @@ public class PpssppActivity extends AppCompatActivity implements SensorEventList char c = (char) unicode; Log.i(TAG, "Key char event " + unicode); // Handle alphanumeric character - NativeApp.keyChar(NativeApp.DEVICE_ID_KEYBOARD, (int)c); + NativeApp.keyChar(NativeApp.DEVICE_ID_KEYBOARD, c); return true; } @@ -1507,7 +1507,7 @@ public class PpssppActivity extends AppCompatActivity implements SensorEventList @RequiresApi(Build.VERSION_CODES.M) private AlertDialog.Builder createDialogBuilderNew() { - return new AlertDialog.Builder(this, android.R.style.Theme_DeviceDefault_Dialog_Alert); + return new AlertDialog.Builder(this, android.R.style.Theme_Material_Dialog_Alert); } private AlertDialog.Builder createDialogBuilder() { @@ -1533,7 +1533,6 @@ public class PpssppActivity extends AppCompatActivity implements SensorEventList input.setText(defaultText); input.setFocusableInTouchMode(true); input.requestFocus(); - input.selectAll(); //input.setSelection(input.getText().length()); @@ -1545,9 +1544,7 @@ public class PpssppActivity extends AppCompatActivity implements SensorEventList NativeApp.sendRequestResult(requestId, true, input.getText().toString(), 0); // Dismiss happens automatically. }) - .setNegativeButton("Cancel", (d, which) -> { - d.cancel(); - }); + .setNegativeButton("Cancel", (d, which) -> d.cancel()); builder.setOnDismissListener( d -> { Log.i(TAG, "input box dismissed"); // This will be ignored if we already sent a success. @@ -1951,12 +1948,9 @@ public class PpssppActivity extends AppCompatActivity implements SensorEventList public void postCommand(String command, String parameter) { final String cmd = command; final String param = parameter; - runOnUiThread(new Runnable() { - @Override - public void run() { - if (!processCommand(cmd, param)) { - Log.e(TAG, "processCommand failed: cmd: '" + cmd + "' param: '" + param + "'"); - } + runOnUiThread(() -> { + if (!processCommand(cmd, param)) { + Log.e(TAG, "processCommand failed: cmd: '" + cmd + "' param: '" + param + "'"); } }); } diff --git a/android/src/org/ppsspp/ppsspp/SimpleFileChooser.java b/android/src/org/ppsspp/ppsspp/SimpleFileChooser.java index 3610ae76b3..252d1adb1f 100644 --- a/android/src/org/ppsspp/ppsspp/SimpleFileChooser.java +++ b/android/src/org/ppsspp/ppsspp/SimpleFileChooser.java @@ -74,19 +74,17 @@ public class SimpleFileChooser { // Comparator for Arrays.sort(). Separate folders from files, order // alphabetically, ignore case. - private final Comparator fileArrayComparator = new Comparator<>() { - public int compare(File file1, File file2) { - if (file1 == null || file2 == null) // if either null, assume equal - return 0; - // put folder first before file - else if (file1.isDirectory() && (!file2.isDirectory())) - return -1; - else if (file2.isDirectory() && (!file1.isDirectory())) - return 1; - else - // when both are folders or both are files, sort by name - return file1.getName().toUpperCase(Locale.ROOT).compareTo(file2.getName().toUpperCase(Locale.ROOT)); - } + private final Comparator fileArrayComparator = (file1, file2) -> { + if (file1 == null || file2 == null) // if either null, assume equal + return 0; + // put folder first before file + else if (file1.isDirectory() && (!file2.isDirectory())) + return -1; + else if (file2.isDirectory() && (!file1.isDirectory())) + return 1; + else + // when both are folders or both are files, sort by name + return file1.getName().toUpperCase(Locale.ROOT).compareTo(file2.getName().toUpperCase(Locale.ROOT)); }; // Event when user click item on dialog diff --git a/android/src/org/ppsspp/ppsspp/SizeManager.java b/android/src/org/ppsspp/ppsspp/SizeManager.java index 86b87f3932..2f1507ed8e 100644 --- a/android/src/org/ppsspp/ppsspp/SizeManager.java +++ b/android/src/org/ppsspp/ppsspp/SizeManager.java @@ -1,9 +1,7 @@ package org.ppsspp.ppsspp; import android.content.pm.ActivityInfo; -import android.content.res.Configuration; import android.graphics.Point; -import android.os.Build; import android.util.DisplayMetrics; import android.util.Log; import android.view.Display; @@ -11,10 +9,6 @@ import android.view.Surface; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; -import androidx.annotation.RequiresApi; -import androidx.core.graphics.Insets; -import androidx.core.view.ViewCompat; -import androidx.core.view.WindowInsetsCompat; public class SizeManager implements SurfaceHolder.Callback { private static final String TAG = "PPSSPPSizeManager"; @@ -106,7 +100,7 @@ public class SizeManager implements SurfaceHolder.Callback { Log.v(TAG, "surfaceChanged: isCreating:" + holder.isCreating() + " holder: " + holder); if (holder.isCreating() && desiredSize.x > 0 && desiredSize.y > 0) { // We have called setFixedSize which will trigger another surfaceChanged after the initial - // one. This one is the original one and we don't care about it. + // one. This one is the original one, and we don't care about it. Log.w(TAG, "holder.isCreating = true, ignoring. width=" + width + " height=" + height + " desWidth=" + desiredSize.x + " desHeight=" + desiredSize.y); // TODO: Should we still set earlySurface here, to be sure? @@ -171,18 +165,15 @@ public class SizeManager implements SurfaceHolder.Callback { } public void setupSystemUiCallback(final View view) { - view.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { - @Override - public void onSystemUiVisibilityChange(int visibility) { - // Called when the system UI's visibility changes, regardless of - // whether it's because of our or system actions. - // We will try to force it to follow our preference but will not stupidly - // act as if it's visible if it's not. - navigationHidden = ((visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0); - // TODO: Check here if it's the state we want. - Log.i(TAG, "SystemUiVisibilityChange! visibility=" + visibility + " navigationHidden: " + navigationHidden + " decorView: " + view.getWidth() + "x" + view.getHeight()); - checkDisplayMeasurements(); - } + view.setOnSystemUiVisibilityChangeListener(visibility -> { + // Called when the system UI's visibility changes, regardless of + // whether it's because of our or system actions. + // We will try to force it to follow our preference but will not stupidly + // act as if it's visible if it's not. + navigationHidden = ((visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0); + // TODO: Check here if it's the state we want. + Log.i(TAG, "SystemUiVisibilityChange! visibility=" + visibility + " navigationHidden: " + navigationHidden + " decorView: " + view.getWidth() + "x" + view.getHeight()); + checkDisplayMeasurements(); }); } diff --git a/android/src/org/ppsspp/ppsspp/TextRenderer.java b/android/src/org/ppsspp/ppsspp/TextRenderer.java index 91bd85ef8e..cb9fa60492 100644 --- a/android/src/org/ppsspp/ppsspp/TextRenderer.java +++ b/android/src/org/ppsspp/ppsspp/TextRenderer.java @@ -10,11 +10,6 @@ import androidx.annotation.Keep; import java.util.HashMap; public class TextRenderer { - private static class Font { - public Paint paint; - public Typeface typeFace; - } - private static Paint textPaint = null; private static final Paint bg; @@ -22,7 +17,7 @@ public class TextRenderer { private static int idGen = 1; - private static HashMap fontMap = new HashMap<>(); + private static final HashMap fontMap = new HashMap<>(); private static boolean highContrastFontsEnabled = false; From f13d339ed3d465f9f03d71e2ca39985ac35cf734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 24 Feb 2026 14:42:42 +0100 Subject: [PATCH 2/6] Set the CRC banner on the game screen to fit contents, instead of the screen. Also make sure it's not visible when it shouldn't be --- UI/GameScreen.cpp | 8 ++------ UI/PauseScreen.cpp | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index 76e620b1d8..f1e7cd1d27 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -335,7 +335,7 @@ void GameScreen::CreateContentViews(UI::ViewGroup *parent) { } } if (found) { - NoticeView *tvVerified = infoLayout->Add(new NoticeView(NoticeLevel::INFO, ga->T("ISO OK according to the ReDump project"), "", new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT))); + NoticeView *tvVerified = infoLayout->Add(new NoticeView(NoticeLevel::INFO, ga->T("ISO OK according to the ReDump project"), "", new LinearLayoutParams(WRAP_CONTENT, WRAP_CONTENT))); tvVerified->SetLevel(NoticeLevel::SUCCESS); } } @@ -359,17 +359,13 @@ void GameScreen::CreateContentViews(UI::ViewGroup *parent) { // INFO_LOG(Log::Loader, "File size %d not matching game DB", (int)info_->gameSizeUncompressed); } - NoticeView *tvVerified = infoLayout->Add(new NoticeView(NoticeLevel::INFO, ga->T("Click \"Calculate CRC\" to verify ISO"), "", new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT))); + NoticeView *tvVerified = infoLayout->Add(new NoticeView(NoticeLevel::INFO, ga->T("Click \"Calculate CRC\" to verify ISO"), "", new LinearLayoutParams(WRAP_CONTENT, WRAP_CONTENT))); tvVerified->SetVisibility(UI::V_VISIBLE); tvVerified->SetLevel(NoticeLevel::INFO); } } } - NoticeView *tvVerified = infoLayout->Add(new NoticeView(NoticeLevel::INFO, ga->T("Click \"Calculate CRC\" to verify ISO"), "", new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT))); - tvVerified->SetVisibility(UI::V_GONE); - tvVerified->SetSquishy(true); - // Show plugin info_, if any. Later might add checkboxes. auto plugins = HLEPlugins::FindPlugins(info_->id, g_Config.sLanguageIni); if (!plugins.empty()) { diff --git a/UI/PauseScreen.cpp b/UI/PauseScreen.cpp index cc08a91225..20be293c1f 100644 --- a/UI/PauseScreen.cpp +++ b/UI/PauseScreen.cpp @@ -833,7 +833,7 @@ std::string GetConfirmExitMessage() { return confirmMessage; } auto di = GetI18NCategory(I18NCat::DIALOG); - confirmMessage = ApplySafeSubstitutions(di->T("You haven't saved your progress for %1."), NiceTimeFormat((int)unsavedSeconds)); + confirmMessage += ApplySafeSubstitutions(di->T("You haven't saved your progress for %1."), NiceTimeFormat((int)unsavedSeconds)); confirmMessage += '\n'; } From 22bfa0087c2f5a412015449fde8be23f50e4d152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 24 Feb 2026 14:59:43 +0100 Subject: [PATCH 3/6] Minor code cleanup --- Core/FileSystems/ISOFileSystem.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Core/FileSystems/ISOFileSystem.cpp b/Core/FileSystems/ISOFileSystem.cpp index 4e2af27703..38e2c7b8b5 100644 --- a/Core/FileSystems/ISOFileSystem.cpp +++ b/Core/FileSystems/ISOFileSystem.cpp @@ -22,6 +22,7 @@ #include "Common/CommonTypes.h" #include "Common/Serialize/Serializer.h" #include "Common/Serialize/SerializeFuncs.h" +#include "Common/StringUtils.h" #include "Core/FileSystems/ISOFileSystem.h" #include "Core/HLE/sceKernel.h" #include "Core/MemMap.h" @@ -33,11 +34,11 @@ bool parseLBN(const std::string &filename, u32 *sectorStart, u32 *readSize) { // The format of this is: "/sce_lbn" "0x"? HEX* ANY* "_size" "0x"? HEX* ANY* // That means that "/sce_lbn/_size1/" is perfectly valid. // Most commonly, it looks like /sce_lbn0x10_size0x100 or /sce_lbn10_size100 (always hex.) - // If it doesn't starts with /sce_lbn or doesn't have _size, look for a file instead. - if (filename.compare(0, sizeof("/sce_lbn") - 1, "/sce_lbn") != 0) + if (!startsWith(filename, "/sce_lbn")) return false; - size_t size_pos = filename.find("_size"); + + const size_t size_pos = filename.find("_size"); if (size_pos == filename.npos) return false; From b7ad74d3098c654dabd8709ca8be47f9c4f95337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 24 Feb 2026 15:01:36 +0100 Subject: [PATCH 4/6] MetaFileSystem: Turn another argument into string_view --- Core/FileSystems/BlobFileSystem.cpp | 2 +- Core/FileSystems/BlobFileSystem.h | 2 +- Core/FileSystems/DirectoryFileSystem.cpp | 6 +++--- Core/FileSystems/DirectoryFileSystem.h | 4 ++-- Core/FileSystems/FileSystem.h | 4 ++-- Core/FileSystems/ISOFileSystem.cpp | 2 +- Core/FileSystems/ISOFileSystem.h | 4 ++-- Core/FileSystems/MetaFileSystem.cpp | 2 +- Core/FileSystems/MetaFileSystem.h | 2 +- Core/FileSystems/VirtualDiscFileSystem.cpp | 14 +++++++------- Core/FileSystems/VirtualDiscFileSystem.h | 2 +- android/jni/app-android.cpp | 10 ++++++---- 12 files changed, 28 insertions(+), 26 deletions(-) diff --git a/Core/FileSystems/BlobFileSystem.cpp b/Core/FileSystems/BlobFileSystem.cpp index 0843ce440e..1060844bf4 100644 --- a/Core/FileSystems/BlobFileSystem.cpp +++ b/Core/FileSystems/BlobFileSystem.cpp @@ -30,7 +30,7 @@ void BlobFileSystem::DoState(PointerWrap &p) { // Not used in real emulation. } -std::vector BlobFileSystem::GetDirListing(const std::string &path, bool *exists) { +std::vector BlobFileSystem::GetDirListing(std::string_view path, bool *exists) { std::vector listing; listing.push_back(GetFileInfo(alias_)); if (exists) diff --git a/Core/FileSystems/BlobFileSystem.h b/Core/FileSystems/BlobFileSystem.h index 256710d0e5..1d8f96c84d 100644 --- a/Core/FileSystems/BlobFileSystem.h +++ b/Core/FileSystems/BlobFileSystem.h @@ -34,7 +34,7 @@ public: ~BlobFileSystem(); void DoState(PointerWrap &p) override; - std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override; + std::vector GetDirListing(std::string_view path, bool *exists = nullptr) override; int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override; void CloseFile(u32 handle) override; size_t ReadFile(u32 handle, u8 *pointer, s64 size) override; diff --git a/Core/FileSystems/DirectoryFileSystem.cpp b/Core/FileSystems/DirectoryFileSystem.cpp index a459b125dc..3534e301cd 100644 --- a/Core/FileSystems/DirectoryFileSystem.cpp +++ b/Core/FileSystems/DirectoryFileSystem.cpp @@ -873,7 +873,7 @@ bool DirectoryFileSystem::ComputeRecursiveDirSizeIfFast(const std::string &path, } } -std::vector DirectoryFileSystem::GetDirListing(const std::string &path, bool *exists) { +std::vector DirectoryFileSystem::GetDirListing(std::string_view path, bool *exists) { std::vector myVector; std::vector files; @@ -884,7 +884,7 @@ std::vector DirectoryFileSystem::GetDirListing(const std::string &p if (this->flags & FileSystemFlags::CASE_SENSITIVE) { if (!success) { // TODO: Case sensitivity should be checked on a file system basis, right? - std::string fixedPath = path; + std::string fixedPath(path); if (FixPathCase(basePath, fixedPath, FPC_FILE_MUST_EXIST)) { // May have failed due to case sensitivity, try again localPath = GetLocalPath(fixedPath); @@ -1204,7 +1204,7 @@ size_t VFSFileSystem::SeekFile(u32 handle, s32 position, FileMove type) { } } -std::vector VFSFileSystem::GetDirListing(const std::string &path, bool *exists) { +std::vector VFSFileSystem::GetDirListing(std::string_view path, bool *exists) { std::vector myVector; // TODO if (exists) diff --git a/Core/FileSystems/DirectoryFileSystem.h b/Core/FileSystems/DirectoryFileSystem.h index ffac242911..6761d48e52 100644 --- a/Core/FileSystems/DirectoryFileSystem.h +++ b/Core/FileSystems/DirectoryFileSystem.h @@ -67,7 +67,7 @@ public: void CloseAll(); void DoState(PointerWrap &p) override; - std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override; + std::vector GetDirListing(std::string_view path, bool *exists = nullptr) override; int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override; void CloseFile(u32 handle) override; size_t ReadFile(u32 handle, u8 *pointer, s64 size) override; @@ -115,7 +115,7 @@ public: ~VFSFileSystem(); void DoState(PointerWrap &p) override; - std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override; + std::vector GetDirListing(std::string_view path, bool *exists = nullptr) override; int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override; void CloseFile(u32 handle) override; size_t ReadFile(u32 handle, u8 *pointer, s64 size) override; diff --git a/Core/FileSystems/FileSystem.h b/Core/FileSystems/FileSystem.h index 90dfc50649..90cae79131 100644 --- a/Core/FileSystems/FileSystem.h +++ b/Core/FileSystems/FileSystem.h @@ -134,7 +134,7 @@ public: virtual ~IFileSystem() {} virtual void DoState(PointerWrap &p) = 0; - virtual std::vector GetDirListing(const std::string &path, bool *exists = nullptr) = 0; + virtual std::vector GetDirListing(std::string_view path, bool *exists = nullptr) = 0; virtual int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) = 0; virtual void CloseFile(u32 handle) = 0; virtual size_t ReadFile(u32 handle, u8 *pointer, s64 size) = 0; @@ -161,7 +161,7 @@ public: class EmptyFileSystem : public IFileSystem { public: void DoState(PointerWrap &p) override {} - std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override { + std::vector GetDirListing(std::string_view path, bool *exists = nullptr) override { if (exists) *exists = false; std::vector vec; diff --git a/Core/FileSystems/ISOFileSystem.cpp b/Core/FileSystems/ISOFileSystem.cpp index 38e2c7b8b5..dc1c640d43 100644 --- a/Core/FileSystems/ISOFileSystem.cpp +++ b/Core/FileSystems/ISOFileSystem.cpp @@ -659,7 +659,7 @@ PSPFileInfo ISOFileSystem::GetFileInfoByHandle(u32 handle) { return x; } -std::vector ISOFileSystem::GetDirListing(const std::string &path, bool *exists) { +std::vector ISOFileSystem::GetDirListing(std::string_view path, bool *exists) { std::vector myVector; const TreeEntry *entry = GetFromPath(path); if (!entry) { diff --git a/Core/FileSystems/ISOFileSystem.h b/Core/FileSystems/ISOFileSystem.h index c07a5616af..0cc4a1f1a5 100644 --- a/Core/FileSystems/ISOFileSystem.h +++ b/Core/FileSystems/ISOFileSystem.h @@ -32,7 +32,7 @@ public: ~ISOFileSystem(); void DoState(PointerWrap &p) override; - std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override; + std::vector GetDirListing(std::string_view path, bool *exists = nullptr) override; int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override; void CloseFile(u32 handle) override; size_t ReadFile(u32 handle, u8 *pointer, s64 size) override; @@ -114,7 +114,7 @@ public: isoFileSystem_->DoState(p); } - std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override { + std::vector GetDirListing(std::string_view path, bool *exists = nullptr) override { if (exists) *exists = true; return std::vector(); diff --git a/Core/FileSystems/MetaFileSystem.cpp b/Core/FileSystems/MetaFileSystem.cpp index a0b2a56e63..12053c1851 100644 --- a/Core/FileSystems/MetaFileSystem.cpp +++ b/Core/FileSystems/MetaFileSystem.cpp @@ -364,7 +364,7 @@ PSPFileInfo MetaFileSystem::GetFileInfoByHandle(u32 handle) { return PSPFileInfo(); } -std::vector MetaFileSystem::GetDirListing(const std::string &path, bool *exists) { +std::vector MetaFileSystem::GetDirListing(std::string_view path, bool *exists) { std::lock_guard guard(lock); std::string of; IFileSystem *system; diff --git a/Core/FileSystems/MetaFileSystem.h b/Core/FileSystems/MetaFileSystem.h index 4ae4dd5d50..c0362be8e9 100644 --- a/Core/FileSystems/MetaFileSystem.h +++ b/Core/FileSystems/MetaFileSystem.h @@ -109,7 +109,7 @@ public: std::string NormalizePrefix(std::string_view prefix) const; - std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override; + std::vector GetDirListing(std::string_view path, bool *exists = nullptr) override; int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override; void CloseFile(u32 handle) override; size_t ReadFile(u32 handle, u8 *pointer, s64 size) override; diff --git a/Core/FileSystems/VirtualDiscFileSystem.cpp b/Core/FileSystems/VirtualDiscFileSystem.cpp index 35e4164523..baa5dcdacc 100644 --- a/Core/FileSystems/VirtualDiscFileSystem.cpp +++ b/Core/FileSystems/VirtualDiscFileSystem.cpp @@ -652,7 +652,7 @@ static void tmFromFiletime(tm &dest, const FILETIME &src) } #endif -std::vector VirtualDiscFileSystem::GetDirListing(const std::string &path, bool *exists) { +std::vector VirtualDiscFileSystem::GetDirListing(std::string_view pathStr, bool *exists) { std::vector myVector; // TODO(scoped): Switch this over to GetFilesInDir! @@ -663,7 +663,7 @@ std::vector VirtualDiscFileSystem::GetDirListing(const std::string // TODO: Handler files that are virtual might not be listed. - std::wstring w32path = GetLocalPath(path).ToWString() + L"\\*.*"; + std::wstring w32path = GetLocalPath(pathStr).ToWString() + L"\\*.*"; #if PPSSPP_PLATFORM(UWP) hFind = FindFirstFileExFromAppW(w32path.c_str(), FindExInfoStandard, &findData, FindExSearchNameMatch, NULL, 0); @@ -700,7 +700,7 @@ std::vector VirtualDiscFileSystem::GetDirListing(const std::string tmFromFiletime(entry.mtime, findData.ftLastWriteTime); entry.isOnSectorSystem = true; - std::string fullRelativePath = path + "/" + entry.name; + std::string fullRelativePath = std::string(pathStr) + "/" + entry.name; int fileIndex = getFileListIndex(fullRelativePath); if (fileIndex != -1) entry.startSector = fileList[fileIndex].firstBlock; @@ -709,11 +709,11 @@ std::vector VirtualDiscFileSystem::GetDirListing(const std::string FindClose(hFind); #else dirent *dirp; - Path localPath = GetLocalPath(path); + Path localPath = GetLocalPath(pathStr); DIR *dp = opendir(localPath.c_str()); #if HOST_IS_CASE_SENSITIVE - std::string fixedPath = path; + std::string fixedPath(pathStr); if(dp == NULL && FixPathCase(basePath, fixedPath, FPC_FILE_MUST_EXIST)) { // May have failed due to case sensitivity, try again localPath = GetLocalPath(fixedPath); @@ -722,7 +722,7 @@ std::vector VirtualDiscFileSystem::GetDirListing(const std::string #endif if (dp == NULL) { - ERROR_LOG(Log::FileSystem,"Error opening directory %s\n", path.c_str()); + ERROR_LOG(Log::FileSystem,"Error opening directory %.*s\n", STR_VIEW(pathStr)); if (exists) *exists = false; return myVector; @@ -753,7 +753,7 @@ std::vector VirtualDiscFileSystem::GetDirListing(const std::string localtime_r((time_t*)&s.st_mtime,&entry.mtime); entry.isOnSectorSystem = true; - std::string fullRelativePath = path + "/" + entry.name; + std::string fullRelativePath = std::string(pathStr) + "/" + entry.name; int fileIndex = getFileListIndex(fullRelativePath); if (fileIndex != -1) entry.startSector = fileList[fileIndex].firstBlock; diff --git a/Core/FileSystems/VirtualDiscFileSystem.h b/Core/FileSystems/VirtualDiscFileSystem.h index 987ea01ffa..00fb4ada5d 100644 --- a/Core/FileSystems/VirtualDiscFileSystem.h +++ b/Core/FileSystems/VirtualDiscFileSystem.h @@ -43,7 +43,7 @@ public: bool OwnsHandle(u32 handle) override; int Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen, int &usec) override; PSPDevType DevType(u32 handle) override; - std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override; + std::vector GetDirListing(std::string_view path, bool *exists = nullptr) override; FileSystemFlags Flags() const override { return FileSystemFlags::UMD; } u64 FreeDiskSpace(const std::string &path) override { return 0; } diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index cefeaa6a00..d511aa5554 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -125,9 +125,8 @@ static std::atomic emuThreadState((int)EmuThreadState::DISABLED); AndroidAudioState *g_audioState; struct FrameCommand { - FrameCommand() {} - FrameCommand(std::string cmd, std::string prm) : command(cmd), params(prm) {} - + FrameCommand() = default; + FrameCommand(std::string_view cmd, std::string_view param) : command(cmd), params(param) {} std::string command; std::string params; }; @@ -354,7 +353,7 @@ static void PushCommand(std::string_view cmd, std::string_view param) { // Android implementation of callbacks to the Java part of the app void System_Toast(std::string_view text) { - PushCommand("toast", std::string(text)); + PushCommand("toast", text); } void System_ShowKeyboard() { @@ -372,6 +371,9 @@ void System_LaunchUrl(LaunchUrlType urlType, std::string_view url) { case LaunchUrlType::BROWSER_URL: PushCommand("launchBrowser", url); break; case LaunchUrlType::MARKET_URL: PushCommand("launchMarket", url); break; case LaunchUrlType::EMAIL_ADDRESS: PushCommand("launchEmail", url); break; + // Can't really support the below well on Android... + case LaunchUrlType::LOCAL_FOLDER: break; + case LaunchUrlType::LOCAL_FILE: break; } } From a22b01089ba0ab411ca9ae5768fe801293d42d18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 24 Feb 2026 23:43:27 +0100 Subject: [PATCH 5/6] Bump gradle yet again --- android/build.gradle.kts | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/android/build.gradle.kts b/android/build.gradle.kts index beffe02d2f..51ca9c6742 100644 --- a/android/build.gradle.kts +++ b/android/build.gradle.kts @@ -62,7 +62,7 @@ dependencies { // Will replace with a different plugin soon. implementation("androidx.appcompat:appcompat:1.7.1") implementation("androidx.documentfile:documentfile:1.1.0") - implementation("com.google.protobuf:protobuf-javalite:4.33.4") + implementation("com.google.protobuf:protobuf-javalite:4.33.5") } protobuf { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9f479a9119..4be0e713ce 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,6 +3,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-all.zip android.useAndroidX=true android.enableJetifier=true From 1e57d8110f675dad45ceda7f3cbc8d013853a2ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 25 Feb 2026 00:51:25 +0100 Subject: [PATCH 6/6] Minor blockcache improvement --- Core/MIPS/JitCommon/JitBlockCache.cpp | 14 ++++++++------ Core/MIPS/JitCommon/JitBlockCache.h | 3 +-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Core/MIPS/JitCommon/JitBlockCache.cpp b/Core/MIPS/JitCommon/JitBlockCache.cpp index c870426ea4..e8b751b776 100644 --- a/Core/MIPS/JitCommon/JitBlockCache.cpp +++ b/Core/MIPS/JitCommon/JitBlockCache.cpp @@ -69,8 +69,7 @@ void JitBlock::DoIntegrityCheck(u32 emAddress, int num, const char *reason) cons _assert_msg_(sentinel == SENTINEL_VAL, "%s: Block %d(%d) sentinel got corrupted: %08x != %08x (origAddr: %08x)", reason, num, blockNum, sentinel, SENTINEL_VAL, originalAddress); } -JitBlockCache::JitBlockCache(MIPSState *mipsState, CodeBlockCommon *codeBlock) : codeBlock_(codeBlock) { -} +JitBlockCache::JitBlockCache(MIPSState *mipsState, CodeBlockCommon *codeBlock) : codeBlock_(codeBlock) {} JitBlockCache::~JitBlockCache() { Shutdown(); @@ -117,7 +116,9 @@ void JitBlockCache::Reset() { int JitBlockCache::AllocateBlock(u32 startAddress) { _assert_(num_blocks_ < MAX_NUM_BLOCKS); - JitBlock &b = blocks_[num_blocks_]; + const int numBlocks = num_blocks_; + + JitBlock &b = blocks_[numBlocks]; b.invalid = false; b.originalAddress = startAddress; @@ -126,10 +127,11 @@ int JitBlockCache::AllocateBlock(u32 startAddress) { b.exitPtrs[i] = 0; b.linkStatus[i] = false; } - b.blockNum = num_blocks_; + b.blockNum = numBlocks; b.sentinel = SENTINEL_VAL; - num_blocks_++; //commit the current block - return num_blocks_ - 1; + + num_blocks_ = numBlocks + 1; //commit the current block + return numBlocks; } void JitBlockCache::AddBlockMap(int block_num) { diff --git a/Core/MIPS/JitCommon/JitBlockCache.h b/Core/MIPS/JitCommon/JitBlockCache.h index 88b63ba35a..a3ceeec387 100644 --- a/Core/MIPS/JitCommon/JitBlockCache.h +++ b/Core/MIPS/JitCommon/JitBlockCache.h @@ -191,10 +191,9 @@ private: MIPSOpcode GetEmuHackOpForBlock(int block_num) const; + int num_blocks_ = 0; CodeBlockCommon *codeBlock_; JitBlock *blocks_ = nullptr; - - int num_blocks_ = 0; std::unordered_multimap links_to_; std::map, u32> block_map_; // (end_addr, start_addr) -> number