Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First-boot memstick screen: Attempt to fix some logic holes #17701

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Core/FileSystems/ISOFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ void ISOFileSystem::ReadDirectory(TreeEntry *root) {
// Round down to avoid any false reports.
if (isFile && dir.firstDataSector + (dir.dataLength / 2048) > blockDevice->GetNumBlocks()) {
blockDevice->NotifyReadError();
ERROR_LOG(FILESYS, "File '%s' starts or ends outside ISO. firstDataSector: %d len: %d", entry->BuildPath().c_str(), dir.firstDataSector, dir.dataLength);
ERROR_LOG(FILESYS, "File '%s' starts or ends outside ISO. firstDataSector: %d len: %d", entry->BuildPath().c_str(), (int)dir.firstDataSector, (int)dir.dataLength);
}

if (entry->isDirectory && !relative) {
Expand Down
19 changes: 7 additions & 12 deletions UI/MemStickScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "Common/System/Request.h"
#include "Common/System/NativeApp.h"
#include "Common/System/Display.h"
#include "Common/System/OSD.h"
#include "Common/Data/Text/I18n.h"
#include "Common/Data/Text/Parsers.h"

Expand Down Expand Up @@ -227,17 +228,14 @@ void MemStickScreen::CreateViews() {
// For legacy Android systems, so you can switch back to the old ways if you move to SD or something.
// Trying to avoid needing a scroll view, so only showing the explanation for one option at a time.

#if PPSSPP_PLATFORM(ANDROID)
if (!System_GetPropertyBool(SYSPROP_ANDROID_SCOPED_STORAGE)) {
leftColumn->Add(new RadioButton(&choice_, CHOICE_STORAGE_ROOT, iz->T("Use PSP folder at root of storage")))->OnClick.Handle(this, &MemStickScreen::OnChoiceClick);
if (choice_ == CHOICE_STORAGE_ROOT) {
AddExplanation(leftColumn, (MemStickScreen::Choice)choice_);
}
}
#endif

if (storageBrowserWorking_) {
//ImageID("I_FOLDER_OPEN")
leftColumn->Add(new RadioButton(&choice_, CHOICE_BROWSE_FOLDER, iz->T("Create or Choose a PSP folder")))->OnClick.Handle(this, &MemStickScreen::OnChoiceClick);

// TODO: Show current folder here if we have one set.
Expand Down Expand Up @@ -447,19 +445,16 @@ UI::EventReturn MemStickScreen::UseStorageRoot(UI::EventParams &params) {
UI::EventReturn MemStickScreen::Browse(UI::EventParams &params) {
auto mm = GetI18NCategory(I18NCat::MAINMENU);
System_BrowseForFolder(mm->T("Choose folder"), [=](const std::string &value, int) {
std::string filename;
filename = value;
INFO_LOG(SYSTEM, "Got folder: '%s'", filename.c_str());

Path pendingMemStickFolder = Path(value);
INFO_LOG(SYSTEM, "Got folder: '%s'", pendingMemStickFolder.c_str());
// Browse finished. Let's pop up the confirmation dialog.
Path pendingMemStickFolder = Path(filename);

if (pendingMemStickFolder == g_Config.memStickDirectory) {
if (!pendingMemStickFolder.empty() && pendingMemStickFolder == g_Config.memStickDirectory && File::IsDirectory(pendingMemStickFolder)) {
auto iz = GetI18NCategory(I18NCat::MEMSTICK);
// Not sure how this could happen, but let's go with it.
g_OSD.Show(OSDType::MESSAGE_SUCCESS, iz->T("Done!"));
done_ = true;
return;
}

bool existingFiles = FolderSeemsToBeUsed(pendingMemStickFolder);
screenManager()->push(new ConfirmMemstickMoveScreen(pendingMemStickFolder, initialSetup_));
});
return UI::EVENT_DONE;
Expand Down
12 changes: 10 additions & 2 deletions android/jni/app-android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1095,10 +1095,18 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_sendRequestResult(JNIEnv *env, jclass, jint jrequestID, jboolean result, jstring jvalue, jint jintValue) {
std::string value = GetJavaString(env, jvalue);

static jint lastSeqID = -1;
INFO_LOG(SYSTEM, "Received result of request %d from Java: %d: %d '%s'", jrequestID, (int)result, jintValue, value.c_str());

if (jrequestID == -1) {
// Sanity check. This shouldn't happen.
ERROR_LOG(SYSTEM, "Unexpected request id %d", jrequestID);
System_Toast("Bad request ID -1");
}

static jint lastSeqID = -1337;
if (lastSeqID == jrequestID) {
// We send this on dismiss, so twice in many cases.
WARN_LOG(SYSTEM, "Ignoring duplicate sendInputBox");
WARN_LOG(SYSTEM, "Ignoring duplicate sendRequestResult");
return;
}
lastSeqID = jrequestID;
Expand Down
4 changes: 4 additions & 0 deletions android/src/org/ppsspp/ppsspp/NativeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,10 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}
fileRequestId = -1;
} else if (requestCode == RESULT_OPEN_DOCUMENT_TREE) {
if (folderRequestId == -1) {
Log.e(TAG, "Unexpected request ID -1");
}

if (resultCode != RESULT_OK || data == null) {
NativeApp.sendRequestResult(folderRequestId, false, "", 0);
folderRequestId = -1;
Expand Down