Commit b9a8ea41 by Minhan Jeong

화웨이 로그인 시스템 작업중

parent 82ed0894
......@@ -145,4 +145,9 @@ KeyAlias=rmvw2021
KeyStorePassword=3df1q2w3e
KeyPassword=3df1q2w3e
ApplicationDisplayName=Real Madrid Virtual World
bBuildForArmV7=False
bBuildForArm64=True
[/Script/GooglePADEditor.GooglePADRuntimeSettings]
bOnlyDistribution=False
......@@ -14,6 +14,25 @@
{
"Name": "MobileNativeCode",
"Enabled": false
},
{
"Name": "OculusVR",
"Enabled": false,
"SupportedTargetPlatforms": [
"Win32",
"Win64",
"Android"
]
},
{
"Name": "SteamVR",
"Enabled": false,
"SupportedTargetPlatforms": [
"Win32",
"Win64",
"Linux",
"Mac"
]
}
]
}
\ No newline at end of file
......@@ -93,9 +93,17 @@
dependencies
{
ext.JUNIT_VERSION = '4.12'
ext.ESPRESSO_VERSION = '2.2.2'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.huawei.hms:iap:6.0.0.300'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation fileTree(include: ['*.jar',], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation "com.google.code.gson:gson:2.8.5"
implementation 'com.huawei.hms:hwid:5.2.0.300'
}
allprojects
......@@ -105,6 +113,16 @@
google()
jcenter()
maven {url 'http://developer.huawei.com/repo/'}
repositories
{
flatDir
{
</insert>
<insertValue value="dirs '$S(AbsPluginDir)/../aars'"/>
<insertNewline/>
<insert>
}
}
}
}
......
package com.Plugins.HuaweiSDK.activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
import com.huawei.hms.support.account.AccountAuthManager;
import com.huawei.hms.support.account.request.AccountAuthParams;
import com.huawei.hms.support.account.service.AccountAuthService;
public class AccountActivity extends activity {
private String TAG = "HuaweiAccountActivity";
private AccountAuthService mAuthManager;
private AccountAuthParams mAuthParam;
private Activity mActivity;
public AccountActivity(Activity activity) {
mActivity = activity;
}
private void signIn() {
mAuthParam = new AccountAuthParamsHelper(AccountAuthParams.DEFAULT_AUTH_REQUEST_PARAM)
.setIdToken()
.setAccessToken()
.createParams();
mAuthManager = AccountAuthManager.getService(mActivity, mAuthParam);
startActivityForResult(mAuthManager.getSignInIntent(), Constant.REQUEST_SIGN_IN_LOGIN);
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// if (requestCode == Constant.REQUEST_SIGN_IN_LOGIN) {
if (requestCode == 1002) {
//login success
//get user message by parseAuthResultFromIntent
Task<AuthAccount> authAccountTask = AccountAuthManager.parseAuthResultFromIntent(data);
if (authAccountTask.isSuccessful()) {
AuthAccount authAccount = authAccountTask.getResult();
Log.i(TAG, authAccount.getDisplayName() + " signIn success ");
Log.i(TAG, "AccessToken: " + authAccount.getAccessToken());
nativeSignInResult(true, authAccount.getAccessToken());
} else {
Log.i(TAG, "signIn failed: " + ((ApiException) authAccountTask.getException()).getStatusCode());
nativeSignInResult(false, 0);
}
}
if (requestCode == Constant.REQUEST_SIGN_IN_LOGIN_CODE) {
//login success
Task<AuthAccount> authAccountTask = AccountAuthManager.parseAuthResultFromIntent(data);
if (authAccountTask.isSuccessful()) {
AuthAccount authAccount = authAccountTask.getResult();
Log.i(TAG, "signIn get code success.");
Log.i(TAG, "ServerAuthCode: " + authAccount.getAuthorizationCode());
/**** english doc:For security reasons, the operation of changing the code to an AT must be performed on your server. The code is only an example and cannot be run. ****/
/**********************************************************************************************/
} else {
Log.i(TAG, "signIn get code failed: " + ((ApiException) authAccountTask.getException()).getStatusCode());
}
}
}
public native void nativeSignInResult(boolean success, String accessToken);
}
\ No newline at end of file
#include "HuaweiAccount.h"
using namespace std;
#if PLATFORM_ANDROID
#include "Android/Utils/AndroidUtils.h"
#include "Android/AndroidJNI.h"
#endif
#include <set>
#pragma region SignIn
static std::set<UHuaweiAccount*> s_huaweiAccounts;
UHuaweiAccount::UHuaweiAccount(){}
UHuaweiAccount::~UHuaweiAccount()
{
std::set<UHuaweiAccount*>::iterator it = s_huaweiAccounts.find(this);
if (it != s_huaweiAccounts.end())
{
s_huaweiAccounts.erase(it);
}
}
UHuaweiAccount* UHuaweiAccount::SignIn()
{
UHuaweiAccount* BPNode = NewObject<UHuaweiAccount>();
s_huaweiAccounts.insert(BPNode);
return BPNode;
}
#if PLATFORM_ANDROID
static void ReqSignIn()
{
if (JNIEnv* Env = FAndroidApplication::GetJavaEnv())
{
static jmethodID SignInMethod = FJavaWrapper::FindMethod(Env, FJavaWrapper::GameActivityClassID, "AndroidThunkJava_SignIn", "()V", false);
if (SignInMethod)
{
FJavaWrapper::CallVoidMethod(Env, FJavaWrapper::GameActivityThis, SignInMethod);
}
}
}
__attribute__((visibility("default"))) extern "C" void Java_com_Plugins_HuaweiSDK_activity_AccountActivity_nativeSignInResult(JNIEnv* jenv, jobject thiz, jboolean success, jstring accessToekn)
{
UE_LOG(LogTemp, Log, TEXT("nativeSignInResult"));
const char* charsAccessToken = jenv->GetStringUTFChars(accessToekn, 0);
FString strAccessToken = FString(UTF8_TO_TCHAR(charsAccessToken));
DECLARE_CYCLE_STAT(TEXT("FSimpleDelegateGraphTask.Java_com_Plugins_HuaweiSDK_activity_AccountActivity_nativeSignInResult"), STAT_FSimpleDelegateGraphTask_Java_com_Plugins_HuaweiSDK_activity_AccountActivity_nativeSignInResult, STATGROUP_TaskGraphTasks);
FSimpleDelegateGraphTask::CreateAndDispatchWhenReady(
FSimpleDelegateGraphTask::FDelegate::CreateLambda([=]()
{
if (strAccessToken.Len() > 0)
{
for (std::set<UHuaweiAccount*>::iterator it = s_huaweiAccounts.begin(); it != s_huaweiAccounts.end(); it++)
{
(*it)->OnComplete.Broadcast(true, strAccessToken);
}
}
else
{
for (std::set<UHuaweiAccount*>::iterator it = s_huaweiAccounts.begin(); it != s_huaweiAccounts.end(); it++)
{
(*it)->OnComplete.Broadcast(false, "");
}
}
s_huaweiAccounts.clear();
}),
GET_STATID(STAT_FSimpleDelegateGraphTask_Java_com_Plugins_HuaweiSDK_activity_AccountActivity_nativeSignInResult),
nullptr,
ENamedThreads::GameThread
);
}
#endif
void UHuaweiAccount::Activate()
{
#if PLATFORM_ANDROID
ReqSignIn();
#endif
}
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintAsyncActionBase.h"
#include "HuaweiAccount.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FSignInResult, bool, IsSuccess, FString, AccessToken);
UCLASS(Category = "Huawei Account", meta = (DisplayName = "Huawei Account"))
class HUAWEISDK_API UHuaweiAccount : public UBlueprintAsyncActionBase
{
GENERATED_BODY()
public:
UHuaweiAccount();
~UHuaweiAccount();
UFUNCTION(BlueprintCallable, meta=(BlueprintINternalUseOnly="true"), Category="HuaweiAccount")
static UHuaweiAccount* SignIn();
virtual void Activate() override;
UPROPERTY(BlueprintAssignable)
FSignInResult OnComplete;
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment