Merge pull request #152 from amnezia-vpn/feature/android_qt6_moving
Moving to Qt 6 and cmake on Android client
This commit is contained in:
commit
18d89e9cad
39 changed files with 1267 additions and 573 deletions
|
@ -3,10 +3,6 @@
|
|||
#include "ui/uilogic.h"
|
||||
#include "ui/pages_logic/StartPageLogic.h"
|
||||
|
||||
#if defined(Q_OS_ANDROID)
|
||||
#include "android_controller.h"
|
||||
#endif
|
||||
|
||||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include "vpnconnection.h"
|
||||
|
||||
#include "../uilogic.h"
|
||||
#include "ServerListLogic.h"
|
||||
#include "ShareConnectionLogic.h"
|
||||
#include "VpnLogic.h"
|
||||
|
||||
|
@ -11,9 +10,7 @@
|
|||
#include <QTimer>
|
||||
|
||||
#if defined(Q_OS_ANDROID)
|
||||
#include <QAndroidJniObject>
|
||||
#include <QAndroidJniEnvironment>
|
||||
#include <QtAndroid>
|
||||
#include "../../platforms/android/androidutils.h"
|
||||
#endif
|
||||
|
||||
ServerSettingsLogic::ServerSettingsLogic(UiLogic *logic, QObject *parent):
|
||||
|
@ -24,9 +21,7 @@ ServerSettingsLogic::ServerSettingsLogic(UiLogic *logic, QObject *parent):
|
|||
m_pushButtonShareFullVisible{true},
|
||||
m_pushButtonClearText{tr("Clear server from Amnezia software")},
|
||||
m_pushButtonClearClientCacheText{tr("Clear client cached profile")}
|
||||
{
|
||||
|
||||
}
|
||||
{ }
|
||||
|
||||
void ServerSettingsLogic::onUpdatePage()
|
||||
{
|
||||
|
@ -140,7 +135,7 @@ void ServerSettingsLogic::onLineEditDescriptionEditingFinished()
|
|||
|
||||
#if defined(Q_OS_ANDROID)
|
||||
/* Auth result handler for Android */
|
||||
void authResultReceiver::handleActivityResult(int receiverRequestCode, int resultCode, const QAndroidJniObject &data)
|
||||
void authResultReceiver::handleActivityResult(int receiverRequestCode, int resultCode, const QJniObject &data)
|
||||
{
|
||||
qDebug() << "receiverRequestCode" << receiverRequestCode << "resultCode" << resultCode;
|
||||
|
||||
|
@ -155,16 +150,17 @@ void ServerSettingsLogic::onPushButtonShareFullClicked()
|
|||
{
|
||||
#if defined(Q_OS_ANDROID)
|
||||
/* We use builtin keyguard for ssh key export protection on Android */
|
||||
auto appContext = QtAndroid::androidActivity().callObjectMethod(
|
||||
QJniObject activity = AndroidUtils::getActivity();
|
||||
auto appContext = activity.callObjectMethod(
|
||||
"getApplicationContext", "()Landroid/content/Context;");
|
||||
if (appContext.isValid()) {
|
||||
QAndroidActivityResultReceiver *receiver = new authResultReceiver(uiLogic(), uiLogic()->selectedServerIndex);
|
||||
auto intent = QAndroidJniObject::callStaticObjectMethod(
|
||||
auto intent = QJniObject::callStaticObjectMethod(
|
||||
"org/amnezia/vpn/AuthHelper", "getAuthIntent",
|
||||
"(Landroid/content/Context;)Landroid/content/Intent;", appContext.object());
|
||||
if (intent.isValid()) {
|
||||
if (intent.object<jobject>() != nullptr) {
|
||||
QtAndroid::startActivity(intent.object<jobject>(), 1, receiver);
|
||||
QtAndroidPrivate::startActivity(intent.object<jobject>(), 1, receiver);
|
||||
}
|
||||
} else {
|
||||
uiLogic()->pageLogic<ShareConnectionLogic>()->updateSharingPage(uiLogic()->selectedServerIndex, DockerContainer::None);
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
#include "PageLogicBase.h"
|
||||
|
||||
#if defined(Q_OS_ANDROID)
|
||||
#include <QAndroidActivityResultReceiver>
|
||||
#include <QJniObject>
|
||||
#include <private/qandroidextras_p.h>
|
||||
#endif
|
||||
|
||||
class UiLogic;
|
||||
|
@ -52,7 +53,7 @@ public:
|
|||
~authResultReceiver() {}
|
||||
|
||||
public:
|
||||
void handleActivityResult(int receiverRequestCode, int resultCode, const QAndroidJniObject &data) override;
|
||||
void handleActivityResult(int receiverRequestCode, int resultCode, const QJniObject &data) override;
|
||||
|
||||
private:
|
||||
int m_serverIndex;
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
#include <QStandardPaths>
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
#include <QtAndroid>
|
||||
#include "platforms/android/android_controller.h"
|
||||
#include <QJniObject>
|
||||
#include "../../platforms/android/androidutils.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
@ -56,8 +56,9 @@ StartPageLogic::StartPageLogic(UiLogic *logic, QObject *parent):
|
|||
{
|
||||
#ifdef Q_OS_ANDROID
|
||||
// Set security screen for Android app
|
||||
QtAndroid::runOnAndroidThread([]() {
|
||||
QAndroidJniObject window = QtAndroid::androidActivity().callObjectMethod("getWindow", "()Landroid/view/Window;");
|
||||
AndroidUtils::runOnAndroidThreadSync([]() {
|
||||
QJniObject activity = AndroidUtils::getActivity();
|
||||
QJniObject window = activity.callObjectMethod("getWindow", "()Landroid/view/Window;");
|
||||
if (window.isValid()){
|
||||
const int FLAG_SECURE = 8192;
|
||||
window.callMethod<void>("addFlags", "(I)V", FLAG_SECURE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue