Files
ARMSX2/common/HTTPDownloaderAndroid.h
T
David IsztlandClaude Opus 4.8 2eb9ec659c refactor: move Android frontend to platforms/android on single shared core
Snapshot the refresh-experimental Android app (Gradle + JNI + Android-only
3rdparty) into platforms/android/. Delete its vendored PCSX2 core copy and
relocate the ~24 genuinely Android-specific core additions (Oboe audio, Android
stubs, EGL-Android GL context, NEON SPU2, GSGPUProfile, VU1Fingerprint, Android
HTTP downloader) into the root core, guarded by if(ANDROID) in
pcsx2/CMakeLists.txt and common/CMakeLists.txt.

The superseded arm64 JIT experiment (arm64/mac/* IR-VU backend, split
aVU0/aDMAC/aVTLB/aR5900COP*) is dropped: the root macOS arm64 JIT (127 unique
commits, newer) is the canonical recompiler.

Rewire the Android native build to a thin CMakeLists that sources the root
{common,pcsx2,3rdparty} instead of the deleted vendored copy.

NOT yet compiled against a real NDK -- build validation is CI's job.
See REFACTOR_STATUS.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 20:29:23 +02:00

57 lines
1.8 KiB
C++

// SPDX-FileCopyrightText: 2002-2026 PCSX2 Dev Team
// SPDX-License-Identifier: GPL-3.0+
#pragma once
#include "common/HTTPDownloader.h"
#include <atomic>
#include <jni.h>
#include <memory>
#include <string>
#include <thread>
// HTTPDownloader implementation backed by Java's HttpURLConnection.
// One worker std::thread per request; the worker attaches to the JVM,
// invokes kr.co.iefriends.pcsx2.HttpClient.doRequest synchronously, and
// flips the request's atomic state to Complete on return. The base
// HTTPDownloader's poll loop owns lifecycle (state observation,
// Cancelled/Timeout transitions, callback invocation) — we just provide
// the actual transport.
//
// Why not curl? On Android we'd need to bundle libcurl + an OpenSSL/
// mbedTLS build into 3rdparty/ to get TLS — significant build-system
// surface. HttpURLConnection uses Android's system networking stack
// (system CA store, OS-managed proxy, TLS via the platform's OpenSSL),
// so this approach has zero third-party dependencies.
class HTTPDownloaderAndroid final : public HTTPDownloader
{
public:
HTTPDownloaderAndroid();
~HTTPDownloaderAndroid() override;
bool Initialize(JavaVM* jvm, std::string user_agent);
// Static one-time setup of the HttpClient class + method ID. Called
// from JNI_OnLoad / NativeApp.initialize once we have a Java env.
// Subsequent calls are no-ops.
static bool BindFromJNI(JNIEnv* env);
protected:
struct Request : HTTPDownloader::Request
{
std::thread worker;
};
HTTPDownloader::Request* InternalCreateRequest() override;
void InternalPollRequests() override;
bool StartRequest(HTTPDownloader::Request* request) override;
void CloseRequest(HTTPDownloader::Request* request) override;
private:
void RunRequest(Request* req);
JavaVM* m_jvm = nullptr;
std::string m_user_agent;
};