Skip to content
This repository was archived by the owner on Jul 3, 2020. It is now read-only.

Getting access to native activity #201

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions cargo-apk/injected-glue/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ pub const MODE_UNKNOWN: i32 = 0;

//
pub type Asset = AAsset;
pub type NativeActivityType = *const ANativeActivity;
pub type NativeWindowType = *const ANativeWindow;

//
Expand Down
5 changes: 5 additions & 0 deletions cargo-apk/injected-glue/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ extern {
#[doc(hidden)]
pub mod ffi;

#[no_mangle]
pub unsafe extern fn cargo_apk_injected_glue_get_native_activity() -> *const c_void {
get_native_activity() as *const _
}

#[no_mangle]
pub unsafe extern fn cargo_apk_injected_glue_get_native_window() -> *const c_void {
get_native_window() as *const _
Expand Down
7 changes: 7 additions & 0 deletions glue/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![cfg(target_os = "android")]

extern {
fn cargo_apk_injected_glue_get_native_activity() -> *const c_void;
fn cargo_apk_injected_glue_get_native_window() -> *const c_void;
fn cargo_apk_injected_glue_add_sender(sender: *mut ());
fn cargo_apk_injected_glue_add_sender_missing(sender: *mut ());
Expand Down Expand Up @@ -117,6 +118,12 @@ pub fn add_sender_missing(sender: Sender<Event>) {
}
}

/// Returns a handle to the native activity.
#[inline]
pub unsafe fn get_native_activity() -> *const c_void {
cargo_apk_injected_glue_get_native_activity()
}

/// Returns a handle to the native window.
#[inline]
pub unsafe fn get_native_window() -> *const c_void {
Expand Down