Browse Source

Move rangeset.h and print_sha1.h into otautil.

Also drop the "bootable/recovery" path in LOCAL_C_INCLUDES from
applypatch modules.

Test: lunch aosp_{angler,bullhead,fugu,dragon,sailfish}-userdebug;
      mmma bootable/recovery
Change-Id: Idd602a796894f971ee4f8fa3eafe36c42d9de986
Tao Bao 3 years ago
parent
commit
09e468f84c

+ 1
- 0
Android.mk View File

@@ -229,6 +229,7 @@ LOCAL_SRC_FILES := \
229 229
     asn1_decoder.cpp \
230 230
     verifier.cpp
231 231
 LOCAL_STATIC_LIBRARIES := \
232
+    libotautil \
232 233
     libcrypto_utils \
233 234
     libcrypto \
234 235
     libbase

+ 17
- 17
applypatch/Android.mk View File

@@ -25,12 +25,13 @@ LOCAL_SRC_FILES := \
25 25
 LOCAL_MODULE := libapplypatch
26 26
 LOCAL_MODULE_TAGS := eng
27 27
 LOCAL_C_INCLUDES := \
28
-    $(LOCAL_PATH)/include \
29
-    bootable/recovery
30
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
28
+    $(LOCAL_PATH)/include
29
+LOCAL_EXPORT_C_INCLUDE_DIRS := \
30
+    $(LOCAL_PATH)/include
31 31
 LOCAL_STATIC_LIBRARIES := \
32 32
     libedify \
33 33
     libotafault \
34
+    libotautil \
34 35
     libbase \
35 36
     libcrypto \
36 37
     libbspatch \
@@ -50,11 +51,12 @@ LOCAL_SRC_FILES := \
50 51
     imgpatch.cpp
51 52
 LOCAL_MODULE := libimgpatch
52 53
 LOCAL_C_INCLUDES := \
53
-    $(LOCAL_PATH)/include \
54
-    bootable/recovery
55
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
54
+    $(LOCAL_PATH)/include
55
+LOCAL_EXPORT_C_INCLUDE_DIRS := \
56
+    $(LOCAL_PATH)/include
56 57
 LOCAL_STATIC_LIBRARIES := \
57 58
     libedify \
59
+    libotautil \
58 60
     libcrypto \
59 61
     libbspatch \
60 62
     libbase \
@@ -75,11 +77,12 @@ LOCAL_SRC_FILES := \
75 77
 LOCAL_MODULE := libimgpatch
76 78
 LOCAL_MODULE_HOST_OS := linux
77 79
 LOCAL_C_INCLUDES := \
78
-    $(LOCAL_PATH)/include \
79
-    bootable/recovery
80
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
80
+    $(LOCAL_PATH)/include
81
+LOCAL_EXPORT_C_INCLUDE_DIRS := \
82
+    $(LOCAL_PATH)/include
81 83
 LOCAL_STATIC_LIBRARIES := \
82 84
     libedify \
85
+    libotautil \
83 86
     libcrypto \
84 87
     libbspatch \
85 88
     libbase \
@@ -97,9 +100,9 @@ include $(CLEAR_VARS)
97 100
 LOCAL_SRC_FILES := \
98 101
     applypatch_modes.cpp
99 102
 LOCAL_MODULE := libapplypatch_modes
100
-LOCAL_C_INCLUDES := bootable/recovery
101 103
 LOCAL_STATIC_LIBRARIES := \
102 104
     libapplypatch \
105
+    libotautil \
103 106
     libbase \
104 107
     libedify \
105 108
     libcrypto
@@ -111,7 +114,6 @@ include $(BUILD_STATIC_LIBRARY)
111 114
 include $(CLEAR_VARS)
112 115
 LOCAL_SRC_FILES := applypatch_main.cpp
113 116
 LOCAL_MODULE := applypatch
114
-LOCAL_C_INCLUDES := bootable/recovery
115 117
 LOCAL_STATIC_LIBRARIES := \
116 118
     libapplypatch_modes \
117 119
     libapplypatch \
@@ -141,6 +143,7 @@ libimgdiff_cflags := \
141 143
     -DZLIB_CONST
142 144
 
143 145
 libimgdiff_static_libraries := \
146
+    libotautil \
144 147
     libbsdiff \
145 148
     libdivsufsort \
146 149
     libdivsufsort64 \
