aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTianjie Xu2018-02-03 19:20:56 -0600
committerTianjie Xu2018-02-12 17:19:37 -0600
commite40c80d021d667c1400b7a5d1f6d623b8450a47c (patch)
treea8f3e862ef385c608ee36bf1db2f5aa2dc13465f
parent5419ad31e7dafae35ab1ac9f56e234fff0c2de50 (diff)
downloadplatform-bootable-recovery-e40c80d021d667c1400b7a5d1f6d623b8450a47c.tar.gz
platform-bootable-recovery-e40c80d021d667c1400b7a5d1f6d623b8450a47c.tar.xz
platform-bootable-recovery-e40c80d021d667c1400b7a5d1f6d623b8450a47c.zip
Skip the cache size check on host
When running the update simulation, we choose to skip the cache size check for now due to the lack of "/cache" on host. And in later cls we can implement a cache size estimator to make the check more constrained. Also build the host version of support libraries. Test: unit test pass Change-Id: I3ed93c857fd02f7b62f5baba9130f75c3236e717
-rw-r--r--applypatch/Android.bp2
-rw-r--r--applypatch/applypatch.cpp5
-rw-r--r--applypatch/freecache.cpp6
-rw-r--r--otafault/Android.bp2
4 files changed, 12 insertions, 3 deletions
diff --git a/applypatch/Android.bp b/applypatch/Android.bp
index b3761407..d3efa152 100644
--- a/applypatch/Android.bp
+++ b/applypatch/Android.bp
@@ -30,6 +30,8 @@ cc_defaults {
30cc_library_static { 30cc_library_static {
31 name: "libapplypatch", 31 name: "libapplypatch",
32 32
33 host_supported: true,
34
33 defaults: [ 35 defaults: [
34 "applypatch_defaults", 36 "applypatch_defaults",
35 ], 37 ],
diff --git a/applypatch/applypatch.cpp b/applypatch/applypatch.cpp
index 04b964b1..73701abc 100644
--- a/applypatch/applypatch.cpp
+++ b/applypatch/applypatch.cpp
@@ -450,9 +450,8 @@ int CacheSizeCheck(size_t bytes) {
450 if (MakeFreeSpaceOnCache(bytes) < 0) { 450 if (MakeFreeSpaceOnCache(bytes) < 0) {
451 printf("unable to make %zu bytes available on /cache\n", bytes); 451 printf("unable to make %zu bytes available on /cache\n", bytes);
452 return 1; 452 return 1;
453 } else {
454 return 0;
455 } 453 }
454 return 0;
456} 455}
457 456
458// This function applies binary patches to EMMC target files in a way that is safe (the original 457// This function applies binary patches to EMMC target files in a way that is safe (the original
@@ -477,7 +476,7 @@ int CacheSizeCheck(size_t bytes) {
477// become obsolete since we have dropped the support for patching non-EMMC targets (EMMC targets 476// become obsolete since we have dropped the support for patching non-EMMC targets (EMMC targets
478// have the size embedded in the filename). 477// have the size embedded in the filename).
479int applypatch(const char* source_filename, const char* target_filename, 478int applypatch(const char* source_filename, const char* target_filename,
480 const char* target_sha1_str, size_t target_size __unused, 479 const char* target_sha1_str, size_t /* target_size */,
481 const std::vector<std::string>& patch_sha1_str, 480 const std::vector<std::string>& patch_sha1_str,
482 const std::vector<std::unique_ptr<Value>>& patch_data, const Value* bonus_data) { 481 const std::vector<std::unique_ptr<Value>>& patch_data, const Value* bonus_data) {
483 printf("patch %s: ", source_filename); 482 printf("patch %s: ", source_filename);
diff --git a/applypatch/freecache.cpp b/applypatch/freecache.cpp
index 0a40baa9..ec1d20ce 100644
--- a/applypatch/freecache.cpp
+++ b/applypatch/freecache.cpp
@@ -111,6 +111,12 @@ static std::set<std::string> FindExpendableFiles() {
111} 111}
112 112
113int MakeFreeSpaceOnCache(size_t bytes_needed) { 113int MakeFreeSpaceOnCache(size_t bytes_needed) {
114#ifndef __ANDROID__
115 // TODO (xunchang) implement a heuristic cache size check during host simulation.
116 printf("Skip making (%zu) bytes free space on cache; program is running on host\n", bytes_needed);
117 return 0;
118#endif
119
114 size_t free_now = FreeSpaceForFile("/cache"); 120 size_t free_now = FreeSpaceForFile("/cache");
115 printf("%zu bytes free on /cache (%zu needed)\n", free_now, bytes_needed); 121 printf("%zu bytes free on /cache (%zu needed)\n", free_now, bytes_needed);
116 122
diff --git a/otafault/Android.bp b/otafault/Android.bp
index 91a5d9a5..30d56101 100644
--- a/otafault/Android.bp
+++ b/otafault/Android.bp
@@ -15,6 +15,8 @@
15cc_library_static { 15cc_library_static {
16 name: "libotafault", 16 name: "libotafault",
17 17
18 host_supported: true,
19
18 srcs: [ 20 srcs: [
19 "config.cpp", 21 "config.cpp",
20 "ota_io.cpp", 22 "ota_io.cpp",