Rename setters for lifecycle state (flutter/engine#40462)
Rename setters for lifecycle state
This commit is contained in:
@@ -67,8 +67,8 @@ void _updateUserSettingsData(String jsonData) {
|
||||
}
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
void _updateLifecycleState(String state) {
|
||||
PlatformDispatcher.instance._updateLifecycleState(state);
|
||||
void _updateInitialLifecycleState(String state) {
|
||||
PlatformDispatcher.instance._updateInitialLifecycleState(state);
|
||||
}
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
|
||||
@@ -922,7 +922,7 @@ class PlatformDispatcher {
|
||||
bool _initialLifecycleStateAccessed = false;
|
||||
|
||||
// Called from the engine, via hooks.dart
|
||||
void _updateLifecycleState(String state) {
|
||||
void _updateInitialLifecycleState(String state) {
|
||||
// We do not update the state if the state has already been used to initialize
|
||||
// the lifecycleState.
|
||||
if (!_initialLifecycleStateAccessed) {
|
||||
|
||||
@@ -48,9 +48,9 @@ void PlatformConfiguration::DidCreateIsolate() {
|
||||
update_user_settings_data_.Set(
|
||||
tonic::DartState::Current(),
|
||||
Dart_GetField(library, tonic::ToDart("_updateUserSettingsData")));
|
||||
update_lifecycle_state_.Set(
|
||||
update_initial_lifecycle_state_.Set(
|
||||
tonic::DartState::Current(),
|
||||
Dart_GetField(library, tonic::ToDart("_updateLifecycleState")));
|
||||
Dart_GetField(library, tonic::ToDart("_updateInitialLifecycleState")));
|
||||
update_semantics_enabled_.Set(
|
||||
tonic::DartState::Current(),
|
||||
Dart_GetField(library, tonic::ToDart("_updateSemanticsEnabled")));
|
||||
@@ -108,17 +108,18 @@ void PlatformConfiguration::UpdateUserSettingsData(const std::string& data) {
|
||||
}));
|
||||
}
|
||||
|
||||
void PlatformConfiguration::UpdateLifecycleState(const std::string& data) {
|
||||
void PlatformConfiguration::UpdateInitialLifecycleState(
|
||||
const std::string& data) {
|
||||
std::shared_ptr<tonic::DartState> dart_state =
|
||||
update_lifecycle_state_.dart_state().lock();
|
||||
update_initial_lifecycle_state_.dart_state().lock();
|
||||
if (!dart_state) {
|
||||
return;
|
||||
}
|
||||
tonic::DartState::Scope scope(dart_state);
|
||||
tonic::CheckAndHandleError(tonic::DartInvoke(update_lifecycle_state_.Get(),
|
||||
{
|
||||
tonic::StdStringToDart(data),
|
||||
}));
|
||||
tonic::CheckAndHandleError(tonic::DartInvoke(
|
||||
update_initial_lifecycle_state_.Get(), {
|
||||
tonic::StdStringToDart(data),
|
||||
}));
|
||||
}
|
||||
|
||||
void PlatformConfiguration::UpdateSemanticsEnabled(bool enabled) {
|
||||
|
||||
@@ -296,7 +296,7 @@ class PlatformConfiguration final {
|
||||
///
|
||||
/// @param[in] data The lifecycle state data.
|
||||
///
|
||||
void UpdateLifecycleState(const std::string& data);
|
||||
void UpdateInitialLifecycleState(const std::string& data);
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Notifies the PlatformConfiguration that the embedder has
|
||||
@@ -436,7 +436,7 @@ class PlatformConfiguration final {
|
||||
tonic::DartPersistentValue on_error_;
|
||||
tonic::DartPersistentValue update_locales_;
|
||||
tonic::DartPersistentValue update_user_settings_data_;
|
||||
tonic::DartPersistentValue update_lifecycle_state_;
|
||||
tonic::DartPersistentValue update_initial_lifecycle_state_;
|
||||
tonic::DartPersistentValue update_semantics_enabled_;
|
||||
tonic::DartPersistentValue update_accessibility_features_;
|
||||
tonic::DartPersistentValue dispatch_platform_message_;
|
||||
|
||||
@@ -119,7 +119,7 @@ bool RuntimeController::FlushRuntimeStateToIsolate() {
|
||||
SetAccessibilityFeatures(
|
||||
platform_data_.accessibility_feature_flags_) &&
|
||||
SetUserSettingsData(platform_data_.user_settings_data) &&
|
||||
SetLifecycleState(platform_data_.lifecycle_state);
|
||||
SetInitialLifecycleState(platform_data_.lifecycle_state);
|
||||
}
|
||||
|
||||
bool RuntimeController::SetViewportMetrics(const ViewportMetrics& metrics) {
|
||||
@@ -157,11 +157,11 @@ bool RuntimeController::SetUserSettingsData(const std::string& data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RuntimeController::SetLifecycleState(const std::string& data) {
|
||||
bool RuntimeController::SetInitialLifecycleState(const std::string& data) {
|
||||
platform_data_.lifecycle_state = data;
|
||||
|
||||
if (auto* platform_configuration = GetPlatformConfigurationIfAvailable()) {
|
||||
platform_configuration->UpdateLifecycleState(
|
||||
platform_configuration->UpdateInitialLifecycleState(
|
||||
platform_data_.lifecycle_state);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -205,9 +205,11 @@ class RuntimeController : public PlatformConfigurationClient {
|
||||
bool SetUserSettingsData(const std::string& data);
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Forward the lifecycle state data to the running isolate. If
|
||||
/// the isolate is not running, this data will be saved and
|
||||
/// flushed to the isolate when it starts running.
|
||||
/// @brief Forward the initial lifecycle state data to the running
|
||||
/// isolate. If the isolate is not running, this data will be
|
||||
/// saved and flushed to the isolate when it starts running.
|
||||
/// After the isolate starts running, the current lifecycle
|
||||
/// state is pushed to it via the "flutter/lifecycle" channel.
|
||||
///
|
||||
/// @deprecated The persistent isolate data must be used for this purpose
|
||||
/// instead.
|
||||
@@ -217,7 +219,7 @@ class RuntimeController : public PlatformConfigurationClient {
|
||||
/// @return If the lifecycle state data was forwarded to the running
|
||||
/// isolate.
|
||||
///
|
||||
bool SetLifecycleState(const std::string& data);
|
||||
bool SetInitialLifecycleState(const std::string& data);
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Notifies the running isolate about whether the semantics tree
|
||||
|
||||
@@ -331,7 +331,7 @@ bool Engine::HandleLifecyclePlatformMessage(PlatformMessage* message) {
|
||||
state == "AppLifecycleState.inactive") {
|
||||
ScheduleFrame();
|
||||
}
|
||||
runtime_controller_->SetLifecycleState(state);
|
||||
runtime_controller_->SetInitialLifecycleState(state);
|
||||
// Always forward these messages to the framework by returning false.
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user