Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Android support #1034

Merged
merged 5 commits into from
Mar 13, 2019
Merged

Android support #1034

merged 5 commits into from
Mar 13, 2019

Conversation

riqkum
Copy link
Contributor

@riqkum riqkum commented Dec 14, 2018

  • build script update required by atkualizr-android
  • package manager for android
  • log system integration

@codecov-io
Copy link

codecov-io commented Dec 14, 2018

Codecov Report

Merging #1034 into master will decrease coverage by 0.61%.
The diff coverage is 81.81%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1034      +/-   ##
==========================================
- Coverage   76.19%   75.58%   -0.62%     
==========================================
  Files         164      158       -6     
  Lines        9860     9355     -505     
==========================================
- Hits         7513     7071     -442     
+ Misses       2347     2284      -63
Impacted Files Coverage Δ
src/libaktualizr/utilities/utils.h 90.47% <ø> (ø) ⬆️
src/libaktualizr/telemetry/telemetryconfig.cc 100% <ø> (ø) ⬆️
src/libaktualizr/uptane/managedsecondary.cc 88% <ø> (ø) ⬆️
...aktualizr/package_manager/packagemanagerfactory.cc 84.61% <0%> (-15.39%) ⬇️
src/libaktualizr/config/config.cc 96.11% <100%> (+0.42%) ⬆️
src/libaktualizr/utilities/config_utils.h 92.75% <100%> (+1.44%) ⬆️
...ibaktualizr/package_manager/packagemanagerconfig.h 83.33% <50%> (-16.67%) ⬇️
src/libaktualizr/utilities/utils.cc 85.95% <93.33%> (-0.05%) ⬇️
src/aktualizr_info/main.cc 0% <0%> (-90.1%) ⬇️
src/aktualizr_info/aktualizr_info_config.cc 51.21% <0%> (-39.03%) ⬇️
... and 37 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3cd2982...68c5411. Read the comment docs.

@patriotyk
Copy link
Contributor

Please update your commit using following command: 'git commit --amend -s', then push with force flag.

