Skip to content
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
13 changes: 7 additions & 6 deletions app/src/main/app/PluviaApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ class PluviaApp : Application() {
}
}

// Initialize Timber in debug builds for app wide logging.
// If 'BuildConfig' give error, ignore it.
// The file needed will be autogenerated when building the apk.
if (com.winlator.cmod.BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree());
}
// Plant Timber in every build, not just debug ones.
// Release builds used to log nothing through Timber, which made the bugs
// users actually report (Steam logon and download failures) impossible to
// diagnose from logcat: the interesting state transitions simply vanished
// once the APK was minified. DebugTree goes to logcat and costs nothing
// when nobody reads it.
Timber.plant(Timber.DebugTree())

// Initialize the LogManager context in case a fallback is needed.
LogManager.init(this.applicationContext)
Expand Down
26 changes: 22 additions & 4 deletions app/src/main/cpp/wn-steam-client/rust/src/cdn_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ impl CdnClient {
if http_status != 200 {
return CdnManifestResult {
http_status,
error: "non-200 HTTP status".to_string(),
error: format!("non-200 HTTP status ({http_status})"),
..Default::default()
};
}
Expand Down Expand Up @@ -327,7 +327,7 @@ impl CdnClient {
if http_status != 200 {
return CdnChunkResult {
http_status,
error: "non-200 HTTP status".to_string(),
error: format!("non-200 HTTP status ({http_status})"),
..Default::default()
};
}
Expand Down Expand Up @@ -388,7 +388,7 @@ impl CdnClient {
.get(url)
.timeout(timeout)
.send()
.map_err(|err| format!("http get: {err}"))?;
.map_err(|err| format_http_error("http get", &err))?;
let http_status = response.status().as_u16() as i32;
let content_length = response.content_length();
let body = response
Expand Down Expand Up @@ -440,6 +440,24 @@ struct HttpResponse {
body: Vec<u8>,
}

/// Expand a reqwest error into its full source chain so a TLS/connect failure
/// on a restricted network is diagnosable from a single log line (reqwest's
/// `Display` collapses everything into a terse "error sending request").
fn format_http_error(context: &str, err: &reqwest::Error) -> String {
let mut out = format!("{context}: {err}");
let mut source = std::error::Error::source(err);
let mut depth = 0;
while let Some(next) = source {
out.push_str(&format!(" | caused by: {next}"));
source = next.source();
depth += 1;
if depth > 8 {
break;
}
}
out
}

impl CdnChunkResult {
pub fn ok(&self) -> bool {
self.error.is_empty() && !self.data.is_empty()
Expand Down Expand Up @@ -636,7 +654,7 @@ mod tests {
assert!(chunk.ok());
assert_eq!(
CdnClient::validate_chunk_response(404, vec![], None).error,
"non-200 HTTP status"
"non-200 HTTP status (404)"
);
}

Expand Down
31 changes: 31 additions & 0 deletions app/src/main/cpp/wn-steam-client/rust/src/cm_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ pub struct CMClientCore {
session_id: AtomicI32,
family_group_id: AtomicU64,
server_realtime: AtomicU32,
cell_id: AtomicU32,
playing_blocked: AtomicBool,
license_list: Mutex<Vec<License>>,
friends: Mutex<HashMap<u64, u32>>,
Expand Down Expand Up @@ -170,6 +171,7 @@ impl Default for CMClientCore {
session_id: AtomicI32::new(0),
family_group_id: AtomicU64::new(0),
server_realtime: AtomicU32::new(0),
cell_id: AtomicU32::new(0),
playing_blocked: AtomicBool::new(false),
license_list: Mutex::new(Vec::new()),
friends: Mutex::new(HashMap::new()),
Expand Down Expand Up @@ -202,6 +204,7 @@ impl CMClientCore {
self.session_id.store(0, Ordering::Relaxed);
self.family_group_id.store(0, Ordering::Relaxed);
self.server_realtime.store(0, Ordering::Relaxed);
self.cell_id.store(0, Ordering::Relaxed);
self.outbound_wires
.lock()
.expect("outbound queue poisoned")
Expand All @@ -224,6 +227,10 @@ impl CMClientCore {
self.server_realtime.load(Ordering::Relaxed)
}

pub fn cell_id(&self) -> u32 {
self.cell_id.load(Ordering::Relaxed)
}

pub fn is_playing_blocked(&self) -> bool {
self.playing_blocked.load(Ordering::Relaxed)
}
Expand Down Expand Up @@ -724,6 +731,28 @@ impl CMClientCore {
)
}

pub fn build_get_cdn_auth_token(
&self,
app_id: u32,
depot_id: u32,
host_name: &str,
job_id: u64,
) -> Option<OutboundServiceCall> {
if app_id == 0 || depot_id == 0 || host_name.is_empty() {
return None;
}
self.build_authed_service_call(
"ContentServerDirectory.GetCDNAuthToken#1",
job_id,
crate::pb::cmsg_client_get_cdn_auth_token::CMsgClientGetCdnAuthToken {
app_id,
depot_id,
host_name: host_name.to_string(),
}
.serialize(),
)
}

pub fn build_manifest_request_code_call(
&self,
app_id: u32,
Expand Down Expand Up @@ -1359,6 +1388,7 @@ impl CMClientCore {
.store(resp.family_group_id, Ordering::Relaxed);
self.server_realtime
.store(resp.rtime32_server_time, Ordering::Relaxed);
self.cell_id.store(resp.cell_id, Ordering::Relaxed);
InboundAction::LogonOk
} else {
InboundAction::LoggedOff
Expand All @@ -1373,6 +1403,7 @@ impl CMClientCore {
self.session_id.store(0, Ordering::Relaxed);
self.family_group_id.store(0, Ordering::Relaxed);
self.server_realtime.store(0, Ordering::Relaxed);
self.cell_id.store(0, Ordering::Relaxed);
InboundAction::LoggedOff
}
EMsg::CLIENT_LICENSE_LIST => {
Expand Down
Loading