This repository has been archived by the owner on Feb 14, 2025. It is now read-only.
forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 10
Hacks for iOS demo #19
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
|
||
#include "flutter/shell/common/shorebird.h" | ||
|
||
#include <optional> | ||
#include <vector> | ||
|
||
#include "flutter/fml/command_line.h" | ||
#include "flutter/fml/file.h" | ||
#include "flutter/fml/macros.h" | ||
#include "flutter/fml/message_loop.h" | ||
#include "flutter/fml/native_library.h" | ||
#include "flutter/fml/paths.h" | ||
#include "flutter/fml/size.h" | ||
#include "flutter/lib/ui/plugins/callback_cache.h" | ||
#include "flutter/runtime/dart_vm.h" | ||
#include "flutter/shell/common/shell.h" | ||
#include "flutter/shell/common/switches.h" | ||
#include "third_party/dart/runtime/include/dart_tools_api.h" | ||
#include "third_party/skia/include/core/SkFontMgr.h" | ||
|
||
#include "third_party/updater/library/include/updater.h" | ||
|
||
// Namespaced to avoid Google style warnings. | ||
namespace flutter { | ||
|
||
// Old Android versions (e.g. the v16 ndk Flutter uses) don't always include a | ||
// getauxval symbol, but the Rust ring crate assumes it exists: | ||
// https://github.com/briansmith/ring/blob/fa25bf3a7403c9fe6458cb87bd8427be41225ca2/src/cpu/arm.rs#L22 | ||
// It uses it to determine if the CPU supports AES instructions. | ||
// Making this a weak symbol allows the linker to use a real version instead | ||
// if it can find one. | ||
// BoringSSL just reads from procfs instead, which is what we would do if | ||
// we needed to implement this ourselves. Implementation looks straightforward: | ||
// https://lwn.net/Articles/519085/ | ||
// https://github.com/google/boringssl/blob/6ab4f0ae7f2db96d240eb61a5a8b4724e5a09b2f/crypto/cpu_arm_linux.c | ||
#if defined(__ANDROID__) && defined(__arm__) | ||
extern "C" __attribute__((weak)) unsigned long getauxval(unsigned long type) { | ||
return 0; | ||
} | ||
#endif | ||
|
||
void ConfigureShorebird(std::string cache_path, | ||
flutter::Settings& settings, | ||
const std::string& shorebird_yaml, | ||
const std::string& version, | ||
int64_t version_code) { | ||
auto cache_dir = | ||
fml::paths::JoinPaths({std::move(cache_path), "shorebird_updater"}); | ||
|
||
fml::CreateDirectory(fml::paths::GetCachesDirectory(), {"shorebird_updater"}, | ||
fml::FilePermission::kReadWrite); | ||
|
||
// Using a block to make AppParameters lifetime explicit. | ||
{ | ||
AppParameters app_parameters; | ||
// Combine version and version_code into a single string. | ||
// We could also pass these separately through to the updater if needed. | ||
auto release_version = version + "+" + std::to_string(version_code); | ||
app_parameters.release_version = release_version.c_str(); | ||
app_parameters.cache_dir = cache_dir.c_str(); | ||
|
||
// https://stackoverflow.com/questions/26032039/convert-vectorstring-into-char-c | ||
std::vector<const char*> c_paths{}; | ||
for (const auto& string : settings.application_library_path) { | ||
c_paths.push_back(string.c_str()); | ||
} | ||
// Do not modify application_library_path or c_strings will invalidate. | ||
|
||
app_parameters.original_libapp_paths = c_paths.data(); | ||
app_parameters.original_libapp_paths_size = c_paths.size(); | ||
|
||
// shorebird_init copies from app_parameters and shorebirdYaml. | ||
shorebird_init(&app_parameters, shorebird_yaml.c_str()); | ||
} | ||
|
||
char* c_active_path = shorebird_next_boot_patch_path(); | ||
if (c_active_path != NULL) { | ||
std::string active_path = c_active_path; | ||
shorebird_free_string(c_active_path); | ||
FML_LOG(INFO) << "Shorebird updater: active path: " << active_path; | ||
char* c_patch_number = shorebird_next_boot_patch_number(); | ||
if (c_patch_number != NULL) { | ||
std::string patch_number = c_patch_number; | ||
shorebird_free_string(c_patch_number); | ||
FML_LOG(INFO) << "Shorebird updater: active patch number: " | ||
<< patch_number; | ||
} | ||
|
||
settings.application_library_path.clear(); | ||
settings.application_library_path.emplace_back(active_path); | ||
// Once start_update_thread is called, the next_boot_patch* functions may | ||
// change their return values if the shorebird_report_launch_failed | ||
// function is called. | ||
shorebird_report_launch_start(); | ||
} else { | ||
FML_LOG(INFO) << "Shorebird updater: no active patch."; | ||
} | ||
|
||
FML_LOG(INFO) << "Starting Shorebird update"; | ||
shorebird_start_update_thread(); | ||
} | ||
|
||
} // namespace flutter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef SHELL_COMMON_SHOREBIRD_H_ | ||
#define SHELL_COMMON_SHOREBIRD_H_ | ||
|
||
#include "flutter/common/settings.h" | ||
|
||
namespace flutter { | ||
|
||
void ConfigureShorebird(std::string cache_path, | ||
flutter::Settings& settings, | ||
const std::string& shorebird_yaml, | ||
const std::string& version, | ||
int64_t version_code); | ||
|
||
} // namespace flutter | ||
|
||
#endif // SHELL_COMMON_SHOREBIRD_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This should have been release.