diff --git a/native/android/app/build.gradle b/native/android/app/build.gradle --- a/native/android/app/build.gradle +++ b/native/android/app/build.gradle @@ -384,7 +384,7 @@ def cxxBridgeCommonDir = "${nativeRustLibraryDir}/target/cxxbridge/rust" task buildNativeRustLibrary(type: Exec) { - commandLine "cargo", "build", "--manifest-path", nativeRustLibraryManifestPath + commandLine "cargo", "build", "--features", "android", "--manifest-path", nativeRustLibraryManifestPath } task copyNativeRustLibraryFiles(dependsOn: buildNativeRustLibrary, type: Copy) { diff --git a/native/native_rust_library/Cargo.toml b/native/native_rust_library/Cargo.toml --- a/native/native_rust_library/Cargo.toml +++ b/native/native_rust_library/Cargo.toml @@ -28,3 +28,6 @@ [lib] crate-type = ["staticlib"] + +[features] +android = [] diff --git a/native/native_rust_library/src/lib.rs b/native/native_rust_library/src/lib.rs --- a/native/native_rust_library/src/lib.rs +++ b/native/native_rust_library/src/lib.rs @@ -23,6 +23,11 @@ RegistrationStartRequest, WalletLoginRequest, }; +#[cfg(not(feature = "android"))] +pub const DEVICE_TYPE: DeviceType = DeviceType::IOs; +#[cfg(feature = "android")] +pub const DEVICE_TYPE: DeviceType = DeviceType::Android; + lazy_static! { pub static ref RUNTIME: Arc = Arc::new( Builder::new_multi_thread() @@ -231,7 +236,7 @@ }), onetime_content_prekeys: password_user_info.content_onetime_keys, onetime_notif_prekeys: password_user_info.notif_onetime_keys, - device_type: DeviceType::Native.into(), + device_type: DEVICE_TYPE.into(), }), }; @@ -322,7 +327,7 @@ }), onetime_content_prekeys: password_user_info.content_onetime_keys, onetime_notif_prekeys: password_user_info.notif_onetime_keys, - device_type: DeviceType::Native.into(), + device_type: DEVICE_TYPE.into(), }), }; diff --git a/services/identity/src/database.rs b/services/identity/src/database.rs --- a/services/identity/src/database.rs +++ b/services/identity/src/database.rs @@ -69,11 +69,15 @@ } #[derive(Clone, Copy)] +#[allow(non_camel_case_types)] pub enum Device { // Numeric values should match the protobuf definition Keyserver = 0, Native, Web, + iOS, + Android, + Windows, } impl TryFrom for Device { @@ -84,6 +88,9 @@ 0 => Ok(Device::Keyserver), 1 => Ok(Device::Native), 2 => Ok(Device::Web), + 3 => Ok(Device::iOS), + 4 => Ok(Device::Android), + 5 => Ok(Device::Windows), _ => Err(Error::Attribute(DBItemError { attribute_name: USERS_TABLE_DEVICES_MAP_DEVICE_TYPE_ATTRIBUTE_NAME .to_string(), @@ -100,6 +107,9 @@ Device::Keyserver => write!(f, "keyserver"), Device::Native => write!(f, "native"), Device::Web => write!(f, "web"), + Device::iOS => write!(f, "ios"), + Device::Android => write!(f, "android"), + Device::Windows => write!(f, "windows"), } } } diff --git a/shared/cmake/corrosion-cxx.cmake b/shared/cmake/corrosion-cxx.cmake --- a/shared/cmake/corrosion-cxx.cmake +++ b/shared/cmake/corrosion-cxx.cmake @@ -3,7 +3,7 @@ # <_LIB_PATH_STEM> must match the crate name: # "path/to/myrustcrate" -> "libmyrustcrate.a" function(add_library_rust) - set(value_keywords PATH NAMESPACE CXX_BRIDGE_SOURCE_FILE) + set(value_keywords PATH NAMESPACE FEATURES CXX_BRIDGE_SOURCE_FILE) cmake_parse_arguments( rust_lib "${OPTIONS}" @@ -42,7 +42,10 @@ set(namespace ${rust_lib_NAMESPACE}) set(cxx_bridge_source_file "${rust_lib_SOURCE_FOLDER}/lib.rs") - corrosion_import_crate(MANIFEST_PATH "${lib_path}/Cargo.toml") + corrosion_import_crate( + MANIFEST_PATH "${lib_path}/Cargo.toml" + FEATURES "${rust_lib_FEATURES}" + ) get_filename_component(_LIB_PATH_STEM ${lib_path} NAME) message(STATUS "Library stem path: ${_LIB_PATH_STEM}") diff --git a/shared/protos/identity_client.proto b/shared/protos/identity_client.proto --- a/shared/protos/identity_client.proto +++ b/shared/protos/identity_client.proto @@ -108,6 +108,9 @@ Keyserver = 0; Native = 1; Web = 2; + iOS = 3; + Android = 4; + Windows = 5; } // Bundle of information needed for creating an initial message using X3DH