fix: streaming on Android devices (#1403)

* fix: android Session::connect failure from TryAnotherAP

It appears that a combination of `Platform::PLATFORM_ANDROID_ARM` and
connecting with `Credentials::with_access_token` causes all AP to error
TryAnotherAP

* fix: getting api access token should respect client id

If we are trying to get an access token from login5 using stored
credentials, ie: from oauth flow, we should use the oauth's client ID,
this matches with the semantics as described in
`Login5Manager::auth_token`

* fix: cpu_family arm64 should be aarch64

* Fix audio streaming on Android platform (#1399)
This commit is contained in:
SilverMira 2024-12-05 21:20:03 +08:00 committed by GitHub
parent 705e68ec65
commit f646ef2b5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 16 additions and 3 deletions

View file

@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [core] Fix "no native root CA certificates found" on platforms unsupported - [core] Fix "no native root CA certificates found" on platforms unsupported
by `rustls-native-certs`. by `rustls-native-certs`.
- [core] Fix all APs rejecting with "TryAnotherAP" when connecting session
on Android platform.
- [core] Fix "Invalid Credentials" when using a Keymaster access token and
client ID on Android platform.
### Removed ### Removed

View file

@ -111,7 +111,6 @@ where
thread_rng().fill_bytes(&mut client_nonce); thread_rng().fill_bytes(&mut client_nonce);
let platform = match crate::config::OS { let platform = match crate::config::OS {
"android" => Platform::PLATFORM_ANDROID_ARM,
"freebsd" | "netbsd" | "openbsd" => match ARCH { "freebsd" | "netbsd" | "openbsd" => match ARCH {
"x86_64" => Platform::PLATFORM_FREEBSD_X86_64, "x86_64" => Platform::PLATFORM_FREEBSD_X86_64,
_ => Platform::PLATFORM_FREEBSD_X86, _ => Platform::PLATFORM_FREEBSD_X86,
@ -120,7 +119,12 @@ where
"aarch64" => Platform::PLATFORM_IPHONE_ARM64, "aarch64" => Platform::PLATFORM_IPHONE_ARM64,
_ => Platform::PLATFORM_IPHONE_ARM, _ => Platform::PLATFORM_IPHONE_ARM,
}, },
"linux" => match ARCH { // Rather than sending `Platform::PLATFORM_ANDROID_ARM` for "android",
// we are spoofing "android" as "linux", as otherwise during Session::connect
// all APs will reject the client with TryAnotherAP, no matter the credentials
// used was obtained via OAuth using KEYMASTER or ANDROID's client ID or
// Login5Manager::login
"linux" | "android" => match ARCH {
"arm" | "aarch64" => Platform::PLATFORM_LINUX_ARM, "arm" | "aarch64" => Platform::PLATFORM_LINUX_ARM,
"blackfin" => Platform::PLATFORM_LINUX_BLACKFIN, "blackfin" => Platform::PLATFORM_LINUX_BLACKFIN,
"mips" => Platform::PLATFORM_LINUX_MIPS, "mips" => Platform::PLATFORM_LINUX_MIPS,

View file

@ -101,7 +101,7 @@ pub async fn authenticate(
let cpu_family = match std::env::consts::ARCH { let cpu_family = match std::env::consts::ARCH {
"blackfin" => CpuFamily::CPU_BLACKFIN, "blackfin" => CpuFamily::CPU_BLACKFIN,
"arm" | "arm64" => CpuFamily::CPU_ARM, "arm" | "aarch64" => CpuFamily::CPU_ARM,
"ia64" => CpuFamily::CPU_IA64, "ia64" => CpuFamily::CPU_IA64,
"mips" => CpuFamily::CPU_MIPS, "mips" => CpuFamily::CPU_MIPS,
"ppc" => CpuFamily::CPU_PPC, "ppc" => CpuFamily::CPU_PPC,

View file

@ -75,6 +75,11 @@ impl Login5Manager {
async fn login5_request(&self, login: Login_method) -> Result<LoginOk, Error> { async fn login5_request(&self, login: Login_method) -> Result<LoginOk, Error> {
let client_id = match OS { let client_id = match OS {
"macos" | "windows" => self.session().client_id(), "macos" | "windows" => self.session().client_id(),
// StoredCredential is used to get an access_token from Session credentials.
// Using the session client_id allows user to use Keymaster on Android/IOS
// if their Credentials::with_access_token was obtained there, assuming
// they have overriden the SessionConfig::client_id with the Keymaster's.
_ if matches!(login, Login_method::StoredCredential(_)) => self.session().client_id(),
_ => SessionConfig::default().client_id, _ => SessionConfig::default().client_id,
}; };