@@ -161,8 +164,7 @@ LOCAL_CFLAGS := \
161 164
 LOCAL_STATIC_LIBRARIES := \
162 165
     $(libimgdiff_static_libraries)
163 166
 LOCAL_C_INCLUDES := \
164
-    $(LOCAL_PATH)/include \
165
-    bootable/recovery
167
+    $(LOCAL_PATH)/include
166 168
 LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
167 169
 include $(BUILD_STATIC_LIBRARY)
168 170
 
@@ -177,8 +179,7 @@ LOCAL_CFLAGS := \
177 179
 LOCAL_STATIC_LIBRARIES := \
178 180
     $(libimgdiff_static_libraries)
179 181
 LOCAL_C_INCLUDES := \
180
-    $(LOCAL_PATH)/include \
181
-    bootable/recovery
182
+    $(LOCAL_PATH)/include
182 183
 LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
183 184
 include $(BUILD_HOST_STATIC_LIBRARY)
184 185
 
@@ -193,6 +194,5 @@ LOCAL_STATIC_LIBRARIES := \
193 194
     $(libimgdiff_static_libraries) \
194 195
     libbz
195 196
 LOCAL_C_INCLUDES := \
196
-    $(LOCAL_PATH)/include \
197
-    bootable/recovery
197
+    $(LOCAL_PATH)/include
198 198
 include $(BUILD_HOST_EXECUTABLE)

+ 1
- 1
applypatch/applypatch.cpp View File

@@ -40,7 +40,7 @@
40 40
 
41 41
 #include "edify/expr.h"
42 42
 #include "otafault/ota_io.h"
43
-#include "print_sha1.h"
43
+#include "otautil/print_sha1.h"
44 44
 
45 45
 static int LoadPartitionContents(const std::string& filename, FileContents* file);
46 46
 static size_t FileSink(const unsigned char* data, size_t len, int fd);

+ 1
- 1
applypatch/bspatch.cpp View File

@@ -31,7 +31,7 @@
31 31
 
32 32
 #include "applypatch/applypatch.h"
33 33
 #include "edify/expr.h"
34
-#include "print_sha1.h"
34
+#include "otautil/print_sha1.h"
35 35
 