src/libaktualizr/config/config.cc Outdated Show resolved Hide resolved
@@ -152,9 +152,19 @@ class BaseConfig {
continue;
}
if (boost::filesystem::is_directory(config)) {
#if (!defined(ANDROID) || __ANDROID_API__ >= 28)
for (const auto& config_file : Utils::glob((config / "*.toml").string())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, let's just use generic version in both cases.

src/libaktualizr/utilities/utils.cc Outdated Show resolved Hide resolved
std::mutex Utils::storage_root_path_mutex_;
std::string Utils::storage_root_path_;

void Utils::setStorageRootPath(const std::string &storage_root_path) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where/how is it used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use it to point aktualizr to an allowed private storage on Android.

src/libaktualizr/logging/boost_logging.cc Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
return {AndroidInstallationState::STATE_INSTALLED, package_file_path};
} else if (ext == ".inprogress") {
return {AndroidInstallationState::STATE_IN_PROGRESS, package_file_path};
} else if (true /* check ext is actually a hash */) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still a TODO? What's the challenge there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No challenge, I'll restore the implementation soon.

data::InstallOutcome finalizeInstall(const Uptane::Target &target) const override {
(void)target;
throw std::runtime_error("Unimplemented");
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to just return a positive result instead of throwing if there really is nothing to do here. This function exists for the case when installation requires reboot or some external action before we can really call it complete. Does that apply to the android case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did android package manager when finalizeInstall call was not yet introduced. It may leads some changes in the current implementation, I need to check.

@@ -144,9 +144,8 @@ class BaseConfig {
continue;
}
if (boost::filesystem::is_directory(config)) {
for (const auto& config_file : Utils::glob((config / "*.toml").string())) {
for (const auto& config_file : Utils::getDirEntriesByExt(config, ".toml"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flagged by clang-tidy: we do not allow braceless for loops.

#if defined(ANDROID)
static void setStorageRootPath(const std::string &storage_root_path);
static boost::filesystem::path getStorageRootPath();
static std::mutex storage_root_path_mutex_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it really need a mutex? I would have thought that setStorageRootPath() would be called once in early initialization.

I also think we could forego the #if defined here and just make this api available in all cases, with a suitable comment (like "used for Android support").
The code in SafeTempRoot could default to use this path if not empty and attempt to use a temporary directory otherwise.

So, if (!Utils::getStorageRootPath()) instead of #if defined(ANDROID).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's a better idea.

};

struct AndroidInstallationState {
enum State { STATE_NOP, STATE_READY, STATE_IN_PROGRESS, STATE_INSTALLED, STATE_UPDATE };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another style consideration: we now prefer using enum class and name enum variants according to google's c++ style.

e.g.:

enum class InitRetCode { kOk, kOccupied, kServerFailure, kStorageFailure, kSecondaryFailure, kBadP12, kPkcs11Failure };

}

Uptane::Target AndroidManager::getCurrent() const {
std::vector<Uptane::Target> installed_versions;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there is a lot going on behind the scene between this and the aktualizr-android code. I don't object merging soon since it's platform-specific code but it would be nice to have quick summaries:

  • what are exactly the roles of the different components and how they interact with the state machine?
  • do you think the need to structure the code like that came from limitations of our current package manager api (not flexible enough)? If so, do you have suggestions to change it to handle this scenario more nicely?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existing package manager interface doesn't fit well while aktualizr is in role of a slave within aktualizr-android application. Extra entity (dispatcher) that I've introduced is required in that case as a sync. point between the sides. I did so to minimize interaction complexity and decrease amount of data to be exposed. And it brings me faster to the point I could play with an update mechanism on Android side.

However I have the same doubts about clearness of the current solution. I'll look what I can do to simplify it.

While entire update approach on Android is not well-established yet, I have no precise suggestions about changing package manager api.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your summary!

If you don't manage to simplify the integration dramatically, I think it could wait. But some documentation about the complete installation process with details about each actors' interactions would be greatly appreciated (when you think it's ready). Either an external doc or helpful code comments would work.

@riqkum riqkum added not-ready and removed ready labels Jan 18, 2019
@riqkum riqkum added ready and removed not-ready labels Feb 11, 2019
@riqkum riqkum force-pushed the feat/android-support branch 2 times, most recently from 01a70d6 to e117009 Compare February 15, 2019 09:34
Copy link
Collaborator

@pattivacek pattivacek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the demo today! Just a couple questions and small issues.

Would you mind rebasing on master once again? Unless @lbonn or @eu-smirnov have other thoughts, we can finally merge this soon.

@@ -736,6 +740,12 @@ class SafeTempRoot {
boost::filesystem::path path;
};

std::string Utils::storage_root_path_;

void Utils::setStorageRootPath(const std::string &storage_root_path) { storage_root_path_ = storage_root_path; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic with storage_root_path seems fine, but is setStorageRootPath ever used?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, just realized it's called by aktualizr-android.

target_sources(package_manager PRIVATE androidmanager.cc)
endif(ANDROID)

aktualizr_source_file_checks(androidmanager.cc androidmanager.h)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call to aktualizr_source_file_checks can be combined with the two immediately above it.

using qi::_1;

std::string getprop_output;
if (0 == Utils::shell("getprop ota.last_installed_package_file", &getprop_output)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this property get set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See explanation in aktualizr-android.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks!

#include <boost/phoenix/stl/algorithm/transformation.hpp>
#include <boost/spirit/include/phoenix_container.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/qi.hpp>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was it that required using these boost libraries? I see the code below, but I'm curious while normal C++ string parsing was inadequate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not aware of all the approaches you're trying to follow in the project, so be specific. Standard library does not offer comparable functionality, and hand-written find/extract would be less expressive than using boost/spirit/Qi.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, I think I've got a good enough handle on it.

@lbonn
Copy link
Contributor

lbonn commented Mar 13, 2019

I think this is also good to go when we'll have resolved your comments @patrickvacek. The boost spirit added dependency doesn't worry me too much if it stays in the android part of code.

* build script update required by atkualizr-android
* package manager for android
* log system integration

Signed-off-by: Maksim Beznos <maximbns@gmail.com>
It relies on Anroid system in-built property to match installed target.

Signed-off-by: Maksim Beznos <maximbns@gmail.com>
Signed-off-by: Maksim Beznos <maximbns@gmail.com>
Signed-off-by: Maksim Beznos <maximbns@gmail.com>
Signed-off-by: Maksim Beznos <maximbns@gmail.com>
Copy link
Collaborator

@pattivacek pattivacek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gitlab actually succeeded despite what Github says, and the LGTM check is bogus and irrelevant. So I think this is ready to go.

Thanks for your patience with keeping this going and seeing it through, @riqkum!

@pattivacek pattivacek merged commit ffbed75 into master Mar 13, 2019
@pattivacek pattivacek deleted the feat/android-support branch March 13, 2019 13:01
pattivacek added a commit that referenced this pull request Apr 20, 2020
It was added in #1034
for the Android support, but it doesn't appear to be used anywhere.

Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants