Skip to content

Commit

Permalink
build: Merge branch 'main' into user_data_migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinodsathyaseelan committed Oct 18, 2024
2 parents fb34f40 + 279ae66 commit b263a80
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main", "1.13.rc" ]
branches: [ "main", "1.14.rc" ]

env:
CARGO_TERM_COLOR: always
Expand Down
10 changes: 9 additions & 1 deletion core/main/src/bootstrap/extn/load_session_step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
//

use ripple_sdk::framework::bootstrap::Bootstep;
use ripple_sdk::tokio;
use ripple_sdk::{async_trait::async_trait, framework::RippleResponse};

use crate::processor::main_context_processor::MainContextProcessor;
Expand All @@ -32,17 +33,24 @@ impl Bootstep<BootstrapState> for LoadDistributorValuesStep {
}

async fn setup(&self, s: BootstrapState) -> RippleResponse {
MetricsState::initialize(&s.platform_state).await;
let ps = s.platform_state.clone();
tokio::spawn(async move {
MetricsState::initialize(&ps).await;
});

MainContextProcessor::remove_expired_and_inactive_entries(&s.platform_state);

ContextManager::setup(&s.platform_state).await;
if !s.platform_state.supports_session() {
return Ok(());
}

MainContextProcessor::initialize_session(&s.platform_state).await;

s.platform_state
.get_client()
.add_event_processor(MainContextProcessor::new(s.platform_state.clone()));

Ok(())
}
}
24 changes: 22 additions & 2 deletions core/main/src/firebolt/firebolt_gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,21 @@ impl FireboltGateway {
request_c.method.clone(),
request_c.ctx.app_id.clone(),
);
let fail_open = matches!(
platform_state
.get_device_manifest()
.get_features()
.intent_validation,
ripple_sdk::api::manifest::device_manifest::IntentValidation::FailOpen
);

let open_rpc_state = self.state.platform_state.open_rpc_state.clone();

