Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate the Google Play Billing Library into engine #17918

Merged
merged 15 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
479 changes: 479 additions & 0 deletions @types/jsb.d.ts

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions cc.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@
"modules": ["tiled-map"],
"dependentModules": ["2d"]
},
"vendor": {
"modules": ["vendor-google"]
},
"spine": {
"modules": ["spine"],
"dependentAssets": [
Expand Down
5 changes: 3 additions & 2 deletions cocos/native-binding/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

/* eslint-disable @typescript-eslint/no-namespace */

import type { Color, Vec2 } from '../core';

export * from 'internal:native';
Expand Down Expand Up @@ -1436,7 +1435,9 @@ export declare namespace native {
*/
const adpf: {
/**
* @en Provides an estimate of how much thermal headroom the device currently has before hitting severe throttling. The value range is a non-negative float, where 0.0 represents a fixed distance from overheating, 1.0 indicates the device will be severely throttled, and values greater than 1.0 may imply even heavier throttling.
* @en Provides an estimate of how much thermal headroom the device currently has before hitting severe throttling.
* The value range is a non-negative float, where 0.0 represents a fixed distance from overheating, 1.0 indicates
* the device will be severely throttled, and values greater than 1.0 may imply even heavier throttling.
* @zh 提供设备在达到严重节流之前当前有多少热余量的估计值。值的范围是非负浮点数,其中0.0表示距离过热的固定距离,1.0表示设备将被严重限制,而大于1.0的值可能表示更重的限制。
* @see https://developer.android.com/ndk/reference/group/thermal#group___thermal_1ga1055f6c8d5910a1904162bea75807314
*/
Expand Down
9 changes: 9 additions & 0 deletions editor/engine-features/render-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,15 @@
"2d"
]
},
"vendor": {
"default": false,
"label": "i18n:ENGINE.features.vendor.label",
"description": "i18n:ENGINE.features.vendor.description",
"enginePlugin": false,
"isNativeModule": true,
"cmakeConfig": "USE_VENDOR",
"hidden": true
},
"spine": {
"default": true,
"label": "i18n:ENGINE.features.spine.label",
Expand Down
6 changes: 6 additions & 0 deletions editor/engine-features/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@
"tiled-map": {
"$ref": "#/definitions/IFeatureItem"
},
"vendor": {
"$ref": "#/definitions/IFeatureItem"
},
"tween": {
"$ref": "#/definitions/IFeatureItem"
},
Expand Down Expand Up @@ -365,6 +368,9 @@
"tiled-map": {
"$ref": "#/definitions/BaseItem"
},
"vendor": {
"$ref": "#/definitions/BaseItem"
},
"tween": {
"$ref": "#/definitions/BaseItem"
},
Expand Down
4 changes: 4 additions & 0 deletions editor/i18n/en/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,10 @@ module.exports = link(mixin({
label: "Tiled Map",
description: "Tiled map support.",
},
vendor: {
label: "Vendor",
description: "Vendor support.",
},
spine: {
label: "Spine Animation",
description: "Spine Animation support.",
Expand Down
4 changes: 4 additions & 0 deletions editor/i18n/zh/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,10 @@ module.exports = link(mixin({
label: "Tiled 地图",
description: "Tiled 地图支持。",
},
vendor: {
label: "Vendor",
description: "Vendor 支持.",
},
spine: {
label: "Spine 动画",
description: "Spine 动画支持。",
Expand Down
26 changes: 26 additions & 0 deletions exports/vendor-google.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Copyright (c) 2024 Xiamen Yaji Software Co., Ltd.

https://www.cocos.com/

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.

The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.

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.
*/

export * from '../vendor/google';
42 changes: 38 additions & 4 deletions native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ cc_set_if_undefined(USE_GEOMETRY_RENDERER ON)
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_BILLING OFF)

if(ANDROID AND NOT DEFINED USE_CCACHE)
if("$ENV{COCOS_USE_CCACHE}" STREQUAL "1")
Expand Down Expand Up @@ -565,8 +566,6 @@ elseif(ANDROID)
cocos/platform/android/AndroidPlatform.cpp
cocos/platform/android/AndroidPlatform.h
cocos/platform/android/AndroidKeyCodes.cpp
cocos/platform/android/adpf_manager.h
cocos/platform/android/adpf_manager.cpp
)
elseif(OPENHARMONY)
cocos_source_files(
Expand Down Expand Up @@ -601,6 +600,13 @@ elseif(IOS)
)
endif()

if(USE_ADPF)
cocos_source_files(
cocos/platform/android/adpf_manager.h
cocos/platform/android/adpf_manager.cpp
)
endif()

############ platform : Abstract interface
cocos_source_files(
cocos/platform/interfaces/OSInterface.h
Expand Down Expand Up @@ -754,13 +760,23 @@ elseif(ANDROID OR OHOS)
endif()
endif()

if(USE_GOOGLE_BILLING)
cocos_source_files(
vendor/google/billing/GoogleBilling.cpp
vendor/google/billing/GoogleBilling.h
vendor/google/billing/GoogleBillingHelper.cpp
vendor/google/billing/GoogleBillingHelper.h
)
endif()

if(ANDROID)
cocos_source_files(
cocos/platform/android/modules/Screen.cpp
cocos/platform/android/modules/Screen.h
cocos/platform/android/modules/System.cpp
cocos/platform/android/modules/System.h
)

elseif(OPENHARMONY)
# Because there will be a definition of OHOS in harmonyos, it is necessary to define the macro of OPENHARMONY.
elseif(OHOS)
Expand Down Expand Up @@ -1178,6 +1194,10 @@ elseif(LINUX)
)
endif()

if(USE_GOOGLE_BILLING)
list(APPEND CC_JNI_SRC_FILES ${CWD}/cocos/platform/java/jni/JniGoogleBillingHandler.cpp)
endif()

##### renderer
cocos_source_files(
cocos/renderer/core/PassUtils.h
Expand Down Expand Up @@ -2559,7 +2579,6 @@ cocos_source_files(
cocos/bindings/manual/jsb_xmlhttprequest.h
cocos/bindings/manual/jsb_pipeline_manual.h
cocos/bindings/manual/jsb_pipeline_manual.cpp
cocos/bindings/manual/jsb_adpf.cpp
)
if(USE_AUDIO)
cocos_source_files(
Expand All @@ -2583,6 +2602,19 @@ if(USE_WEBSOCKET_SERVER)
)
endif()

if(USE_ADPF)
cocos_source_files(
cocos/bindings/manual/jsb_adpf.cpp
)
endif()

if(USE_GOOGLE_BILLING)
cocos_source_files(
cocos/bindings/manual/jsb_google_billing.cpp
)

endif()

if(ANDROID)
cocos_source_files(
cocos/bindings/manual/jsb_platform_android.cpp
Expand Down Expand Up @@ -3114,6 +3146,8 @@ function(cc_apply_definations target)
$<$<BOOL:${USE_SE_NAPI}>:SCRIPT_ENGINE_TYPE=5>
$<$<BOOL:${USE_SE_JSVM}>:SCRIPT_ENGINE_TYPE=6>
$<$<OR:$<CONFIG:Debug>,$<BOOL:${CC_DEBUG_FORCE}>>:CC_DEBUG=1>
$<IF:$<BOOL:${USE_APDF}>,CC_USE_APDF=1,CC_USE_APDF=0>
$<IF:$<BOOL:${USE_GOOGLE_BILLING}>,CC_USE_GOOGLE_BILLING=1,CC_USE_GOOGLE_BILLING=0>
)
endfunction()

Expand Down
2 changes: 2 additions & 0 deletions native/cocos/bindings/manual/jsb_global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1630,7 +1630,9 @@ bool jsb_register_global_variables(se::Object *global) { // NOLINT
jsb_register_TextEncoder(global);
jsb_register_TextDecoder(global);

#if CC_USE_ADPF
jsb_register_ADPF(__jsbObj);
#endif

se::ScriptEngine::getInstance()->clearException();

Expand Down
Loading