36 36
 void ShowBSDiffLicense() {
37 37
     puts("The bsdiff library used herein is:\n"

+ 1
- 1
applypatch/imgdiff.cpp View File

@@ -166,7 +166,7 @@
166 166
 #include <zlib.h>
167 167
 
168 168
 #include "applypatch/imgdiff_image.h"
169
-#include "rangeset.h"
169
+#include "otautil/rangeset.h"
170 170
 
171 171
 using android::base::get_unaligned;
172 172
 

+ 1
- 1
applypatch/include/applypatch/imgdiff_image.h View File

@@ -29,7 +29,7 @@
29 29
 #include <zlib.h>
30 30
 
31 31
 #include "imgdiff.h"
32
-#include "rangeset.h"
32
+#include "otautil/rangeset.h"
33 33
 
34 34
 class ImageChunk {
35 35
  public:

print_sha1.h → otautil/include/otautil/print_sha1.h View File

@@ -23,25 +23,25 @@
23 23
 #include <openssl/sha.h>
24 24
 
25 25
 static std::string print_sha1(const uint8_t* sha1, size_t len) {
26
-    const char* hex = "0123456789abcdef";
27
-    std::string result = "";
28
-    for (size_t i = 0; i < len; ++i) {
29
-        result.push_back(hex[(sha1[i]>>4) & 0xf]);
30
-        result.push_back(hex[sha1[i] & 0xf]);
31
-    }
32
-    return result;
26
+  const char* hex = "0123456789abcdef";
27
+  std::string result = "";
28
+  for (size_t i = 0; i < len; ++i) {
29
+    result.push_back(hex[(sha1[i] >> 4) & 0xf]);
30
+    result.push_back(hex[sha1[i] & 0xf]);
31
+  }
32
+  return result;
33 33
 }
34 34
 
35 35
 [[maybe_unused]] static std::string print_sha1(const uint8_t sha1[SHA_DIGEST_LENGTH]) {
36
-    return print_sha1(sha1, SHA_DIGEST_LENGTH);
36
+  return print_sha1(sha1, SHA_DIGEST_LENGTH);
37 37
 }
38 38
 
39 39
 [[maybe_unused]] static std::string short_sha1(const uint8_t sha1[SHA_DIGEST_LENGTH]) {
40
-    return print_sha1(sha1, 4);
40
+  return print_sha1(sha1, 4);
41 41
 }
42 42
 
43 43
 [[maybe_unused]] static std::string print_hex(const uint8_t* bytes, size_t len) {
44
-    return print_sha1(bytes, len);
44
+  return print_sha1(bytes, len);
45 45
 }
46 46
 
47 47
 #endif  // RECOVERY_PRINT_SHA1_H

rangeset.h → otautil/include/otautil/rangeset.h View File


+ 1
- 0
tests/Android.mk View File

@@ -201,6 +201,7 @@ LOCAL_SRC_FILES := \
201 201
 LOCAL_STATIC_LIBRARIES := \
202 202
     libimgdiff \
203 203
     libimgpatch \
204
+    libotautil \
204 205
     libbsdiff \
205 206
     libbspatch \
206 207
     libziparchive \

+ 1
- 1
tests/component/applypatch_test.cpp View File

@@ -35,7 +35,7 @@
35 35
 #include "applypatch/applypatch.h"
36 36
 #include "applypatch/applypatch_modes.h"
37 37
 #include "common/test_constants.h"
38
-#include "print_sha1.h"
38
+#include "otautil/print_sha1.h"
39 39
 
40 40
 static void sha1sum(const std::string& fname, std::string* sha1, size_t* fsize = nullptr) {
41 41
   ASSERT_NE(nullptr, sha1);

+ 1
- 1
tests/component/updater_test.cpp View File

@@ -41,7 +41,7 @@
41 41
 #include "edify/expr.h"
42 42
 #include "otautil/SysUtil.h"
43 43
 #include "otautil/error_code.h"
44
-#include "print_sha1.h"
44
+#include "otautil/print_sha1.h"
45 45
 #include "updater/blockimg.h"
46 46
 #include "updater/install.h"
47 47
 #include "updater/updater.h"

+ 2
- 2
tests/unit/rangeset_test.cpp View File

@@ -21,7 +21,7 @@
21 21
 
22 22
 #include <gtest/gtest.h>
23 23
 
24
-#include "rangeset.h"
24
+#include "otautil/rangeset.h"
25 25
 
26 26
 TEST(RangeSetTest, Parse_smoke) {
27 27
   RangeSet rs = RangeSet::Parse("2,1,10");
@@ -156,4 +156,4 @@ TEST(SortedRangeSetTest, file_range) {
156 156
   ASSERT_EQ(static_cast<size_t>(40970), rs.GetOffsetInRangeSet(4096 * 16 + 10));
157 157
   // block#10 not in range.
158 158
   ASSERT_EXIT(rs.GetOffsetInRangeSet(40970), ::testing::KilledBySignal(SIGABRT), "");
159
-}
159
+}

+ 2
- 2
updater/blockimg.cpp View File

@@ -52,8 +52,8 @@
52 52
 #include "edify/expr.h"
53 53
 #include "otafault/ota_io.h"
54 54
 #include "otautil/error_code.h"
55
-#include "print_sha1.h"
56
-#include "rangeset.h"
55
+#include "otautil/print_sha1.h"
56
+#include "otautil/rangeset.h"
57 57
 #include "updater/install.h"
58 58
 #include "updater/updater.h"
59 59
 

+ 2
- 2
updater/install.cpp View File

@@ -54,6 +54,7 @@
54 54
 #include <openssl/sha.h>
55 55
 #include <selinux/label.h>
56 56
 #include <selinux/selinux.h>
57
+#include <tune2fs.h>
57 58
 #include <ziparchive/zip_archive.h>
58 59
 
59 60
 #include "edify/expr.h"
@@ -61,8 +62,7 @@
61 62
 #include "otafault/ota_io.h"
62 63
 #include "otautil/DirUtil.h"
63 64
 #include "otautil/error_code.h"
64
-#include "print_sha1.h"
65
-#include "tune2fs.h"
65
+#include "otautil/print_sha1.h"
66 66
 #include "updater/updater.h"
67 67
 
68 68
 // Send over the buffer to recovery though the command pipe.

+ 1
- 1
verifier.cpp View File

@@ -32,7 +32,7 @@
32 32
 #include <openssl/obj_mac.h>
33 33
 
34 34
 #include "asn1_decoder.h"
35
-#include "print_sha1.h"
35
+#include "otautil/print_sha1.h"
36 36
 
37 37
 static constexpr size_t MiB = 1024 * 1024;
38 38