tokio::spawn(async move {
let start = Utc::now().timestamp_millis();

// Validate incoming request parameters.
if let Err(error_string) = validate_request(open_rpc_state, &request_c) {
if let Err(error_string) = validate_request(open_rpc_state, &request_c, fail_open) {
let now = Utc::now().timestamp_millis();

RpcRouter::log_rdk_telemetry_message(
Expand Down Expand Up @@ -312,7 +319,20 @@ impl FireboltGateway {
}
}

fn validate_request(open_rpc_state: OpenRpcState, request: &RpcRequest) -> Result<(), String> {
fn validate_request(
open_rpc_state: OpenRpcState,
request: &RpcRequest,
fail_open: bool,
) -> Result<(), String> {
// Existing fail open configuration should work where the
// call should be delegated to the actual handler
if fail_open {
match request.method.to_lowercase().as_str() {
"lifecyclemanagement.session" | "discovery.launch" => return Ok(()),
_ => {}
}
}

let major_version = open_rpc_state.get_version().major.to_string();
let openrpc_validator = open_rpc_state.get_openrpc_validator();

Expand Down
13 changes: 12 additions & 1 deletion core/main/src/firebolt/handlers/privacy_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,24 @@ impl AllowAppContentAdTargetingSettings {
};

[
(country_code == "US").then(|| (US_PRIVACY_KEY.to_owned(), self.us_privacy.to_owned())),
(country_code == "US"
|| Self::allow_using_us_privacy(platform_state.clone(), &country_code.to_string()))
.then(|| (US_PRIVACY_KEY.to_owned(), self.us_privacy.to_owned())),
Some((LMT_KEY.to_owned(), self.lmt.to_owned())),
]
.into_iter()
.flatten()
.collect()
}

fn allow_using_us_privacy(state: PlatformState, country_code: &String) -> bool {
let countries_using_us_privacy = state
.get_device_manifest()
.configuration
.default_values
.countries_using_us_privacy;
countries_using_us_privacy.contains(country_code)
}
}

impl Default for AllowAppContentAdTargetingSettings {
Expand Down
19 changes: 2 additions & 17 deletions core/main/src/state/openrpc_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use ripple_sdk::{
fb_capabilities::FireboltPermission,
fb_openrpc::{
CapabilitySet, FireboltOpenRpc, FireboltOpenRpcMethod, FireboltSemanticVersion,
FireboltVersionManifest, OpenRPCParser,
FireboltVersionManifest,
},
provider::ProviderAttributes,
},
Expand Down Expand Up @@ -78,19 +78,6 @@ pub struct OpenRpcState {
}

impl OpenRpcState {
fn load_additional_rpc(rpc: &mut FireboltOpenRpc, file_contents: &'static str) {
match serde_json::from_str::<OpenRPCParser>(file_contents) {
Ok(addl_rpc) => {
for m in addl_rpc.methods {
rpc.methods.push(m.clone());
}
}
Err(_) => {
error!("Could not read additional RPC file");
}
}
}

fn load_open_rpc(path: &str) -> Option<FireboltOpenRpc> {
match std::fs::read_to_string(path) {
Ok(content) => {
Expand Down Expand Up @@ -134,9 +121,7 @@ impl OpenRpcState {
let version_manifest: FireboltVersionManifest = serde_json::from_str(&open_rpc_path)
.expect("Failed parsing FireboltVersionManifest from open RPC file");
let firebolt_open_rpc: FireboltOpenRpc = version_manifest.clone().into();
let ripple_rpc_file = std::include_str!("./ripple-rpc.json");
let mut ripple_open_rpc: FireboltOpenRpc = FireboltOpenRpc::default();
Self::load_additional_rpc(&mut ripple_open_rpc, ripple_rpc_file);
let ripple_open_rpc: FireboltOpenRpc = FireboltOpenRpc::default();
let openrpc_validator: FireboltOpenRpcValidator = serde_json::from_str(&open_rpc_path)
.expect("Failed parsing FireboltOpenRpcValidator from open RPC file");
let v = OpenRpcState {
Expand Down
19 changes: 19 additions & 0 deletions core/sdk/src/api/manifest/device_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,10 @@ pub struct DefaultValues {
pub accessibility_audio_description_settings: bool,
#[serde(default)]
pub role_based_support: bool,
#[serde(default = "country_postal_code_default")]
pub country_postal_code: HashMap<String, String>,
#[serde(default = "countries_using_us_privacy_default")]
pub countries_using_us_privacy: Vec<String>,
}

pub fn name_default() -> String {
Expand All @@ -356,6 +360,17 @@ pub fn default_video_dimensions() -> Vec<i32> {
vec![1920, 1080]
}

pub fn countries_using_us_privacy_default() -> Vec<String> {
Vec::new()
}

fn country_postal_code_default() -> HashMap<String, String> {
let mut default_map = HashMap::default();
default_map.insert("USA".to_string(), "66952".to_string());
default_map.insert("CAN".to_string(), "L6T 0C1".to_string());
default_map
}

#[derive(Deserialize, Debug, Clone, Default)]
#[cfg_attr(test, derive(PartialEq))]
pub struct SettingsDefaults {
Expand Down Expand Up @@ -444,6 +459,8 @@ impl Default for DefaultValues {
media_progress_as_watched_events: false,
accessibility_audio_description_settings: false,
role_based_support: false,
country_postal_code: country_postal_code_default(),
countries_using_us_privacy: countries_using_us_privacy_default(),
}
}
}
Expand Down Expand Up @@ -913,6 +930,8 @@ pub(crate) mod tests {
media_progress_as_watched_events: true,
accessibility_audio_description_settings: false,
role_based_support: false,
country_postal_code: HashMap::new(),
countries_using_us_privacy: Vec::new(),
},
settings_defaults_per_app: HashMap::new(),
model_friendly_names: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,6 @@ async fn test_device_delete_persistent_value_by_key(with_scope: bool) {
.await;

let mut result = HashMap::new();
result.insert(
"value".into(),
ContractMatcher::MatchType("testvalue1".into()),
);
result.insert("success".into(), ContractMatcher::MatchBool(true));

let mut params = HashMap::new();
Expand Down

0 comments on commit b263a80

Please sign in to comment.