-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: cleaning up the unnecessary functions #708
base: main
Are you sure you want to change the base?
Changes from 7 commits
1b0f9b0
343e450
e07084c
cd3b4d1
fb091c9
8090d9e
199e029
bd914dd
2ee31b4
29a13f1
6b60812
b10e3d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,9 +23,7 @@ use std::{ | |
|
||
use ripple_sdk::{ | ||
api::{ | ||
apps::{ | ||
AppError, AppManagerResponse, AppMethod, AppSession, EffectiveTransport, StateChange, | ||
}, | ||
apps::{AppError, AppManagerResponse, AppMethod, AppSession, StateChange}, | ||
device::{device_user_grants_data::EvaluateAt, entertainment_data::NavigationIntent}, | ||
firebolt::{ | ||
fb_capabilities::{DenyReason, DenyReasonWithCap, FireboltPermission}, | ||
|
@@ -66,7 +64,6 @@ use ripple_sdk::{ | |
LCM_EVENT_ON_REQUEST_READY, | ||
}, | ||
}, | ||
protocol::{BridgeProtocolRequest, BridgeSessionParams}, | ||
}, | ||
log::info, | ||
tokio::{self, sync::mpsc::Receiver}, | ||
|
@@ -84,10 +81,8 @@ use crate::{ | |
user_grants::{GrantHandler, GrantPolicyEnforcer, GrantState}, | ||
}, | ||
state::{ | ||
bootstrap_state::ChannelsState, | ||
cap::permitted_state::PermissionHandler, | ||
platform_state::PlatformState, | ||
session_state::{PendingSessionInfo, Session}, | ||
bootstrap_state::ChannelsState, cap::permitted_state::PermissionHandler, | ||
platform_state::PlatformState, session_state::PendingSessionInfo, | ||
}, | ||
utils::rpc_utils::rpc_await_oneshot, | ||
SEMVER_LIGHTWEIGHT, | ||
|
@@ -622,14 +617,7 @@ impl DelegatedLauncherHandler { | |
&mut self, | ||
mut session: AppSession, | ||
) -> Result<AppManagerResponse, AppError> { | ||
let transport = session.get_transport(); | ||
if let EffectiveTransport::Bridge(_) = transport.clone() { | ||
if !self.platform_state.supports_bridge() { | ||
error!("Bridge is not a supported contract"); | ||
return Err(AppError::NotSupported); | ||
} | ||
} | ||
|
||
let _transport = session.get_transport(); | ||
let app_id = session.app.id.clone(); | ||
|
||
if let Some(app_title) = session.app.title.as_ref() { | ||
|
@@ -881,40 +869,8 @@ impl DelegatedLauncherHandler { | |
emit_event: bool, | ||
) -> CompletedSessionResponse { | ||
let app_id = session.app.id.clone(); | ||
let transport = session.get_transport(); | ||
let _transport = session.get_transport(); | ||
let session_id = Uuid::new_v4().to_string(); | ||
if let EffectiveTransport::Bridge(container_id) = transport.clone() { | ||
if platform_state.supports_bridge() { | ||
// Step 1: Add the session of the app to the state if bridge | ||
let session_state = Session::new(app_id.clone(), None, transport); | ||
platform_state | ||
.session_state | ||
.add_session(session_id.clone(), session_state); | ||
let id = container_id.clone(); | ||
debug!( | ||
"App session details: appId: {} session: {}", | ||
app_id, session_id | ||
); | ||
// Step 2: Start the session using contract | ||
let request = BridgeSessionParams { | ||
container_id, | ||
session_id: session_id.clone(), | ||
app_id: app_id.clone(), | ||
}; | ||
let request = BridgeProtocolRequest::StartSession(request); | ||
let client = platform_state.get_client(); | ||
// After processing the session response the launcher will launch the app | ||
// Below thread is going to wait for the app to be launched and create a connection | ||
tokio::spawn(async move { | ||
if let Err(e) = client.send_extn_request(request).await { | ||
error!("Error sending request to bridge {:?}", e); | ||
} else { | ||
info!("Bridge connected for {}", id); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
let loaded_session_id = Uuid::new_v4().to_string(); | ||
let mut active_session_id = None; | ||
if !session.launch.inactive { | ||
|
@@ -1062,23 +1018,10 @@ impl DelegatedLauncherHandler { | |
async fn end_session(&mut self, app_id: &str) -> Result<AppManagerResponse, AppError> { | ||
debug!("end_session: entry: app_id={}", app_id); | ||
let app = self.platform_state.app_manager_state.remove(app_id); | ||
if let Some(app) = app { | ||
if let Some(_app) = app { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could just be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
if let Some(timer) = self.timer_map.remove(app_id) { | ||
timer.cancel(); | ||
} | ||
let transport = app.initial_session.get_transport(); | ||
if let EffectiveTransport::Bridge(container_id) = transport { | ||
AppEvents::remove_session(&self.platform_state, app.session_id.clone()); | ||
let request = BridgeProtocolRequest::EndSession(container_id); | ||
if let Err(e) = self | ||
.platform_state | ||
.get_client() | ||
.send_extn_request(request) | ||
.await | ||
{ | ||
error!("Error sending event to bridge {:?}", e); | ||
} | ||
} | ||
} else { | ||
error!("end_session app_id={} Not found", app_id); | ||
return Err(AppError::NotFound); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just get rid of the
AppRuntimeTransport
enum altogether since it's no longer needed, that will then let you also get rid ofEffectiveTransport
and even more code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clean up done.