Skip to content

Commit 4acfd2d

Browse files
committed
Import android-games-sdk changes for 4.0.0
This imports the SDK from commit 090732c3ca7d8b47ed39e028081d685e4097db7f, from: https://github.com/rust-mobile/android-games-sdk/commits/android-activity-4.0.0 This imports a patch to revert the recent addition of a `_rust_glue_on_create_hook` in favour of fixing the Rust wrapper for `GameActivity_onCreate` which is more consistent with the `ANativeActivity_onCreate` entrypoint that we have in the `native-activity` backend. This also: - Fixes a related rerun-if-changed path in build.rs - Removes the reference to _rust_glue_on_create_hook src/game_activity/mod.rs
1 parent b042af6 commit 4acfd2d

10 files changed

Lines changed: 18 additions & 51 deletions

File tree

android-activity/android-games-sdk/game-activity/prefab-src/modules/game-activity/include/game-activity/GameActivity.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ typedef void GameActivity_createFunc(GameActivity* activity, void* savedState,
322322
* "android.app.func_name" string meta-data in your manifest to use a different
323323
* function.
324324
*/
325-
extern GameActivity_createFunc GameActivity_onCreate_C;
325+
extern GameActivity_createFunc GameActivity_onCreate;
326326

327327
/**
328328
* Finish the given activity. Its finish() method will be called, causing it

android-activity/android-games-sdk/game-activity/prefab-src/modules/game-activity/include/game-activity/native_app_glue/android_native_app_glue.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -514,16 +514,6 @@ void android_app_clear_motion_events(struct android_input_buffer* inputBuffer);
514514
*/
515515
void android_app_clear_key_events(struct android_input_buffer* inputBuffer);
516516

517-
/**
518-
* A hook that is called within Activity.onCreate, before the android_main
519-
* thread has been spawned.
520-
*
521-
* This gives the Rust glue code a chance to perform any necessary
522-
* initialization that needs to run from the Java main/UI thread, before the
523-
* android_main thread is started.
524-
*/
525-
extern void _rust_glue_on_create_hook(struct android_app* app);
526-
527517
/**
528518
* This is a springboard into the Rust glue layer that wraps calling the
529519
* main entry for the app itself.

android-activity/android-games-sdk/game-activity/prefab-src/modules/game-activity/src/game-activity/GameActivity.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ static jlong initializeNativeCode_native(
538538
// read configuration for the first time
539539
readConfigurationValues(code, javaConfig);
540540

541-
GameActivity_onCreate_C(code, rawSavedState, rawSavedSize);
541+
GameActivity_onCreate(code, rawSavedState, rawSavedSize);
542542

543543
code->gameTextInput = GameTextInput_init(env, 0);
544544
GameTextInput_setEventCallback(code->gameTextInput,

android-activity/android-games-sdk/game-activity/prefab-src/modules/game-activity/src/game-activity/native_app_glue/android_native_app_glue.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,6 @@ static void* android_app_entry(void* param) {
224224
android_app->cmdPollSource.app = android_app;
225225
android_app->cmdPollSource.process = process_cmd;
226226

227-
_rust_glue_on_create_hook(android_app);
228-
229227
ALooper* looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
230228
ALooper_addFd(looper, android_app->msgread, LOOPER_ID_MAIN,
231229
ALOOPER_EVENT_INPUT, NULL, &android_app->cmdPollSource);
@@ -756,10 +754,9 @@ static bool onEditorAction(GameActivity* activity, int action) {
756754
return true;
757755
}
758756

759-
// XXX: This symbol is renamed with a _C suffix and then re-exported from
760-
// Rust because Rust/Cargo don't give us a way to directly export symbols
761-
// from C/C++ code: https://github.com/rust-lang/rfcs/issues/2771
762-
//
757+
// XXX: This symbol is renamed with a _C suffix so we can implement
758+
// `GameActivity_onCreate` as a wrapper in Rust that does some additional setup
759+
// before calling this function,
763760
JNIEXPORT
764761
void GameActivity_onCreate_C(GameActivity* activity, void* savedState,
765762
size_t savedStateSize) {

android-activity/build.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@ fn build_glue_for_game_activity() {
99
format!("{android_games_sdk}/game-text-input/prefab-src/modules/game-text-input/{src_inc}/game-text-input/{name}")
1010
};
1111

12-
for f in ["GameActivity.cpp", "GameActivityEvents.cpp"] {
12+
for f in [
13+
"GameActivity.cpp",
14+
"GameActivityEvents.cpp",
15+
"GameActivityEvents_internal.h",
16+
] {
1317
println!("cargo:rerun-if-changed={}", activity_path("src", f));
1418
}
1519

1620
for f in [
1721
"GameActivity.h",
1822
"GameActivityEvents.h",
1923
"GameActivityLog.h",
20-
"GameActivityEvents_internal.h",
2124
] {
2225
println!("cargo:rerun-if-changed={}", activity_path("include", f));
2326
}

android-activity/src/game_activity/ffi_aarch64.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ pub const __ANDROID_API_V__: u32 = 35;
3838
pub const __ANDROID_NDK__: u32 = 1;
3939
pub const __NDK_MAJOR__: u32 = 29;
4040
pub const __NDK_MINOR__: u32 = 0;
41-
pub const __NDK_BETA__: u32 = 4;
42-
pub const __NDK_BUILD__: u32 = 14033849;
41+
pub const __NDK_BETA__: u32 = 0;
42+
pub const __NDK_BUILD__: u32 = 14206865;
4343
pub const __NDK_CANARY__: u32 = 0;
4444
pub const WCHAR_MIN: u8 = 0u8;
4545
pub const INT8_MIN: i32 = -128;
@@ -4854,10 +4854,6 @@ unsafe extern "C" {
48544854
#[doc = " Clear the array of key events that were waiting to be handled, and release\n each of them.\n\n This method should be called after you have processed the key up events in\n your game loop. You should handle events at each iteration of your game loop."]
48554855
pub fn android_app_clear_key_events(inputBuffer: *mut android_input_buffer);
48564856
}
4857-
unsafe extern "C" {
4858-
#[doc = " A hook that is called within Activity.onCreate, before the android_main\n thread has been spawned.\n\n This gives the Rust glue code a chance to perform any necessary\n initialization that needs to run from the Java main/UI thread, before the\n android_main thread is started."]
4859-
pub fn _rust_glue_on_create_hook(app: *mut android_app);
4860-
}
48614857
unsafe extern "C" {
48624858
#[doc = " This is a springboard into the Rust glue layer that wraps calling the\n main entry for the app itself."]
48634859
pub fn _rust_glue_entry(app: *mut android_app);

android-activity/src/game_activity/ffi_arm.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ pub const __ANDROID_API_V__: u32 = 35;
165165
pub const __ANDROID_NDK__: u32 = 1;
166166
pub const __NDK_MAJOR__: u32 = 29;
167167
pub const __NDK_MINOR__: u32 = 0;
168-
pub const __NDK_BETA__: u32 = 4;
169-
pub const __NDK_BUILD__: u32 = 14033849;
168+
pub const __NDK_BETA__: u32 = 0;
169+
pub const __NDK_BUILD__: u32 = 14206865;
170170
pub const __NDK_CANARY__: u32 = 0;
171171
pub const WCHAR_MIN: u8 = 0u8;
172172
pub const INT8_MIN: i32 = -128;
@@ -5266,10 +5266,6 @@ unsafe extern "C" {
52665266
#[doc = " Clear the array of key events that were waiting to be handled, and release\n each of them.\n\n This method should be called after you have processed the key up events in\n your game loop. You should handle events at each iteration of your game loop."]
52675267
pub fn android_app_clear_key_events(inputBuffer: *mut android_input_buffer);
52685268
}
5269-
unsafe extern "C" {
5270-
#[doc = " A hook that is called within Activity.onCreate, before the android_main\n thread has been spawned.\n\n This gives the Rust glue code a chance to perform any necessary\n initialization that needs to run from the Java main/UI thread, before the\n android_main thread is started."]
5271-
pub fn _rust_glue_on_create_hook(app: *mut android_app);
5272-
}
52735269
unsafe extern "C" {
52745270
#[doc = " This is a springboard into the Rust glue layer that wraps calling the\n main entry for the app itself."]
52755271
pub fn _rust_glue_entry(app: *mut android_app);

android-activity/src/game_activity/ffi_i686.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ pub const __ANDROID_API_V__: u32 = 35;
2828
pub const __ANDROID_NDK__: u32 = 1;
2929
pub const __NDK_MAJOR__: u32 = 29;
3030
pub const __NDK_MINOR__: u32 = 0;
31-
pub const __NDK_BETA__: u32 = 4;
32-
pub const __NDK_BUILD__: u32 = 14033849;
31+
pub const __NDK_BETA__: u32 = 0;
32+
pub const __NDK_BUILD__: u32 = 14206865;
3333
pub const __NDK_CANARY__: u32 = 0;
3434
pub const INT8_MIN: i32 = -128;
3535
pub const INT8_MAX: u32 = 127;
@@ -5306,10 +5306,6 @@ unsafe extern "C" {
53065306
#[doc = " Clear the array of key events that were waiting to be handled, and release\n each of them.\n\n This method should be called after you have processed the key up events in\n your game loop. You should handle events at each iteration of your game loop."]
53075307
pub fn android_app_clear_key_events(inputBuffer: *mut android_input_buffer);
53085308
}
5309-
unsafe extern "C" {
5310-
#[doc = " A hook that is called within Activity.onCreate, before the android_main\n thread has been spawned.\n\n This gives the Rust glue code a chance to perform any necessary\n initialization that needs to run from the Java main/UI thread, before the\n android_main thread is started."]
5311-
pub fn _rust_glue_on_create_hook(app: *mut android_app);
5312-
}
53135309
unsafe extern "C" {
53145310
#[doc = " This is a springboard into the Rust glue layer that wraps calling the\n main entry for the app itself."]
53155311
pub fn _rust_glue_entry(app: *mut android_app);

android-activity/src/game_activity/ffi_x86_64.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ pub const __ANDROID_API_V__: u32 = 35;
2828
pub const __ANDROID_NDK__: u32 = 1;
2929
pub const __NDK_MAJOR__: u32 = 29;
3030
pub const __NDK_MINOR__: u32 = 0;
31-
pub const __NDK_BETA__: u32 = 4;
32-
pub const __NDK_BUILD__: u32 = 14033849;
31+
pub const __NDK_BETA__: u32 = 0;
32+
pub const __NDK_BUILD__: u32 = 14206865;
3333
pub const __NDK_CANARY__: u32 = 0;
3434
pub const INT8_MIN: i32 = -128;
3535
pub const INT8_MAX: u32 = 127;
@@ -5335,10 +5335,6 @@ unsafe extern "C" {
53355335
#[doc = " Clear the array of key events that were waiting to be handled, and release\n each of them.\n\n This method should be called after you have processed the key up events in\n your game loop. You should handle events at each iteration of your game loop."]
53365336
pub fn android_app_clear_key_events(inputBuffer: *mut android_input_buffer);
53375337
}
5338-
unsafe extern "C" {
5339-
#[doc = " A hook that is called within Activity.onCreate, before the android_main\n thread has been spawned.\n\n This gives the Rust glue code a chance to perform any necessary\n initialization that needs to run from the Java main/UI thread, before the\n android_main thread is started."]
5340-
pub fn _rust_glue_on_create_hook(app: *mut android_app);
5341-
}
53425338
unsafe extern "C" {
53435339
#[doc = " This is a springboard into the Rust glue layer that wraps calling the\n main entry for the app itself."]
53445340
pub fn _rust_glue_entry(app: *mut android_app);

android-activity/src/game_activity/mod.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,13 +1156,6 @@ extern "Rust" {
11561156
pub fn android_main(app: AndroidApp);
11571157
}
11581158

1159-
// This is called via `GameActivity.onCreate`, from the Java main/UI thread,
1160-
// before spawning an `android_main` thread.
1161-
#[no_mangle]
1162-
pub unsafe extern "C" fn _rust_glue_on_create_hook(_game_activity_glue: *mut ffi::android_app) {
1163-
// Noop currently
1164-
}
1165-
11661159
// This is a spring board between android_native_app_glue and the user's
11671160
// `android_main` function. This is run on a dedicated thread spawned
11681161
// by android_native_app_glue.

0 commit comments

Comments
 (0)