Skip to content

Commit

Permalink
Make naett work on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Jul 20, 2023
1 parent 06ab370 commit 3f763f0
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 4 deletions.
10 changes: 10 additions & 0 deletions Common/Net/Resolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@

#include "ext/naett/naett.h"

#if PPSSPP_PLATFORM(ANDROID)
#include <jni.h>
extern JavaVM *gJvm;
#endif

namespace net {

int g_refCount = 0;
Expand All @@ -44,7 +49,12 @@ void Init()
WSAStartup(MAKEWORD(2, 2), &wsaData);
#endif
if (g_refCount == 0) {
#if PPSSPP_PLATFORM(ANDROID)
_assert_(gJvm != nullptr);
naettInit(gJvm);
#else
naettInit(NULL);
#endif
}
g_refCount++;
}
Expand Down
1 change: 1 addition & 0 deletions Common/Render/Text/draw_text_android.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "ppsspp_config.h"

#include "Common/Log.h"
#include "Common/StringUtils.h"
#include "Common/System/Display.h"
Expand Down
13 changes: 13 additions & 0 deletions Common/System/Request.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "ppsspp_config.h"

#include <cstring>

#include "Common/System/Request.h"
Expand All @@ -6,6 +8,17 @@
#include "Common/File/Path.h"
#include "Common/TimeUtil.h"

#if PPSSPP_PLATFORM(ANDROID)

// Maybe not the most natural place for this, but not sure what would be. It needs to be in the Common project
// unless we want to make another System_ function to retrieve it.

#include <jni.h>

JavaVM *gJvm = nullptr;

#endif

RequestManager g_requestManager;

const char *RequestTypeAsString(SystemRequestType type) {
Expand Down
1 change: 1 addition & 0 deletions Common/UI/IconCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ bool IconCache::InsertIcon(const std::string &key, IconFormat format, std::strin
}

if (data.empty()) {
_dbg_assert_(false);
ERROR_LOG(G3D, "Can't insert empty data into icon cache");
return false;
}
Expand Down
3 changes: 1 addition & 2 deletions Core/Util/PortManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,14 @@ PortManager::PortManager():
m_InitState(UPNP_INITSTATE_NONE),
m_LocalPort(UPNP_LOCAL_PORT_ANY),
m_leaseDuration("43200") {
net::Init();
// Don't call net::Init or similar here, we don't want stuff like that to happen before main.
}

PortManager::~PortManager() {
// FIXME: On Windows it seems using any UPnP functions in this destructor that gets triggered when exiting PPSSPP will resulting to UPNPCOMMAND_HTTP_ERROR due to early WSACleanup (miniupnpc was getting WSANOTINITIALISED internally)
Clear();
Restore();
Terminate();
net::Shutdown();
}

void PortManager::Terminate() {
Expand Down
3 changes: 2 additions & 1 deletion android/jni/app-android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ static int desiredBackbufferSizeX;
static int desiredBackbufferSizeY;

// Cache the class loader so we can use it from native threads. Required for TextAndroid.
static JavaVM* gJvm = nullptr;
extern JavaVM *gJvm;

static jobject gClassLoader;
static jmethodID gFindClassMethod;

Expand Down
2 changes: 1 addition & 1 deletion ext/naett

0 comments on commit 3f763f0

Please sign in to comment.