diff --git a/cargo-apk/CHANGELOG.md b/cargo-apk/CHANGELOG.md index a00aedd3..fb0426ff 100644 --- a/cargo-apk/CHANGELOG.md +++ b/cargo-apk/CHANGELOG.md @@ -7,6 +7,7 @@ https://developer.android.com/distribute/best-practices/develop/target-sdk - Allow manifest `package` property to be provided in `Cargo.toml`. ([#236](https://github.com/rust-windowing/android-ndk-rs/pull/236)) - Add `MAIN` intent filter in `from_subcommand` instead of relying on a custom serialization function in `ndk-build`. ([#241](https://github.com/rust-windowing/android-ndk-rs/pull/241)) +- Export the sole `NativeActivity` (through `android:exported="true"`) to allow it to be started by default if targeting Android S or higher. ([#242](https://github.com/rust-windowing/android-ndk-rs/pull/242)) # 0.8.2 (2021-11-22) diff --git a/cargo-apk/README.md b/cargo-apk/README.md index 0b8f84d6..2c545416 100644 --- a/cargo-apk/README.md +++ b/cargo-apk/README.md @@ -126,6 +126,11 @@ launch_mode = "singleTop" # Defaults to "unspecified". orientation = "landscape" +# See https://developer.android.com/guide/topics/manifest/activity-element#exported +# +# Unset by default, or "true" when targeting Android >= 31 (S and up). +exported = "true" + # See https://developer.android.com/guide/topics/manifest/meta-data-element # # Note: there can be several .meta_data entries. diff --git a/cargo-apk/src/apk.rs b/cargo-apk/src/apk.rs index 32b6da90..2f8ba928 100644 --- a/cargo-apk/src/apk.rs +++ b/cargo-apk/src/apk.rs @@ -53,7 +53,7 @@ impl<'a> ApkBuilder<'a> { panic!("version_code should not be set in TOML"); } - manifest + let target_sdk_version = *manifest .android_manifest .sdk .target_sdk_version @@ -80,6 +80,13 @@ impl<'a> ApkBuilder<'a> { }); } + // Export the sole Rust activity on Android S and up, if the user didn't explicitly do so. + // Without this, apps won't start on S+. + // https://developer.android.com/about/versions/12/behavior-changes-12#exported + if target_sdk_version >= 31 { + activity.exported.get_or_insert(true); + } + Ok(Self { cmd, ndk, diff --git a/ndk-build/CHANGELOG.md b/ndk-build/CHANGELOG.md index 641dd254..06446154 100644 --- a/ndk-build/CHANGELOG.md +++ b/ndk-build/CHANGELOG.md @@ -5,6 +5,7 @@ https://developer.android.com/distribute/best-practices/develop/target-sdk - Remove default insertion of `MAIN` intent filter through a custom serialization function, this is better filled in by the default setup in `cargo-apk`. ([#241](https://github.com/rust-windowing/android-ndk-rs/pull/241)) +- Add `android:exported` attribute to the manifest's `Activity` element. ([#242](https://github.com/rust-windowing/android-ndk-rs/pull/242)) # 0.4.3 (2021-11-22) diff --git a/ndk-build/src/manifest.rs b/ndk-build/src/manifest.rs index fe4f1854..8b2306f8 100644 --- a/ndk-build/src/manifest.rs +++ b/ndk-build/src/manifest.rs @@ -93,6 +93,8 @@ pub struct Activity { pub name: String, #[serde(rename(serialize = "android:screenOrientation"))] pub orientation: Option, + #[serde(rename(serialize = "android:exported"))] + pub exported: Option, #[serde(rename(serialize = "meta-data"))] #[serde(default)] @@ -111,6 +113,7 @@ impl Default for Activity { launch_mode: None, name: default_activity_name(), orientation: None, + exported: None, meta_data: Default::default(), intent_filters: Default::default(), }