From e0169062eeb8edd0f528b073123e23826640ca67 Mon Sep 17 00:00:00 2001 From: qiuguohua Date: Thu, 28 Nov 2024 14:52:47 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81Name=20change=20from=20billing=20to?= =?UTF-8?q?=20GoogleBilling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- @types/jsb.d.ts | 2 +- editor/engine-features/render-config.json | 2 +- exports/vendor.ts | 2 +- native/CMakeLists.txt | 22 +-- ...jsb_billing.cpp => jsb_google_billing.cpp} | 164 +++++++++--------- .../bindings/manual/jsb_module_register.cpp | 2 +- .../billing/GoogleBilling.java} | 38 ++-- .../billing/GoogleBillingHelper.java} | 12 +- .../platform/android/libcocos2dx/build.gradle | 4 +- .../modules/google_play/billing/billing.cpp | 116 ------------- .../platform/java/jni/JniCocosBilling.cpp | 112 ------------ .../java/jni/JniGoogleBillingHandler.cpp | 112 ++++++++++++ .../vendor/google/billing/GoogleBilling.cpp | 116 +++++++++++++ .../google/billing/GoogleBilling.h} | 8 +- .../google/billing/GoogleBillingHelper.cpp} | 152 ++++++++-------- .../google/billing/GoogleBillingHelper.h} | 2 +- .../source/platforms/google-play.ts | 42 +++++ templates/google-play/build/gradle.properties | 2 +- vendor/google/{play => }/billing/billing.ts | 60 +++---- vendor/google/{play => }/index.ts | 0 20 files changed, 506 insertions(+), 464 deletions(-) rename native/cocos/bindings/manual/{jsb_billing.cpp => jsb_google_billing.cpp} (89%) rename native/cocos/platform/android/java/vendor/{com/cocos/billing/CocosBilling.java => google/billing/GoogleBilling.java} (91%) rename native/cocos/platform/android/java/vendor/{com/cocos/billing/CocosBillingHelper.java => google/billing/GoogleBillingHelper.java} (97%) delete mode 100644 native/cocos/platform/android/modules/google_play/billing/billing.cpp delete mode 100644 native/cocos/platform/java/jni/JniCocosBilling.cpp create mode 100644 native/cocos/platform/java/jni/JniGoogleBillingHandler.cpp create mode 100644 native/vendor/google/billing/GoogleBilling.cpp rename native/{cocos/platform/android/modules/google_play/billing/billing.h => vendor/google/billing/GoogleBilling.h} (94%) rename native/{cocos/platform/android/modules/google_play/billing/JniBillingHelper.cpp => vendor/google/billing/GoogleBillingHelper.cpp} (76%) rename native/{cocos/platform/android/modules/google_play/billing/JniBillingHelper.h => vendor/google/billing/GoogleBillingHelper.h} (99%) rename vendor/google/{play => }/billing/billing.ts (91%) rename vendor/google/{play => }/index.ts (100%) diff --git a/@types/jsb.d.ts b/@types/jsb.d.ts index 11262fdd1e6..418b3ec8394 100644 --- a/@types/jsb.d.ts +++ b/@types/jsb.d.ts @@ -717,7 +717,7 @@ declare namespace jsb { * @en Main interface for communication between the Google Play library and user application code. * @zh 产品 ID。 */ - const billing: { + const googleBilling: { /** * @en Starts up BillingClient setup process asynchronously. * @zh 异步启动 BillingClient 设置过程。 diff --git a/editor/engine-features/render-config.json b/editor/engine-features/render-config.json index 727b933afc3..d121ba7a9d5 100644 --- a/editor/engine-features/render-config.json +++ b/editor/engine-features/render-config.json @@ -318,7 +318,7 @@ "description": "i18n:ENGINE.features.vendor.description", "enginePlugin": false, "isNativeModule": true, - "cmakeConfig": "USE_GOOGLE_PLAY_BILLING", + "cmakeConfig": "USE_GOOGLE_BILLING", "hidden": true }, "spine": { diff --git a/exports/vendor.ts b/exports/vendor.ts index e9aea6db849..e6ca3a50a09 100644 --- a/exports/vendor.ts +++ b/exports/vendor.ts @@ -23,4 +23,4 @@ THE SOFTWARE. */ -export * from '../vendor/google/play'; +export * from '../vendor/google'; diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt index 870e9714e60..b001e9cdba7 100644 --- a/native/CMakeLists.txt +++ b/native/CMakeLists.txt @@ -48,7 +48,7 @@ cc_set_if_undefined(USE_WEBP ON) cc_set_if_undefined(NET_MODE 0) # 0 is client cc_set_if_undefined(USE_REMOTE_LOG OFF) cc_set_if_undefined(USE_ADPF OFF) -cc_set_if_undefined(USE_GOOGLE_PLAY_BILLING OFF) +cc_set_if_undefined(USE_GOOGLE_BILLING OFF) if(ANDROID AND NOT DEFINED USE_CCACHE) if("$ENV{COCOS_USE_CCACHE}" STREQUAL "1") @@ -760,12 +760,12 @@ elseif(ANDROID OR OHOS) endif() endif() -if(USE_GOOGLE_PLAY_BILLING) +if(USE_GOOGLE_BILLING) cocos_source_files( - cocos/platform/android/modules/google_play/billing/billing.cpp - cocos/platform/android/modules/google_play/billing/billing.h - cocos/platform/android/modules/google_play/billing/JniBillingHelper.cpp - cocos/platform/android/modules/google_play/billing/JniBillingHelper.h + vendor/google/billing/GoogleBilling.cpp + vendor/google/billing/GoogleBilling.h + vendor/google/billing/GoogleBillingHelper.cpp + vendor/google/billing/GoogleBillingHelper.h ) endif() @@ -1194,8 +1194,8 @@ elseif(LINUX) ) endif() -if(USE_GOOGLE_PLAY_BILLING) - list(APPEND CC_JNI_SRC_FILES ${CWD}/cocos/platform/java/jni/JniCocosBilling.cpp) +if(USE_GOOGLE_BILLING) + list(APPEND CC_JNI_SRC_FILES ${CWD}/cocos/platform/java/jni/JniGoogleBillingHandler.cpp) endif() ##### renderer @@ -2608,9 +2608,9 @@ if(USE_ADPF) ) endif() -if(USE_GOOGLE_PLAY_BILLING) +if(USE_GOOGLE_BILLING) cocos_source_files( - cocos/bindings/manual/jsb_billing.cpp + cocos/bindings/manual/jsb_google_billing.cpp ) endif() @@ -3147,7 +3147,7 @@ function(cc_apply_definations target) $<$:SCRIPT_ENGINE_TYPE=6> $<$,$>:CC_DEBUG=1> $,CC_USE_APDF=1,CC_USE_USE_APDF=0> - $,CC_USE_GOOGLE_PLAY_BILLING=1,CC_USE_GOOGLE_PLAY_BILLING=0> + $,CC_USE_GOOGLE_BILLING=1,CC_USE_GOOGLE_BILLING=0> ) endfunction() diff --git a/native/cocos/bindings/manual/jsb_billing.cpp b/native/cocos/bindings/manual/jsb_google_billing.cpp similarity index 89% rename from native/cocos/bindings/manual/jsb_billing.cpp rename to native/cocos/bindings/manual/jsb_google_billing.cpp index 6a772ccd39a..9321269fbb3 100644 --- a/native/cocos/bindings/manual/jsb_billing.cpp +++ b/native/cocos/bindings/manual/jsb_google_billing.cpp @@ -29,7 +29,7 @@ #include "bindings/jswrapper/SeApi.h" #include "bindings/manual/jsb_conversions.h" #include "bindings/manual/jsb_global.h" - #include "cocos/platform/android/modules/google_play/billing/billing.h" + #include "vendor/google/billing/GoogleBilling.h" JSB_REGISTER_OBJECT_TYPE(cc::BillingResult); JSB_REGISTER_OBJECT_TYPE(cc::OneTimePurchaseOfferDetails); JSB_REGISTER_OBJECT_TYPE(cc::InstallmentPlanDetails); @@ -40,7 +40,7 @@ JSB_REGISTER_OBJECT_TYPE(cc::AccountIdentifiers); JSB_REGISTER_OBJECT_TYPE(cc::PendingPurchaseUpdate); JSB_REGISTER_OBJECT_TYPE(cc::Purchase); JSB_REGISTER_OBJECT_TYPE(cc::BillingConfig); -JSB_REGISTER_OBJECT_TYPE(cc::Billing); +JSB_REGISTER_OBJECT_TYPE(cc::GoogleBilling); #endif @@ -1204,35 +1204,35 @@ bool js_register_cc_BillingConfig(se::Object* obj) { // NOLINT return true; } -SE_DECLARE_FINALIZE_FUNC(js_delete_cc_Billing) +SE_DECLARE_FINALIZE_FUNC(js_delete_cc_Google_Billing) -static bool js_cc_Billing_startConnection(se::State& s) { // NOLINT - cc::Billing::getInstance().startConnection(); +static bool js_cc_Google_Billing_startConnection(se::State& s) { // NOLINT + cc::GoogleBilling::getInstance().startConnection(); return true; } -SE_BIND_FUNC(js_cc_Billing_startConnection) +SE_BIND_FUNC(js_cc_Google_Billing_startConnection) -static bool js_cc_Billing_endConnection(se::State& s) { // NOLINT - cc::Billing::getInstance().endConnection(); +static bool js_cc_Google_Billing_endConnection(se::State& s) { // NOLINT + cc::GoogleBilling::getInstance().endConnection(); return true; } -SE_BIND_FUNC(js_cc_Billing_endConnection) +SE_BIND_FUNC(js_cc_Google_Billing_endConnection) -static bool js_cc_Billing_getConnectionState(se::State& s) { // NOLINT - int connectionState = cc::Billing::getInstance().getConnectionState(); +static bool js_cc_Google_Billing_getConnectionState(se::State& s) { // NOLINT + int connectionState = cc::GoogleBilling::getInstance().getConnectionState(); s.rval().setFloat(connectionState); return true; } -SE_BIND_FUNC(js_cc_Billing_getConnectionState) +SE_BIND_FUNC(js_cc_Google_Billing_getConnectionState) -static bool js_cc_Billing_isReady(se::State& s) { - int isReady = cc::Billing::getInstance().isReady(); +static bool js_cc_Google_Billing_isReady(se::State& s) { + int isReady = cc::GoogleBilling::getInstance().isReady(); s.rval().setFloat(isReady); return true; } -SE_BIND_FUNC(js_cc_Billing_isReady) +SE_BIND_FUNC(js_cc_Google_Billing_isReady) -static bool js_cc_Billing_queryProductDetailsParams(se::State& s) { // NOLINT +static bool js_cc_Google_Billing_queryProductDetailsParams(se::State& s) { // NOLINT CC_UNUSED bool ok = true; const auto& args = s.args(); size_t argc = args.size(); @@ -1250,12 +1250,12 @@ static bool js_cc_Billing_queryProductDetailsParams(se::State& s) { // NOLINT SE_PRECONDITION2(ok, false, "Error processing arguments"); arg3 = &temp3; - cc::Billing::getInstance().queryProductDetailsParams((std::vector const&)*arg2, (std::string const&)*arg3); + cc::GoogleBilling::getInstance().queryProductDetailsParams((std::vector const&)*arg2, (std::string const&)*arg3); return true; } -SE_BIND_FUNC(js_cc_Billing_queryProductDetailsParams) +SE_BIND_FUNC(js_cc_Google_Billing_queryProductDetailsParams) -static bool js_cc_Billing_launchBillingFlow(se::State& s) { // NOLINT +static bool js_cc_Google_Billing_launchBillingFlow(se::State& s) { // NOLINT CC_UNUSED bool ok = true; const auto& args = s.args(); size_t argc = args.size(); @@ -1278,13 +1278,13 @@ static bool js_cc_Billing_launchBillingFlow(se::State& s) { // NOLINT SE_PRECONDITION2(ok, false, "Error processing arguments"); arg3 = &temp3; - cc::Billing::getInstance().launchBillingFlow((std::vector const&)*arg2, (std::string const&)*arg3); + cc::GoogleBilling::getInstance().launchBillingFlow((std::vector const&)*arg2, (std::string const&)*arg3); return true; } -SE_BIND_FUNC(js_cc_Billing_launchBillingFlow) +SE_BIND_FUNC(js_cc_Google_Billing_launchBillingFlow) -static bool js_cc_Billing_consumePurchases(se::State& s) { // NOLINT +static bool js_cc_Google_Billing_consumePurchases(se::State& s) { // NOLINT CC_UNUSED bool ok = true; const auto& args = s.args(); size_t argc = args.size(); @@ -1300,13 +1300,13 @@ static bool js_cc_Billing_consumePurchases(se::State& s) { // NOLINT SE_PRECONDITION2(ok, false, "Error processing arguments"); arg2 = &temp2; - cc::Billing::getInstance().consumePurchases((std::vector const&)*arg2); + cc::GoogleBilling::getInstance().consumePurchases((std::vector const&)*arg2); return true; } -SE_BIND_FUNC(js_cc_Billing_consumePurchases) +SE_BIND_FUNC(js_cc_Google_Billing_consumePurchases) -static bool js_cc_Billing_acknowledgePurchase(se::State& s) { // NOLINT +static bool js_cc_Google_Billing_acknowledgePurchase(se::State& s) { // NOLINT CC_UNUSED bool ok = true; const auto& args = s.args(); size_t argc = args.size(); @@ -1322,13 +1322,13 @@ static bool js_cc_Billing_acknowledgePurchase(se::State& s) { // NOLINT SE_PRECONDITION2(ok, false, "Error processing arguments"); arg1 = &temp2; - cc::Billing::getInstance().acknowledgePurchase((std::vector const&)*arg1); + cc::GoogleBilling::getInstance().acknowledgePurchase((std::vector const&)*arg1); return true; } -SE_BIND_FUNC(js_cc_Billing_acknowledgePurchase) +SE_BIND_FUNC(js_cc_Google_Billing_acknowledgePurchase) -static bool js_cc_Billing_queryPurchasesAsync(se::State& s) { // NOLINT +static bool js_cc_Google_Billing_queryPurchasesAsync(se::State& s) { // NOLINT CC_UNUSED bool ok = true; const auto& args = s.args(); size_t argc = args.size(); @@ -1344,43 +1344,43 @@ static bool js_cc_Billing_queryPurchasesAsync(se::State& s) { // NOLINT SE_PRECONDITION2(ok, false, "Error processing arguments"); arg2 = &temp2; - cc::Billing::getInstance().queryPurchasesAsync((std::string const&)*arg2); + cc::GoogleBilling::getInstance().queryPurchasesAsync((std::string const&)*arg2); return true; } -SE_BIND_FUNC(js_cc_Billing_queryPurchasesAsync) +SE_BIND_FUNC(js_cc_Google_Billing_queryPurchasesAsync) -static bool js_cc_Billing_getBillingConfigAsync(se::State& s) { // NOLINT - cc::Billing::getInstance().getBillingConfigAsync(); +static bool js_cc_Google_Billing_getBillingConfigAsync(se::State& s) { // NOLINT + cc::GoogleBilling::getInstance().getBillingConfigAsync(); return true; } -SE_BIND_FUNC(js_cc_Billing_getBillingConfigAsync) +SE_BIND_FUNC(js_cc_Google_Billing_getBillingConfigAsync) -static bool js_cc_Billing_createAlternativeBillingOnlyReportingDetailsAsync(se::State& s) { // NOLINT - cc::Billing::getInstance().createAlternativeBillingOnlyReportingDetailsAsync(); +static bool js_cc_Google_Billing_createAlternativeBillingOnlyReportingDetailsAsync(se::State& s) { // NOLINT + cc::GoogleBilling::getInstance().createAlternativeBillingOnlyReportingDetailsAsync(); return true; } -SE_BIND_FUNC(js_cc_Billing_createAlternativeBillingOnlyReportingDetailsAsync) +SE_BIND_FUNC(js_cc_Google_Billing_createAlternativeBillingOnlyReportingDetailsAsync) -static bool js_cc_Billing_isAlternativeBillingOnlyAvailableAsync(se::State& s) { // NOLINT - cc::Billing::getInstance().isAlternativeBillingOnlyAvailableAsync(); +static bool js_cc_Google_Billing_isAlternativeBillingOnlyAvailableAsync(se::State& s) { // NOLINT + cc::GoogleBilling::getInstance().isAlternativeBillingOnlyAvailableAsync(); return true; } -SE_BIND_FUNC(js_cc_Billing_isAlternativeBillingOnlyAvailableAsync) +SE_BIND_FUNC(js_cc_Google_Billing_isAlternativeBillingOnlyAvailableAsync) -static bool js_cc_Billing_createExternalOfferReportingDetailsAsync(se::State& s) { // NOLINT - cc::Billing::getInstance().createExternalOfferReportingDetailsAsync(); +static bool js_cc_Google_Billing_createExternalOfferReportingDetailsAsync(se::State& s) { // NOLINT + cc::GoogleBilling::getInstance().createExternalOfferReportingDetailsAsync(); return true; } -SE_BIND_FUNC(js_cc_Billing_createExternalOfferReportingDetailsAsync) +SE_BIND_FUNC(js_cc_Google_Billing_createExternalOfferReportingDetailsAsync) -static bool js_cc_Billing_isExternalOfferAvailableAsync(se::State& s) { // NOLINT - cc::Billing::getInstance().isExternalOfferAvailableAsync(); +static bool js_cc_Google_Billing_isExternalOfferAvailableAsync(se::State& s) { // NOLINT + cc::GoogleBilling::getInstance().isExternalOfferAvailableAsync(); return true; } -SE_BIND_FUNC(js_cc_Billing_isExternalOfferAvailableAsync) +SE_BIND_FUNC(js_cc_Google_Billing_isExternalOfferAvailableAsync) -static bool js_cc_Billing_isFeatureSupported(se::State& s) { // NOLINT +static bool js_cc_Google_Billing_isFeatureSupported(se::State& s) { // NOLINT CC_UNUSED bool ok = true; const auto& args = s.args(); size_t argc = args.size(); @@ -1394,74 +1394,74 @@ static bool js_cc_Billing_isFeatureSupported(se::State& s) { // NOLINT ok &= sevalue_to_native(args[0], &temp2, s.thisObject()); SE_PRECONDITION2(ok, false, "Error processing arguments"); - cc::BillingResult* result = cc::Billing::getInstance().isFeatureSupported(temp2); + cc::BillingResult* result = cc::GoogleBilling::getInstance().isFeatureSupported(temp2); ok &= nativevalue_to_se(*result, s.rval(), s.thisObject()); SE_PRECONDITION2(ok, false, "Error processing arguments"); return true; } -SE_BIND_FUNC(js_cc_Billing_isFeatureSupported) +SE_BIND_FUNC(js_cc_Google_Billing_isFeatureSupported) -static bool js_cc_Billing_showAlternativeBillingOnlyInformationDialog(se::State& s) { // NOLINT +static bool js_cc_Google_Billing_showAlternativeBillingOnlyInformationDialog(se::State& s) { // NOLINT CC_UNUSED bool ok = true; - cc::BillingResult* result = cc::Billing::getInstance().showAlternativeBillingOnlyInformationDialog(); + cc::BillingResult* result = cc::GoogleBilling::getInstance().showAlternativeBillingOnlyInformationDialog(); ok &= nativevalue_to_se(*result, s.rval(), s.thisObject()); SE_PRECONDITION2(ok, false, "Error processing arguments"); return true; } -SE_BIND_FUNC(js_cc_Billing_showAlternativeBillingOnlyInformationDialog) +SE_BIND_FUNC(js_cc_Google_Billing_showAlternativeBillingOnlyInformationDialog) -static bool js_cc_Billing_showExternalOfferInformationDialog(se::State& s) { // NOLINT +static bool js_cc_Google_Billing_showExternalOfferInformationDialog(se::State& s) { // NOLINT CC_UNUSED bool ok = true; - cc::BillingResult* result = cc::Billing::getInstance().showExternalOfferInformationDialog(); + cc::BillingResult* result = cc::GoogleBilling::getInstance().showExternalOfferInformationDialog(); ok &= nativevalue_to_se(*result, s.rval(), s.thisObject()); SE_PRECONDITION2(ok, false, "Error processing arguments"); return true; } -SE_BIND_FUNC(js_cc_Billing_showExternalOfferInformationDialog) +SE_BIND_FUNC(js_cc_Google_Billing_showExternalOfferInformationDialog) -static bool js_cc_Billing_showInAppMessages(se::State& s) { // NOLINT +static bool js_cc_Google_Billing_showInAppMessages(se::State& s) { // NOLINT CC_UNUSED bool ok = true; - cc::BillingResult* result = cc::Billing::getInstance().showInAppMessages(); + cc::BillingResult* result = cc::GoogleBilling::getInstance().showInAppMessages(); ok &= nativevalue_to_se(*result, s.rval(), s.thisObject()); SE_PRECONDITION2(ok, false, "Error processing arguments"); return true; } -SE_BIND_FUNC(js_cc_Billing_showInAppMessages) +SE_BIND_FUNC(js_cc_Google_Billing_showInAppMessages) -static bool js_delete_cc_Billing(se::State& s) { // NOLINT +static bool js_delete_cc_Google_Billing(se::State& s) { // NOLINT return true; } -SE_BIND_FINALIZE_FUNC(js_delete_cc_Billing) +SE_BIND_FINALIZE_FUNC(js_delete_cc_Google_Billing) -bool js_register_cc_Billing(se::Object* obj) { // NOLINT - se::Value billingVal{se::Object::createPlainObject()}; - auto* cls = billingVal.toObject(); +bool js_register_cc_Google_Billing(se::Object* obj) { // NOLINT + se::Value googleBillingVal{se::Object::createPlainObject()}; + auto* cls = googleBillingVal.toObject(); - cls->defineFunction("startConnection", _SE(js_cc_Billing_startConnection)); - cls->defineFunction("endConnection", _SE(js_cc_Billing_endConnection)); - cls->defineFunction("getConnectionState", _SE(js_cc_Billing_getConnectionState)); - cls->defineFunction("isReady", _SE(js_cc_Billing_isReady)); - cls->defineFunction("queryProductDetailsParams", _SE(js_cc_Billing_queryProductDetailsParams)); + cls->defineFunction("startConnection", _SE(js_cc_Google_Billing_startConnection)); + cls->defineFunction("endConnection", _SE(js_cc_Google_Billing_endConnection)); + cls->defineFunction("getConnectionState", _SE(js_cc_Google_Billing_getConnectionState)); + cls->defineFunction("isReady", _SE(js_cc_Google_Billing_isReady)); + cls->defineFunction("queryProductDetailsParams", _SE(js_cc_Google_Billing_queryProductDetailsParams)); - cls->defineFunction("launchBillingFlow", _SE(js_cc_Billing_launchBillingFlow)); - cls->defineFunction("consumePurchases", _SE(js_cc_Billing_consumePurchases)); - cls->defineFunction("acknowledgePurchase", _SE(js_cc_Billing_acknowledgePurchase)); - cls->defineFunction("queryPurchasesAsync", _SE(js_cc_Billing_queryPurchasesAsync)); - cls->defineFunction("getBillingConfigAsync", _SE(js_cc_Billing_getBillingConfigAsync)); + cls->defineFunction("launchBillingFlow", _SE(js_cc_Google_Billing_launchBillingFlow)); + cls->defineFunction("consumePurchases", _SE(js_cc_Google_Billing_consumePurchases)); + cls->defineFunction("acknowledgePurchase", _SE(js_cc_Google_Billing_acknowledgePurchase)); + cls->defineFunction("queryPurchasesAsync", _SE(js_cc_Google_Billing_queryPurchasesAsync)); + cls->defineFunction("getBillingConfigAsync", _SE(js_cc_Google_Billing_getBillingConfigAsync)); - cls->defineFunction("createAlternativeBillingOnlyReportingDetailsAsync", _SE(js_cc_Billing_createAlternativeBillingOnlyReportingDetailsAsync)); - cls->defineFunction("isAlternativeBillingOnlyAvailableAsync", _SE(js_cc_Billing_isAlternativeBillingOnlyAvailableAsync)); - cls->defineFunction("createExternalOfferReportingDetailsAsync", _SE(js_cc_Billing_createExternalOfferReportingDetailsAsync)); - cls->defineFunction("isExternalOfferAvailableAsync", _SE(js_cc_Billing_isExternalOfferAvailableAsync)); + cls->defineFunction("createAlternativeBillingOnlyReportingDetailsAsync", _SE(js_cc_Google_Billing_createAlternativeBillingOnlyReportingDetailsAsync)); + cls->defineFunction("isAlternativeBillingOnlyAvailableAsync", _SE(js_cc_Google_Billing_isAlternativeBillingOnlyAvailableAsync)); + cls->defineFunction("createExternalOfferReportingDetailsAsync", _SE(js_cc_Google_Billing_createExternalOfferReportingDetailsAsync)); + cls->defineFunction("isExternalOfferAvailableAsync", _SE(js_cc_Google_Billing_isExternalOfferAvailableAsync)); - cls->defineFunction("isFeatureSupported", _SE(js_cc_Billing_isFeatureSupported)); + cls->defineFunction("isFeatureSupported", _SE(js_cc_Google_Billing_isFeatureSupported)); - cls->defineFunction("showAlternativeBillingOnlyInformationDialog", _SE(js_cc_Billing_showAlternativeBillingOnlyInformationDialog)); - cls->defineFunction("showExternalOfferInformationDialog", _SE(js_cc_Billing_showExternalOfferInformationDialog)); - cls->defineFunction("showInAppMessages", _SE(js_cc_Billing_showInAppMessages)); + cls->defineFunction("showAlternativeBillingOnlyInformationDialog", _SE(js_cc_Google_Billing_showAlternativeBillingOnlyInformationDialog)); + cls->defineFunction("showExternalOfferInformationDialog", _SE(js_cc_Google_Billing_showExternalOfferInformationDialog)); + cls->defineFunction("showInAppMessages", _SE(js_cc_Google_Billing_showInAppMessages)); - obj->setProperty("billing", billingVal); + obj->setProperty("googleBilling", googleBillingVal); return true; } @@ -1487,7 +1487,7 @@ bool jsb_register_all_billing(se::Object* obj) { // NOLINT js_register_cc_PendingPurchaseUpdate(ns); js_register_cc_Purchase(ns); js_register_cc_BillingConfig(ns); - js_register_cc_Billing(ns); + js_register_cc_Google_Billing(ns); return true; } diff --git a/native/cocos/bindings/manual/jsb_module_register.cpp b/native/cocos/bindings/manual/jsb_module_register.cpp index 0074ff3ef80..0e0c7ee52ff 100644 --- a/native/cocos/bindings/manual/jsb_module_register.cpp +++ b/native/cocos/bindings/manual/jsb_module_register.cpp @@ -192,7 +192,7 @@ bool jsb_register_all_modules() { se->addRegisterCallback(register_all_socketio); #endif -#if CC_USE_GOOGLE_PLAY_BILLING +#if CC_USE_GOOGLE_BILLING se->addRegisterCallback(jsb_register_all_billing); #endif diff --git a/native/cocos/platform/android/java/vendor/com/cocos/billing/CocosBilling.java b/native/cocos/platform/android/java/vendor/google/billing/GoogleBilling.java similarity index 91% rename from native/cocos/platform/android/java/vendor/com/cocos/billing/CocosBilling.java rename to native/cocos/platform/android/java/vendor/google/billing/GoogleBilling.java index a4b821c8f8c..9cd1bc853d8 100644 --- a/native/cocos/platform/android/java/vendor/com/cocos/billing/CocosBilling.java +++ b/native/cocos/platform/android/java/vendor/google/billing/GoogleBilling.java @@ -22,7 +22,7 @@ of this software and associated documentation files (the "Software"), to deal THE SOFTWARE. ****************************************************************************/ -package com.cocos.billing; +package google.billing; import android.util.Log; import androidx.annotation.NonNull; @@ -64,13 +64,13 @@ of this software and associated documentation files (the "Software"), to deal import java.util.List; import java.util.Map; -public class CocosBilling implements BillingClientStateListener, +public class GoogleBilling implements BillingClientStateListener, PurchasesUpdatedListener, ProductDetailsResponseListener, PurchasesResponseListener, ConsumeResponseListener, AcknowledgePurchaseResponseListener, BillingConfigResponseListener, AlternativeBillingOnlyReportingDetailsListener, AlternativeBillingOnlyAvailabilityListener,AlternativeBillingOnlyInformationDialogListener, ExternalOfferReportingDetailsListener, ExternalOfferAvailabilityListener,ExternalOfferInformationDialogListener, InAppMessageResponseListener { - private static final String TAG = CocosBilling.class.getSimpleName(); + private static final String TAG = GoogleBilling.class.getSimpleName(); private Map _productDetails = new HashMap<>(); private Map _purchase = new HashMap<>(); private int _productDetailsNextID = 0; @@ -81,7 +81,7 @@ public class CocosBilling implements BillingClientStateListener, */ private BillingClient _billingClient; - public CocosBilling() { + public GoogleBilling() { _billingClient = BillingClient.newBuilder(GlobalObject.getActivity()) .setListener(this) .enablePendingPurchases() @@ -327,7 +327,7 @@ public void onBillingSetupFinished(@NonNull BillingResult billingResult) { CocosHelper.runOnGameThread(new Runnable() { @Override public void run() { - CocosBillingHelper.onBillingSetupFinished(billingResult); + GoogleBillingHelper.onBillingSetupFinished(billingResult); } }); } @@ -336,7 +336,7 @@ public void onBillingServiceDisconnected() { CocosHelper.runOnGameThread(new Runnable() { @Override public void run() { - CocosBillingHelper.onBillingServiceDisconnected(); + GoogleBillingHelper.onBillingServiceDisconnected(); } }); } @@ -351,7 +351,7 @@ public void onProductDetailsResponse(@NonNull BillingResult billingResult, CocosHelper.runOnGameThread(new Runnable() { @Override public void run() { - CocosBillingHelper.onProductDetailsResponse(billingResult, productDetailsList, startID); + GoogleBillingHelper.onProductDetailsResponse(billingResult, productDetailsList, startID); } }); } @@ -368,7 +368,7 @@ public void onPurchasesUpdated(@NonNull BillingResult billingResult, CocosHelper.runOnGameThread(new Runnable() { @Override public void run() { - CocosBillingHelper.onPurchasesUpdated(billingResult, purchaseList, startID); + GoogleBillingHelper.onPurchasesUpdated(billingResult, purchaseList, startID); } }); } @@ -383,7 +383,7 @@ public void onQueryPurchasesResponse(@NonNull BillingResult billingResult, CocosHelper.runOnGameThread(new Runnable() { @Override public void run() { - CocosBillingHelper.onQueryPurchasesResponse(billingResult, purchaseList, startID); + GoogleBillingHelper.onQueryPurchasesResponse(billingResult, purchaseList, startID); } }); } @@ -394,7 +394,7 @@ public void onConsumeResponse(@NonNull BillingResult billingResult, CocosHelper.runOnGameThread(new Runnable() { @Override public void run() { - CocosBillingHelper.onConsumeResponse(billingResult, purchaseToken); + GoogleBillingHelper.onConsumeResponse(billingResult, purchaseToken); } }); } @@ -404,7 +404,7 @@ public void onAcknowledgePurchaseResponse(@NonNull BillingResult billingResult) CocosHelper.runOnGameThread(new Runnable() { @Override public void run() { - CocosBillingHelper.onAcknowledgePurchaseResponse(billingResult); + GoogleBillingHelper.onAcknowledgePurchaseResponse(billingResult); } }); } @@ -414,7 +414,7 @@ public void onBillingConfigResponse(@NonNull BillingResult billingResult, @Nulla CocosHelper.runOnGameThread(new Runnable() { @Override public void run() { - CocosBillingHelper.onBillingConfigResponse(billingResult, billingConfig); + GoogleBillingHelper.onBillingConfigResponse(billingResult, billingConfig); } }); } @@ -426,7 +426,7 @@ public void onAlternativeBillingOnlyTokenResponse( CocosHelper.runOnGameThread(new Runnable() { @Override public void run() { - CocosBillingHelper.onAlternativeBillingOnlyTokenResponse(billingResult, alternativeBillingOnlyReportingDetails); + GoogleBillingHelper.onAlternativeBillingOnlyTokenResponse(billingResult, alternativeBillingOnlyReportingDetails); } }); } @@ -436,7 +436,7 @@ public void onAlternativeBillingOnlyAvailabilityResponse(@NonNull BillingResult CocosHelper.runOnGameThread(new Runnable() { @Override public void run() { - CocosBillingHelper.onAlternativeBillingOnlyAvailabilityResponse(billingResult); + GoogleBillingHelper.onAlternativeBillingOnlyAvailabilityResponse(billingResult); } }); } @@ -449,7 +449,7 @@ public void onExternalOfferReportingDetailsResponse( CocosHelper.runOnGameThread(new Runnable() { @Override public void run() { - CocosBillingHelper.onExternalOfferReportingDetailsResponse(billingResult, externalOfferReportingDetails); + GoogleBillingHelper.onExternalOfferReportingDetailsResponse(billingResult, externalOfferReportingDetails); } }); } @@ -459,7 +459,7 @@ public void onExternalOfferAvailabilityResponse(@NonNull BillingResult billingRe CocosHelper.runOnGameThread(new Runnable() { @Override public void run() { - CocosBillingHelper.onExternalOfferAvailabilityResponse(billingResult); + GoogleBillingHelper.onExternalOfferAvailabilityResponse(billingResult); } }); } @@ -469,7 +469,7 @@ public void onExternalOfferInformationDialogResponse(@NonNull BillingResult bill CocosHelper.runOnGameThread(new Runnable() { @Override public void run() { - CocosBillingHelper.onExternalOfferInformationDialogResponse(billingResult); + GoogleBillingHelper.onExternalOfferInformationDialogResponse(billingResult); } }); } @@ -479,7 +479,7 @@ public void onAlternativeBillingOnlyInformationDialogResponse(@NonNull BillingRe CocosHelper.runOnGameThread(new Runnable() { @Override public void run() { - CocosBillingHelper.onAlternativeBillingOnlyInformationDialogResponse(billingResult); + GoogleBillingHelper.onAlternativeBillingOnlyInformationDialogResponse(billingResult); } }); } @@ -489,7 +489,7 @@ public void onInAppMessageResponse(@NonNull InAppMessageResult inAppMessageResul CocosHelper.runOnGameThread(new Runnable() { @Override public void run() { - CocosBillingHelper.onInAppMessageResponse(inAppMessageResult); + GoogleBillingHelper.onInAppMessageResponse(inAppMessageResult); } }); } diff --git a/native/cocos/platform/android/java/vendor/com/cocos/billing/CocosBillingHelper.java b/native/cocos/platform/android/java/vendor/google/billing/GoogleBillingHelper.java similarity index 97% rename from native/cocos/platform/android/java/vendor/com/cocos/billing/CocosBillingHelper.java rename to native/cocos/platform/android/java/vendor/google/billing/GoogleBillingHelper.java index 5d862538f4d..3351911858f 100644 --- a/native/cocos/platform/android/java/vendor/com/cocos/billing/CocosBillingHelper.java +++ b/native/cocos/platform/android/java/vendor/google/billing/GoogleBillingHelper.java @@ -22,7 +22,7 @@ of this software and associated documentation files (the "Software"), to deal THE SOFTWARE. ****************************************************************************/ -package com.cocos.billing; +package google.billing; import android.annotation.SuppressLint; @@ -38,9 +38,9 @@ of this software and associated documentation files (the "Software"), to deal import com.android.billingclient.api.Purchase; import java.util.List; import com.cocos.lib.GlobalObject; -import com.cocos.billing.CocosBilling; +import google.billing.GoogleBilling; -public class CocosBillingHelper { +public class GoogleBillingHelper { public static native void onBillingSetupFinished(@NonNull BillingResult billingResult); public static native void onBillingServiceDisconnected(); public static native void onProductDetailsResponse(@NonNull BillingResult billingResult, @NonNull List productDetailsList, int startID); @@ -64,11 +64,11 @@ public static native void onExternalOfferReportingDetailsResponse( public static native void onInAppMessageResponse(@NonNull InAppMessageResult inAppMessageResult); @SuppressLint("StaticFieldLeak") - private static CocosBilling instance; + private static GoogleBilling instance; - public static CocosBilling getInstance() { + public static GoogleBilling getInstance() { if (instance == null) { - instance = new CocosBilling(); + instance = new GoogleBilling(); } return instance; } diff --git a/native/cocos/platform/android/libcocos2dx/build.gradle b/native/cocos/platform/android/libcocos2dx/build.gradle index 8dedbe4acac..801cff10d39 100644 --- a/native/cocos/platform/android/libcocos2dx/build.gradle +++ b/native/cocos/platform/android/libcocos2dx/build.gradle @@ -21,7 +21,7 @@ android { manifest.srcFile "AndroidManifest.xml" } - if(project.hasProperty("PROP_ENABLE_BILLING") && project.PROP_ENABLE_BILLING.toBoolean()) { + if(project.hasProperty("PROP_ENABLE_GOOGLE_BILLING") && project.PROP_ENABLE_GOOGLE_BILLING.toBoolean()) { sourceSets.main.java.srcDirs += ["../java/vendor"] } buildDir = new File(rootProject.buildDir, project.name) @@ -40,7 +40,7 @@ android { dependencies { api fileTree(include: ['*.jar'], dir: '../java/libs') - if(project.hasProperty("PROP_ENABLE_BILLING") && project.PROP_ENABLE_BILLING.toBoolean()) { + if(project.hasProperty("PROP_ENABLE_GOOGLE_BILLING") && project.PROP_ENABLE_GOOGLE_BILLING.toBoolean()) { implementation "com.android.billingclient:billing:7.1.0" } } diff --git a/native/cocos/platform/android/modules/google_play/billing/billing.cpp b/native/cocos/platform/android/modules/google_play/billing/billing.cpp deleted file mode 100644 index a5f00640d38..00000000000 --- a/native/cocos/platform/android/modules/google_play/billing/billing.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** - Copyright (c) 2024 Xiamen Yaji Software Co., Ltd. - - http://www.cocos.com - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights to - use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - of the Software, and to permit persons to whom the Software is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -****************************************************************************/ - -#include "platform/android/modules/google_play/billing/billing.h" -#include "platform/android/modules/google_play/billing/JniBillingHelper.h" -#include "platform/java/jni/JniHelper.h" -#include "platform/java/jni/JniImp.h" - -namespace cc { - -ProductDetails::~ProductDetails() { - for (auto* ptr : subscriptionOfferDetails) { - delete ptr; - } - subscriptionOfferDetails.clear(); - JniBillingHelper::removeProductDetails(_id); -} - -Purchase::~Purchase() { - JniBillingHelper::removePurchase(_id); -} - -void Billing::startConnection() { - JniBillingHelper::startConnection(); -} - -void Billing::endConnection() { - JniBillingHelper::endConnection(); -} - -int Billing::getConnectionState() const { - return JniBillingHelper::getConnectionState(); -} - -bool Billing::isReady() const { - return JniBillingHelper::isReady(); -} - -void Billing::queryProductDetailsParams(const std::vector& productIds, const std::string& type) { - JniBillingHelper::queryProductDetailsParams(productIds, type); -} - -void Billing::launchBillingFlow(const std::vector& productDetailsList, const std::string& selectedOfferToken) { - JniBillingHelper::launchBillingFlow(productDetailsList, selectedOfferToken); -} - -void Billing::consumePurchases(const std::vector& purchases) { - JniBillingHelper::consumePurchases(purchases); -} - -void Billing::acknowledgePurchase(const std::vector& purchases) { - JniBillingHelper::acknowledgePurchase(purchases); -} - -void Billing::queryPurchasesAsync(const std::string& productType) { - JniBillingHelper::queryPurchasesAsync(productType); -} - -void Billing::getBillingConfigAsync() { - JniBillingHelper::getBillingConfigAsync(); -} - -BillingResult* Billing::isFeatureSupported(const std::string& feature) { - return JniBillingHelper::isFeatureSupported(feature); -} - -void Billing::createAlternativeBillingOnlyReportingDetailsAsync() { - JniBillingHelper::createAlternativeBillingOnlyReportingDetailsAsync(); -} - -void Billing::isAlternativeBillingOnlyAvailableAsync() { - JniBillingHelper::isAlternativeBillingOnlyAvailableAsync(); -} - -void Billing::createExternalOfferReportingDetailsAsync() { - JniBillingHelper::createExternalOfferReportingDetailsAsync(); -} - -void Billing::isExternalOfferAvailableAsync() { - JniBillingHelper::isExternalOfferAvailableAsync(); -} - -BillingResult* Billing::showAlternativeBillingOnlyInformationDialog() { - return JniBillingHelper::showAlternativeBillingOnlyInformationDialog(); -} - -BillingResult* Billing::showExternalOfferInformationDialog() { - return JniBillingHelper::showExternalOfferInformationDialog(); -} - -BillingResult* Billing::showInAppMessages() { - return JniBillingHelper::showInAppMessages(); -} - -} // namespace cc diff --git a/native/cocos/platform/java/jni/JniCocosBilling.cpp b/native/cocos/platform/java/jni/JniCocosBilling.cpp deleted file mode 100644 index 5d76cf3ee9b..00000000000 --- a/native/cocos/platform/java/jni/JniCocosBilling.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** - Copyright (c) 2024 Xiamen Yaji Software Co., Ltd. - - http://www.cocos.com - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights to - use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - of the Software, and to permit persons to whom the Software is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -****************************************************************************/ - -#include "platform/java/jni/JniHelper.h" -#include -#include "cocos/platform/android/modules/google_play/billing/JniBillingHelper.h" - -extern "C" { - -// NOLINTNEXTLINE -JNIEXPORT void JNICALL Java_com_cocos_billing_CocosBillingHelper_onBillingSetupFinished(JNIEnv *env, jclass clazz, jobject billingResultObj) { - cc::JniBillingHelper::onBillingSetupFinished(env, clazz, billingResultObj); -} - -// NOLINTNEXTLINE -JNIEXPORT void JNICALL Java_com_cocos_billing_CocosBillingHelper_onBillingServiceDisconnected(JNIEnv *env, jclass clazz) { - cc::JniBillingHelper::onBillingServiceDisconnected(env, clazz); -} - -// NOLINTNEXTLINE -JNIEXPORT void JNICALL Java_com_cocos_billing_CocosBillingHelper_onProductDetailsResponse(JNIEnv *env, jclass clazz, - jobject billingResultObj, - jobject productDetailsListObj, - jint startID) { - cc::JniBillingHelper::onProductDetailsResponse(env, clazz, billingResultObj, productDetailsListObj, startID); -} - -// NOLINTNEXTLINE -JNIEXPORT void JNICALL Java_com_cocos_billing_CocosBillingHelper_onPurchasesUpdated(JNIEnv *env, jclass clazz, - jobject billingResultObj, - jobject purchaseListObj, - jint startID) { - cc::JniBillingHelper::onPurchasesUpdated(env, clazz, billingResultObj, purchaseListObj, startID); -} - -// NOLINTNEXTLINE -JNIEXPORT void JNICALL Java_com_cocos_billing_CocosBillingHelper_onConsumeResponse(JNIEnv *env, jclass clazz, jobject billingResultObj, jstring purchaseToken) { - cc::JniBillingHelper::onConsumeResponse(env, clazz, billingResultObj, purchaseToken); -} - -// NOLINTNEXTLINE -JNIEXPORT void JNICALL Java_com_cocos_billing_CocosBillingHelper_onQueryPurchasesResponse(JNIEnv *env, jclass clazz, jobject billingResultObj, - jobject purchaseListObj, jint startID) { - cc::JniBillingHelper::onQueryPurchasesResponse(env, clazz, billingResultObj, purchaseListObj, startID); -} - -// NOLINTNEXTLINE -JNIEXPORT void JNICALL Java_com_cocos_billing_CocosBillingHelper_onAcknowledgePurchaseResponse(JNIEnv *env, jclass clazz, jobject billingResultObj) { - cc::JniBillingHelper::onAcknowledgePurchaseResponse(env, clazz, billingResultObj); -} - -// NOLINTNEXTLINE -JNIEXPORT void JNICALL Java_com_cocos_billing_CocosBillingHelper_onBillingConfigResponse(JNIEnv *env, jclass clazz, jobject billingResultObj, jobject billingConfigObj) { - cc::JniBillingHelper::onBillingConfigResponse(env, clazz, billingResultObj, billingConfigObj); -} - -// NOLINTNEXTLINE -JNIEXPORT void JNICALL Java_com_cocos_billing_CocosBillingHelper_onAlternativeBillingOnlyTokenResponse(JNIEnv *env, jclass clazz, jobject billingResultObj, jobject alternativeBillingOnlyReportingDetailsObj) { - cc::JniBillingHelper::onAlternativeBillingOnlyTokenResponse(env, clazz, billingResultObj, alternativeBillingOnlyReportingDetailsObj); -} - -// NOLINTNEXTLINE -JNIEXPORT void JNICALL Java_com_cocos_billing_CocosBillingHelper_onExternalOfferReportingDetailsResponse(JNIEnv *env, jclass clazz, jobject billingResultObj, jobject externalOfferReportingDetailsObj) { - cc::JniBillingHelper::onExternalOfferReportingDetailsResponse(env, clazz, billingResultObj, externalOfferReportingDetailsObj); -} - -// NOLINTNEXTLINE -JNIEXPORT void JNICALL Java_com_cocos_billing_CocosBillingHelper_onAlternativeBillingOnlyAvailabilityResponse(JNIEnv *env, jclass clazz, jobject billingResultObj) { - cc::JniBillingHelper::onAlternativeBillingOnlyAvailabilityResponse(env, clazz, billingResultObj); -} - -// NOLINTNEXTLINE -JNIEXPORT void JNICALL Java_com_cocos_billing_CocosBillingHelper_onExternalOfferAvailabilityResponse(JNIEnv *env, jclass clazz, jobject billingResultObj) { - cc::JniBillingHelper::onExternalOfferAvailabilityResponse(env, clazz, billingResultObj); -} - -// NOLINTNEXTLINE -JNIEXPORT void JNICALL Java_com_cocos_billing_CocosBillingHelper_onAlternativeBillingOnlyInformationDialogResponse(JNIEnv *env, jclass clazz, jobject billingResultObj) { - cc::JniBillingHelper::onAlternativeBillingOnlyInformationDialogResponse(env, clazz, billingResultObj); -} - -// NOLINTNEXTLINE -JNIEXPORT void JNICALL Java_com_cocos_billing_CocosBillingHelper_onExternalOfferInformationDialogResponse(JNIEnv *env, jclass clazz, jobject billingResultObj) { - cc::JniBillingHelper::onExternalOfferInformationDialogResponse(env, clazz, billingResultObj); -} - -// NOLINTNEXTLINE -JNIEXPORT void JNICALL Java_com_cocos_billing_CocosBillingHelper_onInAppMessageResponse(JNIEnv *env, jclass clazz, jobject inAppMessageResultObj) { - cc::JniBillingHelper::onInAppMessageResponse(env, clazz, inAppMessageResultObj); -} -} diff --git a/native/cocos/platform/java/jni/JniGoogleBillingHandler.cpp b/native/cocos/platform/java/jni/JniGoogleBillingHandler.cpp new file mode 100644 index 00000000000..a27ce9f0aa6 --- /dev/null +++ b/native/cocos/platform/java/jni/JniGoogleBillingHandler.cpp @@ -0,0 +1,112 @@ +/**************************************************************************** + Copyright (c) 2024 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#include "platform/java/jni/JniHelper.h" +#include +#include "vendor/google/billing/GoogleBillingHelper.h" + +extern "C" { + +// NOLINTNEXTLINE +JNIEXPORT void JNICALL Java_google_billing_GoogleBillingHelper_onBillingSetupFinished(JNIEnv *env, jclass clazz, jobject billingResultObj) { + cc::GoogleBillingHelper::onBillingSetupFinished(env, clazz, billingResultObj); +} + +// NOLINTNEXTLINE +JNIEXPORT void JNICALL Java_google_billing_GoogleBillingHelper_onBillingServiceDisconnected(JNIEnv *env, jclass clazz) { + cc::GoogleBillingHelper::onBillingServiceDisconnected(env, clazz); +} + +// NOLINTNEXTLINE +JNIEXPORT void JNICALL Java_google_billing_GoogleBillingHelper_onProductDetailsResponse(JNIEnv *env, jclass clazz, + jobject billingResultObj, + jobject productDetailsListObj, + jint startID) { + cc::GoogleBillingHelper::onProductDetailsResponse(env, clazz, billingResultObj, productDetailsListObj, startID); +} + +// NOLINTNEXTLINE +JNIEXPORT void JNICALL Java_google_billing_GoogleBillingHelper_onPurchasesUpdated(JNIEnv *env, jclass clazz, + jobject billingResultObj, + jobject purchaseListObj, + jint startID) { + cc::GoogleBillingHelper::onPurchasesUpdated(env, clazz, billingResultObj, purchaseListObj, startID); +} + +// NOLINTNEXTLINE +JNIEXPORT void JNICALL Java_google_billing_GoogleBillingHelper_onConsumeResponse(JNIEnv *env, jclass clazz, jobject billingResultObj, jstring purchaseToken) { + cc::GoogleBillingHelper::onConsumeResponse(env, clazz, billingResultObj, purchaseToken); +} + +// NOLINTNEXTLINE +JNIEXPORT void JNICALL Java_google_billing_GoogleBillingHelper_onQueryPurchasesResponse(JNIEnv *env, jclass clazz, jobject billingResultObj, + jobject purchaseListObj, jint startID) { + cc::GoogleBillingHelper::onQueryPurchasesResponse(env, clazz, billingResultObj, purchaseListObj, startID); +} + +// NOLINTNEXTLINE +JNIEXPORT void JNICALL Java_google_billing_GoogleBillingHelper_onAcknowledgePurchaseResponse(JNIEnv *env, jclass clazz, jobject billingResultObj) { + cc::GoogleBillingHelper::onAcknowledgePurchaseResponse(env, clazz, billingResultObj); +} + +// NOLINTNEXTLINE +JNIEXPORT void JNICALL Java_google_billing_GoogleBillingHelper_onBillingConfigResponse(JNIEnv *env, jclass clazz, jobject billingResultObj, jobject billingConfigObj) { + cc::GoogleBillingHelper::onBillingConfigResponse(env, clazz, billingResultObj, billingConfigObj); +} + +// NOLINTNEXTLINE +JNIEXPORT void JNICALL Java_google_billing_GoogleBillingHelper_onAlternativeBillingOnlyTokenResponse(JNIEnv *env, jclass clazz, jobject billingResultObj, jobject alternativeBillingOnlyReportingDetailsObj) { + cc::GoogleBillingHelper::onAlternativeBillingOnlyTokenResponse(env, clazz, billingResultObj, alternativeBillingOnlyReportingDetailsObj); +} + +// NOLINTNEXTLINE +JNIEXPORT void JNICALL Java_google_billing_GoogleBillingHelper_onExternalOfferReportingDetailsResponse(JNIEnv *env, jclass clazz, jobject billingResultObj, jobject externalOfferReportingDetailsObj) { + cc::GoogleBillingHelper::onExternalOfferReportingDetailsResponse(env, clazz, billingResultObj, externalOfferReportingDetailsObj); +} + +// NOLINTNEXTLINE +JNIEXPORT void JNICALL Java_google_billing_GoogleBillingHelper_onAlternativeBillingOnlyAvailabilityResponse(JNIEnv *env, jclass clazz, jobject billingResultObj) { + cc::GoogleBillingHelper::onAlternativeBillingOnlyAvailabilityResponse(env, clazz, billingResultObj); +} + +// NOLINTNEXTLINE +JNIEXPORT void JNICALL Java_google_billing_GoogleBillingHelper_onExternalOfferAvailabilityResponse(JNIEnv *env, jclass clazz, jobject billingResultObj) { + cc::GoogleBillingHelper::onExternalOfferAvailabilityResponse(env, clazz, billingResultObj); +} + +// NOLINTNEXTLINE +JNIEXPORT void JNICALL Java_google_billing_GoogleBillingHelper_onAlternativeBillingOnlyInformationDialogResponse(JNIEnv *env, jclass clazz, jobject billingResultObj) { + cc::GoogleBillingHelper::onAlternativeBillingOnlyInformationDialogResponse(env, clazz, billingResultObj); +} + +// NOLINTNEXTLINE +JNIEXPORT void JNICALL Java_google_billing_GoogleBillingHelper_onExternalOfferInformationDialogResponse(JNIEnv *env, jclass clazz, jobject billingResultObj) { + cc::GoogleBillingHelper::onExternalOfferInformationDialogResponse(env, clazz, billingResultObj); +} + +// NOLINTNEXTLINE +JNIEXPORT void JNICALL Java_google_billing_GoogleBillingHelper_onInAppMessageResponse(JNIEnv *env, jclass clazz, jobject inAppMessageResultObj) { + cc::GoogleBillingHelper::onInAppMessageResponse(env, clazz, inAppMessageResultObj); +} +} diff --git a/native/vendor/google/billing/GoogleBilling.cpp b/native/vendor/google/billing/GoogleBilling.cpp new file mode 100644 index 00000000000..04155f2ebb1 --- /dev/null +++ b/native/vendor/google/billing/GoogleBilling.cpp @@ -0,0 +1,116 @@ +/**************************************************************************** + Copyright (c) 2024 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#include "vendor/google/billing/GoogleBilling.h" +#include "vendor/google/billing/GoogleBillingHelper.h" +#include "platform/java/jni/JniHelper.h" +#include "platform/java/jni/JniImp.h" + +namespace cc { + +ProductDetails::~ProductDetails() { + for (auto* ptr : subscriptionOfferDetails) { + delete ptr; + } + subscriptionOfferDetails.clear(); + GoogleBillingHelper::removeProductDetails(_id); +} + +Purchase::~Purchase() { + GoogleBillingHelper::removePurchase(_id); +} + +void GoogleBilling::startConnection() { + GoogleBillingHelper::startConnection(); +} + +void GoogleBilling::endConnection() { + GoogleBillingHelper::endConnection(); +} + +int GoogleBilling::getConnectionState() const { + return GoogleBillingHelper::getConnectionState(); +} + +bool GoogleBilling::isReady() const { + return GoogleBillingHelper::isReady(); +} + +void GoogleBilling::queryProductDetailsParams(const std::vector& productIds, const std::string& type) { + GoogleBillingHelper::queryProductDetailsParams(productIds, type); +} + +void GoogleBilling::launchBillingFlow(const std::vector& productDetailsList, const std::string& selectedOfferToken) { + GoogleBillingHelper::launchBillingFlow(productDetailsList, selectedOfferToken); +} + +void GoogleBilling::consumePurchases(const std::vector& purchases) { + GoogleBillingHelper::consumePurchases(purchases); +} + +void GoogleBilling::acknowledgePurchase(const std::vector& purchases) { + GoogleBillingHelper::acknowledgePurchase(purchases); +} + +void GoogleBilling::queryPurchasesAsync(const std::string& productType) { + GoogleBillingHelper::queryPurchasesAsync(productType); +} + +void GoogleBilling::getBillingConfigAsync() { + GoogleBillingHelper::getBillingConfigAsync(); +} + +BillingResult* GoogleBilling::isFeatureSupported(const std::string& feature) { + return GoogleBillingHelper::isFeatureSupported(feature); +} + +void GoogleBilling::createAlternativeBillingOnlyReportingDetailsAsync() { + GoogleBillingHelper::createAlternativeBillingOnlyReportingDetailsAsync(); +} + +void GoogleBilling::isAlternativeBillingOnlyAvailableAsync() { + GoogleBillingHelper::isAlternativeBillingOnlyAvailableAsync(); +} + +void GoogleBilling::createExternalOfferReportingDetailsAsync() { + GoogleBillingHelper::createExternalOfferReportingDetailsAsync(); +} + +void GoogleBilling::isExternalOfferAvailableAsync() { + GoogleBillingHelper::isExternalOfferAvailableAsync(); +} + +BillingResult* GoogleBilling::showAlternativeBillingOnlyInformationDialog() { + return GoogleBillingHelper::showAlternativeBillingOnlyInformationDialog(); +} + +BillingResult* GoogleBilling::showExternalOfferInformationDialog() { + return GoogleBillingHelper::showExternalOfferInformationDialog(); +} + +BillingResult* GoogleBilling::showInAppMessages() { + return GoogleBillingHelper::showInAppMessages(); +} + +} // namespace cc diff --git a/native/cocos/platform/android/modules/google_play/billing/billing.h b/native/vendor/google/billing/GoogleBilling.h similarity index 94% rename from native/cocos/platform/android/modules/google_play/billing/billing.h rename to native/vendor/google/billing/GoogleBilling.h index 9445c60e607..b394775f2f7 100644 --- a/native/cocos/platform/android/modules/google_play/billing/billing.h +++ b/native/vendor/google/billing/GoogleBilling.h @@ -159,10 +159,10 @@ class InAppMessageResult : public cc::RefCounted{ std::string purchaseToken; }; -class CC_DLL Billing { +class CC_DLL GoogleBilling { public: - static Billing &getInstance() { - static Billing instance; + static GoogleBilling &getInstance() { + static GoogleBilling instance; return instance; } @@ -186,7 +186,7 @@ class CC_DLL Billing { BillingResult* showExternalOfferInformationDialog(); BillingResult* showInAppMessages(); private: - Billing() = default; + GoogleBilling() = default; }; } // namespace cc diff --git a/native/cocos/platform/android/modules/google_play/billing/JniBillingHelper.cpp b/native/vendor/google/billing/GoogleBillingHelper.cpp similarity index 76% rename from native/cocos/platform/android/modules/google_play/billing/JniBillingHelper.cpp rename to native/vendor/google/billing/GoogleBillingHelper.cpp index f4335097242..fc34a726e39 100644 --- a/native/cocos/platform/android/modules/google_play/billing/JniBillingHelper.cpp +++ b/native/vendor/google/billing/GoogleBillingHelper.cpp @@ -21,8 +21,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "platform/android/modules/google_play/billing/JniBillingHelper.h" -#include "platform/android/modules/google_play/billing/billing.h" +#include "vendor/google/billing/GoogleBillingHelper.h" +#include "vendor/google/billing/GoogleBilling.h" #include "platform/java/jni/JniHelper.h" #include @@ -37,7 +37,7 @@ namespace { #ifndef JCLS_BILLING - #define JCLS_BILLING "com/cocos/billing/CocosBillingHelper" + #define JCLS_BILLING "google/billing/GoogleBillingHelper" #endif }; // namespace @@ -112,72 +112,72 @@ template void callJSfunc(const char*, BillingResult*&&, AlternativeBillingOnlyRe template void callJSfunc(const char*, BillingResult*&&, ExternalOfferReportingDetails*&&); template void callJSfunc(const char*, InAppMessageResult*&&); -void JniBillingHelper::removeProductDetails(int productDetailsID) { +void GoogleBillingHelper::removeProductDetails(int productDetailsID) { JniHelper::callStaticVoidMethod(JCLS_BILLING, "removeProductDetails", productDetailsID); } -void JniBillingHelper::removePurchase(int purchaseID) { +void GoogleBillingHelper::removePurchase(int purchaseID) { JniHelper::callStaticVoidMethod(JCLS_BILLING, "removePurchase", purchaseID); } -void JniBillingHelper::startConnection() { +void GoogleBillingHelper::startConnection() { JniHelper::callStaticVoidMethod(JCLS_BILLING, "startConnection"); } -void JniBillingHelper::endConnection() { +void GoogleBillingHelper::endConnection() { JniHelper::callStaticVoidMethod(JCLS_BILLING, "endConnection"); } -int JniBillingHelper::getConnectionState() { +int GoogleBillingHelper::getConnectionState() { return JniHelper::callStaticIntMethod(JCLS_BILLING, "getConnectionState"); } -bool JniBillingHelper::isReady() { +bool GoogleBillingHelper::isReady() { return JniHelper::callStaticBooleanMethod(JCLS_BILLING, "isReady"); } -void JniBillingHelper::queryProductDetailsParams(const std::vector& productIds, const std::string& type) { +void GoogleBillingHelper::queryProductDetailsParams(const std::vector& productIds, const std::string& type) { JniHelper::callStaticVoidMethod(JCLS_BILLING, "queryProductDetailsParams", productIds, type); } -void JniBillingHelper::queryPurchasesAsync(const std::string& productType) { +void GoogleBillingHelper::queryPurchasesAsync(const std::string& productType) { JniHelper::callStaticVoidMethod(JCLS_BILLING, "queryPurchasesAsync", productType); } -void JniBillingHelper::getBillingConfigAsync() { +void GoogleBillingHelper::getBillingConfigAsync() { JniHelper::callStaticVoidMethod(JCLS_BILLING, "getBillingConfigAsync"); } -void JniBillingHelper::createAlternativeBillingOnlyReportingDetailsAsync() { +void GoogleBillingHelper::createAlternativeBillingOnlyReportingDetailsAsync() { JniHelper::callStaticVoidMethod(JCLS_BILLING, "createAlternativeBillingOnlyReportingDetailsAsync"); } -void JniBillingHelper::isAlternativeBillingOnlyAvailableAsync() { +void GoogleBillingHelper::isAlternativeBillingOnlyAvailableAsync() { JniHelper::callStaticVoidMethod(JCLS_BILLING, "isAlternativeBillingOnlyAvailableAsync"); } -void JniBillingHelper::createExternalOfferReportingDetailsAsync() { +void GoogleBillingHelper::createExternalOfferReportingDetailsAsync() { JniHelper::callStaticVoidMethod(JCLS_BILLING, "createExternalOfferReportingDetailsAsync"); } -void JniBillingHelper::isExternalOfferAvailableAsync() { +void GoogleBillingHelper::isExternalOfferAvailableAsync() { JniHelper::callStaticVoidMethod(JCLS_BILLING, "isExternalOfferAvailableAsync"); } -BillingResult* JniBillingHelper::showAlternativeBillingOnlyInformationDialog() { +BillingResult* GoogleBillingHelper::showAlternativeBillingOnlyInformationDialog() { return callFunctionAndReturnBillingResult("showAlternativeBillingOnlyInformationDialog"); } -BillingResult* JniBillingHelper::showExternalOfferInformationDialog() { +BillingResult* GoogleBillingHelper::showExternalOfferInformationDialog() { return callFunctionAndReturnBillingResult("showExternalOfferInformationDialog"); } -BillingResult* JniBillingHelper::showInAppMessages() { +BillingResult* GoogleBillingHelper::showInAppMessages() { return callFunctionAndReturnBillingResult("showInAppMessages"); } -void JniBillingHelper::launchBillingFlow(const std::vector& productDetailsList, const std::string& selectedOfferToken) { +void GoogleBillingHelper::launchBillingFlow(const std::vector& productDetailsList, const std::string& selectedOfferToken) { if (productDetailsList.empty()) { return; } @@ -196,7 +196,7 @@ void JniBillingHelper::launchBillingFlow(const std::vector& pro t.env->CallStaticVoidMethod(t.classID, t.methodID, result, offerToken); } -void JniBillingHelper::consumePurchases(const std::vector& purchases) { +void GoogleBillingHelper::consumePurchases(const std::vector& purchases) { if (purchases.empty()) { return; } @@ -214,7 +214,7 @@ void JniBillingHelper::consumePurchases(const std::vector& purchases) t.env->CallStaticVoidMethod(t.classID, t.methodID, result); } -void JniBillingHelper::acknowledgePurchase(const std::vector& purchases) { +void GoogleBillingHelper::acknowledgePurchase(const std::vector& purchases) { if (purchases.empty()) { return; } @@ -232,7 +232,7 @@ void JniBillingHelper::acknowledgePurchase(const std::vector& purchas t.env->CallStaticVoidMethod(t.classID, t.methodID, result); } -BillingResult* JniBillingHelper::callFunctionAndReturnBillingResult(const std::string& functionName) { +BillingResult* GoogleBillingHelper::callFunctionAndReturnBillingResult(const std::string& functionName) { auto* env = JniHelper::getEnv(); cc::JniMethodInfo t; if (cc::JniHelper::getStaticMethodInfo(t, JCLS_BILLING, functionName.c_str(), "()Lcom/android/billingclient/api/BillingResult;")) { @@ -242,7 +242,7 @@ BillingResult* JniBillingHelper::callFunctionAndReturnBillingResult(const std::s return nullptr; } -BillingResult* JniBillingHelper::isFeatureSupported(const std::string& feature) { +BillingResult* GoogleBillingHelper::isFeatureSupported(const std::string& feature) { auto* env = JniHelper::getEnv(); cc::JniMethodInfo t; if (cc::JniHelper::getStaticMethodInfo(t, JCLS_BILLING, "isFeatureSupported", "(Ljava/lang/String;)Lcom/android/billingclient/api/BillingResult;")) { @@ -253,104 +253,104 @@ BillingResult* JniBillingHelper::isFeatureSupported(const std::string& feature) return nullptr; } -void JniBillingHelper::onBillingSetupFinished(JNIEnv* env, jclass clazz, jobject billingResultObj) { +void GoogleBillingHelper::onBillingSetupFinished(JNIEnv* env, jclass clazz, jobject billingResultObj) { cc::callJSfunc("onBillingSetupFinished", toBillingResult(env, billingResultObj)); } -void JniBillingHelper::onBillingServiceDisconnected(JNIEnv* env, jclass clazz) { +void GoogleBillingHelper::onBillingServiceDisconnected(JNIEnv* env, jclass clazz) { cc::callJSfunc("onBillingServiceDisconnected"); } -void JniBillingHelper::onProductDetailsResponse(JNIEnv* env, jclass clazz, +void GoogleBillingHelper::onProductDetailsResponse(JNIEnv* env, jclass clazz, jobject billingResultObj, jobject productDetailsListObj, jint startID) { - auto* billingResult = cc::JniBillingHelper::toBillingResult(env, billingResultObj); - std::vector productDetailsList = cc::JniBillingHelper::toProductDetailList(env, productDetailsListObj, startID); + auto* billingResult = cc::GoogleBillingHelper::toBillingResult(env, billingResultObj); + std::vector productDetailsList = cc::GoogleBillingHelper::toProductDetailList(env, productDetailsListObj, startID); cc::callJSfunc("onProductDetailsResponse", billingResult, productDetailsList); } -void JniBillingHelper::onPurchasesUpdated(JNIEnv* env, jclass clazz, +void GoogleBillingHelper::onPurchasesUpdated(JNIEnv* env, jclass clazz, jobject billingResultObj, jobject purchasesListObj, jint startID) { - auto* billingResult = cc::JniBillingHelper::toBillingResult(env, billingResultObj); + auto* billingResult = cc::GoogleBillingHelper::toBillingResult(env, billingResultObj); if (purchasesListObj != nullptr) { - std::vector purchasesList = cc::JniBillingHelper::toPurchaseList(env, purchasesListObj, startID); + std::vector purchasesList = cc::GoogleBillingHelper::toPurchaseList(env, purchasesListObj, startID); cc::callJSfunc("onPurchasesUpdated", billingResult, purchasesList); } else { cc::callJSfunc("onPurchasesUpdated", billingResult, std::vector()); } } -void JniBillingHelper::onConsumeResponse(JNIEnv* env, jclass clazz, jobject billingResultObj, jstring purchaseToken) { - auto* billingResult = cc::JniBillingHelper::toBillingResult(env, billingResultObj); +void GoogleBillingHelper::onConsumeResponse(JNIEnv* env, jclass clazz, jobject billingResultObj, jstring purchaseToken) { + auto* billingResult = cc::GoogleBillingHelper::toBillingResult(env, billingResultObj); cc::callJSfunc("onConsumeResponse", billingResult, cc::StringUtils::getStringUTFCharsJNI(env, static_cast(purchaseToken))); } -void JniBillingHelper::onQueryPurchasesResponse(JNIEnv* env, jclass clazz, jobject billingResultObj, jobject purchasesListObj, jint startID) { - auto* billingResult = cc::JniBillingHelper::toBillingResult(env, billingResultObj); - std::vector purchasesList = cc::JniBillingHelper::toPurchaseList(env, purchasesListObj, startID); +void GoogleBillingHelper::onQueryPurchasesResponse(JNIEnv* env, jclass clazz, jobject billingResultObj, jobject purchasesListObj, jint startID) { + auto* billingResult = cc::GoogleBillingHelper::toBillingResult(env, billingResultObj); + std::vector purchasesList = cc::GoogleBillingHelper::toPurchaseList(env, purchasesListObj, startID); cc::callJSfunc("onQueryPurchasesResponse", billingResult, purchasesList); } -void JniBillingHelper::onAcknowledgePurchaseResponse(JNIEnv* env, jclass clazz, jobject billingResultObj) { - auto* billingResult = cc::JniBillingHelper::toBillingResult(env, billingResultObj); +void GoogleBillingHelper::onAcknowledgePurchaseResponse(JNIEnv* env, jclass clazz, jobject billingResultObj) { + auto* billingResult = cc::GoogleBillingHelper::toBillingResult(env, billingResultObj); cc::callJSfunc("onAcknowledgePurchaseResponse", billingResult); } -void JniBillingHelper::onBillingConfigResponse(JNIEnv* env, jclass clazz, jobject billingResultObj, jobject billingConfigObj) { - auto* billingResult = cc::JniBillingHelper::toBillingResult(env, billingResultObj); +void GoogleBillingHelper::onBillingConfigResponse(JNIEnv* env, jclass clazz, jobject billingResultObj, jobject billingConfigObj) { + auto* billingResult = cc::GoogleBillingHelper::toBillingResult(env, billingResultObj); cc::BillingConfig* billingConfig = nullptr; if (billingConfigObj) { - billingConfig = cc::JniBillingHelper::toBillingConfig(env, billingConfigObj); + billingConfig = cc::GoogleBillingHelper::toBillingConfig(env, billingConfigObj); } cc::callJSfunc("onBillingConfigResponse", billingResult, billingConfig); } -void JniBillingHelper::onAlternativeBillingOnlyTokenResponse(JNIEnv* env, jclass clazz, jobject billingResultObj, jobject alternativeBillingOnlyReportingDetailsObj) { - auto* billingResult = cc::JniBillingHelper::toBillingResult(env, billingResultObj); +void GoogleBillingHelper::onAlternativeBillingOnlyTokenResponse(JNIEnv* env, jclass clazz, jobject billingResultObj, jobject alternativeBillingOnlyReportingDetailsObj) { + auto* billingResult = cc::GoogleBillingHelper::toBillingResult(env, billingResultObj); cc::AlternativeBillingOnlyReportingDetails* toAlternativeBillingOnlyReporting = nullptr; if (alternativeBillingOnlyReportingDetailsObj) { - toAlternativeBillingOnlyReporting = cc::JniBillingHelper::toAlternativeBillingOnlyReportingDetails(env, alternativeBillingOnlyReportingDetailsObj); + toAlternativeBillingOnlyReporting = cc::GoogleBillingHelper::toAlternativeBillingOnlyReportingDetails(env, alternativeBillingOnlyReportingDetailsObj); } cc::callJSfunc("onAlternativeBillingOnlyTokenResponse", billingResult, toAlternativeBillingOnlyReporting); } -void JniBillingHelper::onExternalOfferReportingDetailsResponse(JNIEnv* env, jclass clazz, jobject billingResultObj, jobject externalOfferReportingDetailsObj) { - auto* billingResult = cc::JniBillingHelper::toBillingResult(env, billingResultObj); +void GoogleBillingHelper::onExternalOfferReportingDetailsResponse(JNIEnv* env, jclass clazz, jobject billingResultObj, jobject externalOfferReportingDetailsObj) { + auto* billingResult = cc::GoogleBillingHelper::toBillingResult(env, billingResultObj); cc::ExternalOfferReportingDetails* externalOfferReportingDetails = nullptr; if (externalOfferReportingDetailsObj) { - externalOfferReportingDetails = cc::JniBillingHelper::toExternalOfferReportingDetails(env, externalOfferReportingDetailsObj); + externalOfferReportingDetails = cc::GoogleBillingHelper::toExternalOfferReportingDetails(env, externalOfferReportingDetailsObj); } cc::callJSfunc("onExternalOfferReportingDetailsResponse", billingResult, externalOfferReportingDetails); } -void JniBillingHelper::onAlternativeBillingOnlyAvailabilityResponse(JNIEnv* env, jclass clazz, jobject billingResultObj) { - auto* billingResult = cc::JniBillingHelper::toBillingResult(env, billingResultObj); +void GoogleBillingHelper::onAlternativeBillingOnlyAvailabilityResponse(JNIEnv* env, jclass clazz, jobject billingResultObj) { + auto* billingResult = cc::GoogleBillingHelper::toBillingResult(env, billingResultObj); cc::callJSfunc("onAlternativeBillingOnlyAvailabilityResponse", billingResult); } -void JniBillingHelper::onExternalOfferAvailabilityResponse(JNIEnv* env, jclass clazz, jobject billingResultObj) { - auto* billingResult = cc::JniBillingHelper::toBillingResult(env, billingResultObj); +void GoogleBillingHelper::onExternalOfferAvailabilityResponse(JNIEnv* env, jclass clazz, jobject billingResultObj) { + auto* billingResult = cc::GoogleBillingHelper::toBillingResult(env, billingResultObj); cc::callJSfunc("onExternalOfferAvailabilityResponse", billingResult); } -void JniBillingHelper::onAlternativeBillingOnlyInformationDialogResponse(JNIEnv* env, jclass clazz, jobject billingResultObj) { - auto* billingResult = cc::JniBillingHelper::toBillingResult(env, billingResultObj); +void GoogleBillingHelper::onAlternativeBillingOnlyInformationDialogResponse(JNIEnv* env, jclass clazz, jobject billingResultObj) { + auto* billingResult = cc::GoogleBillingHelper::toBillingResult(env, billingResultObj); cc::callJSfunc("onAlternativeBillingOnlyInformationDialogResponse", billingResult); } -void JniBillingHelper::onExternalOfferInformationDialogResponse(JNIEnv* env, jclass clazz, jobject billingResultObj) { - auto* billingResult = cc::JniBillingHelper::toBillingResult(env, billingResultObj); +void GoogleBillingHelper::onExternalOfferInformationDialogResponse(JNIEnv* env, jclass clazz, jobject billingResultObj) { + auto* billingResult = cc::GoogleBillingHelper::toBillingResult(env, billingResultObj); cc::callJSfunc("onExternalOfferInformationDialogResponse", billingResult); } -void JniBillingHelper::onInAppMessageResponse(JNIEnv* env, jclass clazz, jobject inAppMessageResultObj) { - auto* inAppMessageResult = cc::JniBillingHelper::toInAppMessageResult(env, inAppMessageResultObj); +void GoogleBillingHelper::onInAppMessageResponse(JNIEnv* env, jclass clazz, jobject inAppMessageResultObj) { + auto* inAppMessageResult = cc::GoogleBillingHelper::toInAppMessageResult(env, inAppMessageResultObj); cc::callJSfunc("onInAppMessageResponse", inAppMessageResult); } -cc::BillingResult* JniBillingHelper::toBillingResult(JNIEnv* env, jobject obj) { +cc::BillingResult* GoogleBillingHelper::toBillingResult(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto* billingResult = ccnew cc::BillingResult; billingResult->debugMessage = callStringMethod(env, clazz, obj, "getDebugMessage"); @@ -359,7 +359,7 @@ cc::BillingResult* JniBillingHelper::toBillingResult(JNIEnv* env, jobject obj) { return billingResult; } -cc::OneTimePurchaseOfferDetails* JniBillingHelper::toOneTimePurchaseOfferDetails(JNIEnv* env, jobject obj) { +cc::OneTimePurchaseOfferDetails* GoogleBillingHelper::toOneTimePurchaseOfferDetails(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto oneTimePurchaseOfferDetails = new cc::OneTimePurchaseOfferDetails; oneTimePurchaseOfferDetails->formattedPrice = callStringMethod(env, clazz, obj, "getFormattedPrice"); @@ -368,7 +368,7 @@ cc::OneTimePurchaseOfferDetails* JniBillingHelper::toOneTimePurchaseOfferDetails return oneTimePurchaseOfferDetails; } -cc::InstallmentPlanDetails* JniBillingHelper::toInstallmentPlanDetails(JNIEnv* env, jobject obj) { +cc::InstallmentPlanDetails* GoogleBillingHelper::toInstallmentPlanDetails(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto* installmentPlanDetails = new cc::InstallmentPlanDetails; installmentPlanDetails->installmentPlanCommitmentPaymentsCount = callIntMethod(env, clazz, obj, "getInstallmentPlanCommitmentPaymentsCount"); @@ -376,7 +376,7 @@ cc::InstallmentPlanDetails* JniBillingHelper::toInstallmentPlanDetails(JNIEnv* e return installmentPlanDetails; } -cc::PricingPhase* JniBillingHelper::toPricingPhase(JNIEnv* env, jobject obj) { +cc::PricingPhase* GoogleBillingHelper::toPricingPhase(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto* pricingPhase = new cc::PricingPhase; @@ -389,7 +389,7 @@ cc::PricingPhase* JniBillingHelper::toPricingPhase(JNIEnv* env, jobject obj) { return pricingPhase; } -cc::PricingPhases* JniBillingHelper::toPricingPhases(JNIEnv* env, jobject obj) { +cc::PricingPhases* GoogleBillingHelper::toPricingPhases(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto* pricingPhases = new cc::PricingPhases; @@ -406,7 +406,7 @@ cc::PricingPhases* JniBillingHelper::toPricingPhases(JNIEnv* env, jobject obj) { return pricingPhases; } -cc::SubscriptionOfferDetails* JniBillingHelper::toSubscriptionOfferDetails(JNIEnv* env, jobject obj) { +cc::SubscriptionOfferDetails* GoogleBillingHelper::toSubscriptionOfferDetails(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto* details = ccnew cc::SubscriptionOfferDetails; details->basePlanId = callStringMethod(env, clazz, obj, @@ -434,21 +434,21 @@ cc::SubscriptionOfferDetails* JniBillingHelper::toSubscriptionOfferDetails(JNIEn return details; } -std::vector JniBillingHelper::toProductDetailList(JNIEnv* env, jobject productListObj, jint startID) { +std::vector GoogleBillingHelper::toProductDetailList(JNIEnv* env, jobject productListObj, jint startID) { jclass clazz = env->GetObjectClass(productListObj); jmethodID listGetMethod = env->GetMethodID(clazz, "get", "(I)Ljava/lang/Object;"); int size = callIntMethod(env, clazz, productListObj, "size"); std::vector productDetailsList; for (int i = 0; i < size; ++i) { jobject productDetailObj = env->CallObjectMethod(productListObj, listGetMethod, i); - cc::ProductDetails* productDetails = cc::JniBillingHelper::toProductDetail(env, productDetailObj); + cc::ProductDetails* productDetails = cc::GoogleBillingHelper::toProductDetail(env, productDetailObj); productDetails->_id = startID++; productDetailsList.push_back(productDetails); } return std::move(productDetailsList); } -cc::ProductDetails* JniBillingHelper::toProductDetail(JNIEnv* env, jobject productObj) { +cc::ProductDetails* GoogleBillingHelper::toProductDetail(JNIEnv* env, jobject productObj) { jclass clazz = env->GetObjectClass(productObj); auto* productDetails = new cc::ProductDetails; @@ -483,7 +483,7 @@ cc::ProductDetails* JniBillingHelper::toProductDetail(JNIEnv* env, jobject produ return productDetails; } -cc::AccountIdentifiers* JniBillingHelper::toAccountIdentifiers(JNIEnv* env, jobject obj) { +cc::AccountIdentifiers* GoogleBillingHelper::toAccountIdentifiers(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto* accountIdentifiers = new cc::AccountIdentifiers; accountIdentifiers->obfuscatedAccountId = callStringMethod(env, clazz, obj, "getObfuscatedAccountId"); @@ -491,7 +491,7 @@ cc::AccountIdentifiers* JniBillingHelper::toAccountIdentifiers(JNIEnv* env, jobj return accountIdentifiers; } -cc::PendingPurchaseUpdate* JniBillingHelper::toPendingPurchaseUpdate(JNIEnv* env, jobject obj) { +cc::PendingPurchaseUpdate* GoogleBillingHelper::toPendingPurchaseUpdate(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto* pendingPurchaseUpdate = new cc::PendingPurchaseUpdate; jmethodID methodId = env->GetMethodID(clazz, "getProducts", "()Ljava/util/ArrayList;"); @@ -507,21 +507,21 @@ cc::PendingPurchaseUpdate* JniBillingHelper::toPendingPurchaseUpdate(JNIEnv* env return pendingPurchaseUpdate; } -std::vector JniBillingHelper::toPurchaseList(JNIEnv* env, jobject productsListObj, jint startID) { +std::vector GoogleBillingHelper::toPurchaseList(JNIEnv* env, jobject productsListObj, jint startID) { jclass clazz = env->GetObjectClass(productsListObj); jmethodID listGetMethod = env->GetMethodID(clazz, "get", "(I)Ljava/lang/Object;"); int size = callIntMethod(env, clazz, productsListObj, "size"); std::vector purchases; for (int i = 0; i < size; ++i) { jobject purchaseObj = env->CallObjectMethod(productsListObj, listGetMethod, i); - cc::Purchase* purchase = cc::JniBillingHelper::toPurchase(env, purchaseObj); + cc::Purchase* purchase = cc::GoogleBillingHelper::toPurchase(env, purchaseObj); purchase->_id = startID++; purchases.push_back(purchase); } return std::move(purchases); } -cc::Purchase* JniBillingHelper::toPurchase(JNIEnv* env, jobject purchaseObj) { +cc::Purchase* GoogleBillingHelper::toPurchase(JNIEnv* env, jobject purchaseObj) { jclass clazz = env->GetObjectClass(purchaseObj); auto* purchase = new cc::Purchase; @@ -564,28 +564,28 @@ cc::Purchase* JniBillingHelper::toPurchase(JNIEnv* env, jobject purchaseObj) { return purchase; } -cc::BillingConfig* JniBillingHelper::toBillingConfig(JNIEnv* env, jobject obj) { +cc::BillingConfig* GoogleBillingHelper::toBillingConfig(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto* billingConfig = new cc::BillingConfig; billingConfig->countryCode = callStringMethod(env, clazz, obj, "getCountryCode"); return billingConfig; } -cc::AlternativeBillingOnlyReportingDetails* JniBillingHelper::toAlternativeBillingOnlyReportingDetails(JNIEnv* env, jobject obj) { +cc::AlternativeBillingOnlyReportingDetails* GoogleBillingHelper::toAlternativeBillingOnlyReportingDetails(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto* alternativeBillingOnlyReportingDetails = new cc::AlternativeBillingOnlyReportingDetails; alternativeBillingOnlyReportingDetails->externalTransactionToken = callStringMethod(env, clazz, obj, "getExternalTransactionToken"); return alternativeBillingOnlyReportingDetails; } -cc::ExternalOfferReportingDetails* JniBillingHelper::toExternalOfferReportingDetails(JNIEnv* env, jobject obj) { +cc::ExternalOfferReportingDetails* GoogleBillingHelper::toExternalOfferReportingDetails(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto* externalOfferReportingDetails = new cc::ExternalOfferReportingDetails; externalOfferReportingDetails->externalTransactionToken = callStringMethod(env, clazz, obj, "getExternalTransactionToken"); return externalOfferReportingDetails; } -cc::InAppMessageResult* JniBillingHelper::toInAppMessageResult(JNIEnv* env, jobject obj) { +cc::InAppMessageResult* GoogleBillingHelper::toInAppMessageResult(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto* inAppMessageResult = new cc::InAppMessageResult; inAppMessageResult->responseCode = callIntMethod(env, clazz, obj, "getResponseCode"); diff --git a/native/cocos/platform/android/modules/google_play/billing/JniBillingHelper.h b/native/vendor/google/billing/GoogleBillingHelper.h similarity index 99% rename from native/cocos/platform/android/modules/google_play/billing/JniBillingHelper.h rename to native/vendor/google/billing/GoogleBillingHelper.h index 33df0534b29..bd73a35a9b5 100644 --- a/native/cocos/platform/android/modules/google_play/billing/JniBillingHelper.h +++ b/native/vendor/google/billing/GoogleBillingHelper.h @@ -46,7 +46,7 @@ class AlternativeBillingOnlyReportingDetails; class ExternalOfferReportingDetails; class InAppMessageResult; -class CC_DLL JniBillingHelper { +class CC_DLL GoogleBillingHelper { public: static void removeProductDetails(int productDetailsID); static void removePurchase(int purchaseID); diff --git a/scripts/native-pack-tool/source/platforms/google-play.ts b/scripts/native-pack-tool/source/platforms/google-play.ts index 1ce044567aa..dc02b01b25e 100644 --- a/scripts/native-pack-tool/source/platforms/google-play.ts +++ b/scripts/native-pack-tool/source/platforms/google-play.ts @@ -13,6 +13,21 @@ export interface IOrientation { portrait: boolean; upsideDown: boolean; } +/** + * 默认 CustomIconList,存放在 static 下的 icon 路径 + */ +export interface ICustomIconDpi { + fileName: string; + dirName: string; + dpi: number; + path: string; +} + +export interface ICustomIconInfo { + type: string, + display: string, + list: ICustomIconDpi[] +} export interface IAndroidParams { packageName: string; @@ -34,9 +49,13 @@ export interface IAndroidParams { orientation: IOrientation; appBundle: boolean; resizeableActivity: boolean; + googleBilling: boolean; + customIconInfo: ICustomIconInfo, } const DefaultAPILevel = 27; + + export class GooglePlayPackTool extends NativePackTool { params!: CocosParams; @@ -59,6 +78,26 @@ export class GooglePlayPackTool extends NativePackTool { } else { this.validateNativeDir(); } + + // 替换icon + await this.copyCustomIcons(this.params.platformParams.customIconInfo); + } + + /** + * 拷贝自定义 ICON + * @param type - 类型自定义还是默认 + * @param buildDir - 构建路径 + * @param outputName - 用于获取 CustomIcon + */ + protected async copyCustomIcons(customIconInfo: ICustomIconInfo) { + const tasks = customIconInfo.list.map(async (item) => { + const distRoot = ps.join(this.paths.platformTemplateDirInPrj, 'res', item.dirName); + + await fs.ensureDir(distRoot); + const filePath = ps.join(distRoot, item.fileName); + await fs.copy(item.path, filePath); + }); + await Promise.all(tasks); } protected validatePlatformDirectory(missing: string[]): void { @@ -364,6 +403,9 @@ export class GooglePlayPackTool extends NativePackTool { content = content.replace(/APPLICATION_ID=.*/, `APPLICATION_ID=${options.packageName}`); content = content.replace(/NATIVE_DIR=.*/, `NATIVE_DIR=${cchelper.fixPath(this.paths.platformTemplateDirInPrj)}`); + content = content.replace(/PROP_ENABLE_GOOGLE_BILLING=.*/, `PROP_ENABLE_GOOGLE_BILLING=${options.googleBilling ? "true" : "false"}`); + + if (process.platform === 'win32') { options.ndkPath = options.ndkPath.replace(/\\/g, '\\\\'); diff --git a/templates/google-play/build/gradle.properties b/templates/google-play/build/gradle.properties index ba524fd48e9..c52b0a50848 100644 --- a/templates/google-play/build/gradle.properties +++ b/templates/google-play/build/gradle.properties @@ -53,7 +53,7 @@ PROP_IS_DEBUG=true COCOS_ENGINE_PATH= # Billing -PROP_ENABLE_BILLING=true +PROP_ENABLE_GOOGLE_BILLING=true # Res path RES_PATH= diff --git a/vendor/google/play/billing/billing.ts b/vendor/google/billing/billing.ts similarity index 91% rename from vendor/google/play/billing/billing.ts rename to vendor/google/billing/billing.ts index d2fc57f3397..c9545f20ca2 100644 --- a/vendor/google/play/billing/billing.ts +++ b/vendor/google/billing/billing.ts @@ -22,7 +22,7 @@ THE SOFTWARE. *****************************************************************************/ import { JSB } from 'internal:constants'; -import { EventTarget } from '../../../../cocos/core/event'; +import { EventTarget } from '../../../cocos/core/event'; interface BillingEventMap { [google.BillingEventType.BILLING_SETUP_FINISHED]: (result: google.BillingResult) => void, @@ -48,7 +48,7 @@ interface BillingEventMap { class Billing { private _eventTarget: EventTarget = new EventTarget(); constructor () { - if (!JSB || !jsb.billing) { + if (!JSB || !jsb.googleBilling) { return; } jsb.onBillingSetupFinished = (result: google.BillingResult): void => { @@ -132,7 +132,7 @@ class Billing { * @zh 异步启动 BillingClient 设置过程。 */ public startConnection (): void { - jsb.billing?.startConnection(); + jsb.googleBilling?.startConnection(); } /** @@ -140,7 +140,7 @@ class Billing { * @zh 关闭连接并释放所有持有的资源,例如服务连接。 */ public endConnection (): void { - jsb.billing?.endConnection(); + jsb.googleBilling?.endConnection(); } /** @@ -148,9 +148,9 @@ class Billing { * @zh 获取当前billing客户端连接状态。 */ public getConnectionState (): number { - if (jsb.billing) { + if (jsb.googleBilling) { // eslint-disable-next-line @typescript-eslint/no-unsafe-return - return jsb.billing.getConnectionState(); + return jsb.googleBilling.getConnectionState(); } return google.ConnectionState.DISCONNECTED; } @@ -162,9 +162,9 @@ class Billing { 如果客户端当前已连接到服务,则返回 true,否则返回 false。 */ public isReady (): boolean { - if (jsb.billing) { + if (jsb.googleBilling) { // eslint-disable-next-line @typescript-eslint/no-unsafe-return - return jsb.billing.isReady(); + return jsb.googleBilling.isReady(); } return false; } @@ -178,11 +178,11 @@ class Billing { */ public queryProductDetailsParams (productId: string[] | string, productType: google.ProductType): void { if (productId instanceof Array) { - jsb.billing?.queryProductDetailsParams(productId, productType); + jsb.googleBilling?.queryProductDetailsParams(productId, productType); } else { const productIdList: string[] = []; productIdList.push(productId); - jsb.billing?.queryProductDetailsParams(productIdList, productType); + jsb.googleBilling?.queryProductDetailsParams(productIdList, productType); } } @@ -194,11 +194,11 @@ class Billing { */ public launchBillingFlow (productDetails: google.ProductDetails[] | google.ProductDetails, selectedOfferToken: string | null): void { if (productDetails instanceof Array) { - jsb.billing?.launchBillingFlow(productDetails, selectedOfferToken); + jsb.googleBilling?.launchBillingFlow(productDetails, selectedOfferToken); } else { const productDetailsList: google.ProductDetails[] = []; productDetailsList.push(productDetails); - jsb.billing?.launchBillingFlow(productDetailsList, selectedOfferToken); + jsb.googleBilling?.launchBillingFlow(productDetailsList, selectedOfferToken); } } @@ -209,11 +209,11 @@ class Billing { */ public consumePurchases (purchase: google.Purchase[] | google.Purchase): void { if (purchase instanceof Array) { - jsb.billing?.consumePurchases(purchase); + jsb.googleBilling?.consumePurchases(purchase); } else { const purchaseList: google.Purchase[] = []; purchaseList.push(purchase); - jsb.billing?.consumePurchases(purchaseList); + jsb.googleBilling?.consumePurchases(purchaseList); } } @@ -224,11 +224,11 @@ class Billing { */ public acknowledgePurchase (purchase: google.Purchase[] | google.Purchase): void { if (purchase instanceof Array) { - jsb.billing?.acknowledgePurchase(purchase); + jsb.googleBilling?.acknowledgePurchase(purchase); } else { const purchaseList: google.Purchase[] = []; purchaseList.push(purchase); - jsb.billing?.acknowledgePurchase(purchaseList); + jsb.googleBilling?.acknowledgePurchase(purchaseList); } } @@ -238,7 +238,7 @@ class Billing { * @param productType @zh 产品类型 @en Product type. */ public queryPurchasesAsync (productType: google.ProductType): void { - jsb.billing?.queryPurchasesAsync(productType); + jsb.googleBilling?.queryPurchasesAsync(productType); } /** @@ -246,7 +246,7 @@ class Billing { * @zh 获取计费配置,其中存储用于执行计费操作的配置。 */ public getBillingConfigAsync (): void { - jsb.billing?.getBillingConfigAsync(); + jsb.googleBilling?.getBillingConfigAsync(); } /** @@ -255,7 +255,7 @@ class Billing { * @zh 创建仅限替代结算的购买详情,可用于报告通过替代结算进行的交易,而无需用户选择使用 Google Play 结算。 */ public createAlternativeBillingOnlyReportingDetailsAsync (): void { - jsb.billing?.createAlternativeBillingOnlyReportingDetailsAsync(); + jsb.googleBilling?.createAlternativeBillingOnlyReportingDetailsAsync(); } /** @@ -263,7 +263,7 @@ class Billing { * @zh 检查是否可以提供替代结算方式,而无需用户选择使用 Google Play 结算方式。 */ public isAlternativeBillingOnlyAvailableAsync (): void { - jsb.billing?.isAlternativeBillingOnlyAvailableAsync(); + jsb.googleBilling?.isAlternativeBillingOnlyAvailableAsync(); } /** @@ -271,7 +271,7 @@ class Billing { * @zh 创建可用于报告通过外部报价进行的交易的购买详情。 */ public createExternalOfferReportingDetailsAsync (): void { - jsb.billing?.createExternalOfferReportingDetailsAsync(); + jsb.googleBilling?.createExternalOfferReportingDetailsAsync(); } /** @@ -279,7 +279,7 @@ class Billing { * @zh 检查提供外部报价的可用性。 */ public isExternalOfferAvailableAsync (): void { - jsb.billing?.isExternalOfferAvailableAsync(); + jsb.googleBilling?.isExternalOfferAvailableAsync(); } /** @@ -288,9 +288,9 @@ class Billing { * @param feature @zh 功能特性 @en feature. */ public isFeatureSupported (feature: string): google.BillingResult | null { - if (jsb.billing) { + if (jsb.googleBilling) { // eslint-disable-next-line @typescript-eslint/no-unsafe-return - return jsb.billing.isFeatureSupported(feature); + return jsb.googleBilling.isFeatureSupported(feature); } return null; } @@ -300,9 +300,9 @@ class Billing { * @zh 在调用应用程序顶部显示仅显示备用计费信息对话框。 */ public showAlternativeBillingOnlyInformationDialog (): google.BillingResult | null { - if (jsb.billing) { + if (jsb.googleBilling) { // eslint-disable-next-line @typescript-eslint/no-unsafe-return - return jsb.billing.showAlternativeBillingOnlyInformationDialog(); + return jsb.googleBilling.showAlternativeBillingOnlyInformationDialog(); } return null; } @@ -312,9 +312,9 @@ class Billing { * @zh 在调用应用程序顶部显示外部优惠信息对话框。 */ public showExternalOfferInformationDialog (): google.BillingResult | null { - if (jsb.billing) { + if (jsb.googleBilling) { // eslint-disable-next-line @typescript-eslint/no-unsafe-return - return jsb.billing.showExternalOfferInformationDialog(); + return jsb.googleBilling.showExternalOfferInformationDialog(); } return null; } @@ -324,9 +324,9 @@ class Billing { * @zh 在调用应用程序上叠加与计费相关的消息。 */ public showInAppMessages (): google.BillingResult | null { - if (jsb.billing) { + if (jsb.googleBilling) { // eslint-disable-next-line @typescript-eslint/no-unsafe-return - return jsb.billing.showInAppMessages(); + return jsb.googleBilling.showInAppMessages(); } return null; } diff --git a/vendor/google/play/index.ts b/vendor/google/index.ts similarity index 100% rename from vendor/google/play/index.ts rename to vendor/google/index.ts