diff options
author | Steven Laver <lavers@google.com> | 2020-01-06 13:24:38 -0800 |
---|---|---|
committer | Steven Laver <lavers@google.com> | 2020-01-06 13:24:38 -0800 |
commit | d6c80d4db481f1d2aee430dca619fc17aa1073cc (patch) | |
tree | e31e8821ce94f04c10de1ef9584036afe2990341 | |
parent | 3b24e70819b04b3cc6090337eecd26b548cc7d68 (diff) | |
parent | e2cb46ac1bc47e51e6d075c3862788cf1f220301 (diff) |
Merge RP1A.200106.001
Change-Id: I802ad986f1dffebfb4ee628ed684db212ff1b634
-rw-r--r-- | etc/init.rc | 4 | ||||
-rw-r--r-- | install/Android.bp | 1 | ||||
-rw-r--r-- | install/include/install/install.h | 4 | ||||
-rw-r--r-- | install/install.cpp | 81 | ||||
-rw-r--r-- | minui/graphics.cpp | 4 | ||||
-rw-r--r-- | minui/graphics_drm.cpp | 4 | ||||
-rw-r--r-- | minui/include/minui/minui.h | 1 | ||||
-rw-r--r-- | minui/resources.cpp | 6 | ||||
-rw-r--r-- | tests/Android.bp | 3 | ||||
-rw-r--r-- | tests/unit/install_test.cpp | 82 |
10 files changed, 16 insertions, 174 deletions
diff --git a/etc/init.rc b/etc/init.rc index 12411ac1..3ec45db2 100644 --- a/etc/init.rc +++ b/etc/init.rc @@ -4,6 +4,10 @@ on early-init # Set the security context of /postinstall if present. restorecon /postinstall + # Copy prebuilt ld.config.txt into linkerconfig directory + copy /system/etc/ld.config.txt /linkerconfig/ld.config.txt + chmod 444 /linkerconfig/ld.config.txt + start ueventd setprop sys.usb.configfs 0 diff --git a/install/Android.bp b/install/Android.bp index 9a0dd822..f927088b 100644 --- a/install/Android.bp +++ b/install/Android.bp @@ -43,7 +43,6 @@ cc_defaults { "libsnapshot_nobinder", // external dependencies - "libvintf_recovery", "libvintf", ], } diff --git a/install/include/install/install.h b/install/include/install/install.h index c3331c8b..bef23e9c 100644 --- a/install/include/install/install.h +++ b/install/include/install/install.h @@ -59,10 +59,6 @@ bool verify_package(Package* package, RecoveryUI* ui); // result to |metadata|. Return true if succeed, otherwise return false. bool ReadMetadataFromPackage(ZipArchiveHandle zip, std::map<std::string, std::string>* metadata); -// Verifies the compatibility info in a Treble-compatible package. Returns true directly if the -// entry doesn't exist. -bool verify_package_compatibility(ZipArchiveHandle package_zip); - // Checks if the metadata in the OTA package has expected values. Mandatory checks: ota-type, // pre-device and serial number (if presents). A/B OTA specific checks: pre-build version, // fingerprint, timestamp. diff --git a/install/install.cpp b/install/install.cpp index 43916b3d..1c9bf2fd 100644 --- a/install/install.cpp +++ b/install/install.cpp @@ -45,7 +45,6 @@ #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android-base/unique_fd.h> -#include <vintf/VintfObjectRecovery.h> #include "install/package.h" #include "install/verifier.h" @@ -506,73 +505,6 @@ static InstallResult TryUpdateBinary(Package* package, bool* wipe_cache, return INSTALL_SUCCESS; } -// Verifies the compatibility info in a Treble-compatible package. Returns true directly if the -// entry doesn't exist. Note that the compatibility info is packed in a zip file inside the OTA -// package. -bool verify_package_compatibility(ZipArchiveHandle package_zip) { - LOG(INFO) << "Verifying package compatibility..."; - - static constexpr const char* COMPATIBILITY_ZIP_ENTRY = "compatibility.zip"; - ZipEntry compatibility_entry; - if (FindEntry(package_zip, COMPATIBILITY_ZIP_ENTRY, &compatibility_entry) != 0) { - LOG(INFO) << "Package doesn't contain " << COMPATIBILITY_ZIP_ENTRY << " entry"; - return true; - } - - std::string zip_content(compatibility_entry.uncompressed_length, '\0'); - int32_t ret; - if ((ret = ExtractToMemory(package_zip, &compatibility_entry, - reinterpret_cast<uint8_t*>(&zip_content[0]), - compatibility_entry.uncompressed_length)) != 0) { - LOG(ERROR) << "Failed to read " << COMPATIBILITY_ZIP_ENTRY << ": " << ErrorCodeString(ret); - return false; - } - - ZipArchiveHandle zip_handle; - ret = OpenArchiveFromMemory(static_cast<void*>(const_cast<char*>(zip_content.data())), - zip_content.size(), COMPATIBILITY_ZIP_ENTRY, &zip_handle); - if (ret != 0) { - LOG(ERROR) << "Failed to OpenArchiveFromMemory: " << ErrorCodeString(ret); - return false; - } - - // Iterate all the entries inside COMPATIBILITY_ZIP_ENTRY and read the contents. - void* cookie; - ret = StartIteration(zip_handle, &cookie); - if (ret != 0) { - LOG(ERROR) << "Failed to start iterating zip entries: " << ErrorCodeString(ret); - CloseArchive(zip_handle); - return false; - } - std::unique_ptr<void, decltype(&EndIteration)> guard(cookie, EndIteration); - - std::vector<std::string> compatibility_info; - ZipEntry info_entry; - std::string_view info_name; - while (Next(cookie, &info_entry, &info_name) == 0) { - std::string content(info_entry.uncompressed_length, '\0'); - int32_t ret = ExtractToMemory(zip_handle, &info_entry, reinterpret_cast<uint8_t*>(&content[0]), - info_entry.uncompressed_length); - if (ret != 0) { - LOG(ERROR) << "Failed to read " << info_name << ": " << ErrorCodeString(ret); - CloseArchive(zip_handle); - return false; - } - compatibility_info.emplace_back(std::move(content)); - } - CloseArchive(zip_handle); - - // VintfObjectRecovery::CheckCompatibility returns zero on success. - std::string err; - int result = android::vintf::VintfObjectRecovery::CheckCompatibility(compatibility_info, &err); - if (result == 0) { - return true; - } - - LOG(ERROR) << "Failed to verify package compatibility (result " << result << "): " << err; - return false; -} - static InstallResult VerifyAndInstallPackage(Package* package, bool* wipe_cache, std::vector<std::string>* log_buffer, int retry_count, int* max_temperature, RecoveryUI* ui) { @@ -587,19 +519,6 @@ static InstallResult VerifyAndInstallPackage(Package* package, bool* wipe_cache, return INSTALL_CORRUPT; } - // Try to open the package. - ZipArchiveHandle zip = package->GetZipArchiveHandle(); - if (!zip) { - log_buffer->push_back(android::base::StringPrintf("error: %d", kZipOpenFailure)); - return INSTALL_CORRUPT; - } - - // Additionally verify the compatibility of the package if it's a fresh install. - if (retry_count == 0 && !verify_package_compatibility(zip)) { - log_buffer->push_back(android::base::StringPrintf("error: %d", kPackageCompatibilityFailure)); - return INSTALL_CORRUPT; - } - // Verify and install the contents of the package. ui->Print("Installing update...\n"); if (retry_count > 0) { diff --git a/minui/graphics.cpp b/minui/graphics.cpp index 4d1f9b2d..d34da567 100644 --- a/minui/graphics.cpp +++ b/minui/graphics.cpp @@ -209,7 +209,7 @@ void gr_texticon(int x, int y, const GRSurface* icon) { void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a) { uint32_t r32 = r, g32 = g, b32 = b, a32 = a; - if (pixel_format == PixelFormat::ABGR || pixel_format == PixelFormat::BGRA) { + if (pixel_format == PixelFormat::ARGB || pixel_format == PixelFormat::BGRA) { gr_current = (a32 << 24) | (r32 << 16) | (g32 << 8) | b32; } else { gr_current = (a32 << 24) | (b32 << 16) | (g32 << 8) | r32; @@ -348,6 +348,8 @@ int gr_init() { pixel_format = PixelFormat::ABGR; } else if (format == "RGBX_8888") { pixel_format = PixelFormat::RGBX; + } else if (format == "ARGB_8888") { + pixel_format = PixelFormat::ARGB; } else if (format == "BGRA_8888") { pixel_format = PixelFormat::BGRA; } else { diff --git a/minui/graphics_drm.cpp b/minui/graphics_drm.cpp index 3fee5a11..48589d49 100644 --- a/minui/graphics_drm.cpp +++ b/minui/graphics_drm.cpp @@ -317,6 +317,8 @@ static int drm_format_to_bpp(uint32_t format) { case DRM_FORMAT_ABGR8888: case DRM_FORMAT_BGRA8888: case DRM_FORMAT_RGBX8888: + case DRM_FORMAT_RGBA8888: + case DRM_FORMAT_ARGB8888: case DRM_FORMAT_BGRX8888: case DRM_FORMAT_XBGR8888: case DRM_FORMAT_XRGB8888: @@ -342,6 +344,8 @@ std::unique_ptr<GRSurfaceDrm> GRSurfaceDrm::Create(int drm_fd, int width, int he format = DRM_FORMAT_ARGB8888; } else if (pixel_format == PixelFormat::RGBX) { format = DRM_FORMAT_XBGR8888; + } else if (pixel_format == PixelFormat::ARGB) { + format = DRM_FORMAT_BGRA8888; } else { format = DRM_FORMAT_RGB565; } diff --git a/minui/include/minui/minui.h b/minui/include/minui/minui.h index 36bdcf10..163e41dc 100644 --- a/minui/include/minui/minui.h +++ b/minui/include/minui/minui.h @@ -101,6 +101,7 @@ enum class PixelFormat : int { ABGR = 1, RGBX = 2, BGRA = 3, + ARGB = 4, }; // Initializes the graphics backend and loads font file. Returns 0 on success, or -1 on error. Note diff --git a/minui/resources.cpp b/minui/resources.cpp index 00d36d5f..f635acd1 100644 --- a/minui/resources.cpp +++ b/minui/resources.cpp @@ -199,7 +199,7 @@ int res_create_display_surface(const char* name, GRSurface** pSurface) { } PixelFormat pixel_format = gr_pixel_format(); - if (pixel_format == PixelFormat::ABGR || pixel_format == PixelFormat::BGRA) { + if (pixel_format == PixelFormat::ARGB || pixel_format == PixelFormat::BGRA) { png_set_bgr(png_ptr); } @@ -271,7 +271,7 @@ int res_create_multi_display_surface(const char* name, int* frames, int* fps, surface[i] = created_surface.release(); } - if (gr_pixel_format() == PixelFormat::ABGR || gr_pixel_format() == PixelFormat::BGRA) { + if (gr_pixel_format() == PixelFormat::ARGB || gr_pixel_format() == PixelFormat::BGRA) { png_set_bgr(png_ptr); } @@ -317,7 +317,7 @@ int res_create_alpha_surface(const char* name, GRSurface** pSurface) { } PixelFormat pixel_format = gr_pixel_format(); - if (pixel_format == PixelFormat::ABGR || pixel_format == PixelFormat::BGRA) { + if (pixel_format == PixelFormat::ARGB || pixel_format == PixelFormat::BGRA) { png_set_bgr(png_ptr); } diff --git a/tests/Android.bp b/tests/Android.bp index ec49c07a..640bb042 100644 --- a/tests/Android.bp +++ b/tests/Android.bp @@ -39,6 +39,7 @@ cc_defaults { android: { shared_libs: [ "libutils", + "libvndksupport", ], }, @@ -81,7 +82,6 @@ librecovery_static_libs = [ "libotautil", "libhealthhalutils", - "libvintf_recovery", "libvintf", "android.hardware.health@2.0", @@ -92,7 +92,6 @@ librecovery_static_libs = [ "libhidlbase", "libbinderthreadstate", "liblp", - "libvndksupport", "libtinyxml2", "libc++fs", ] diff --git a/tests/unit/install_test.cpp b/tests/unit/install_test.cpp index 60cdc110..ee753494 100644 --- a/tests/unit/install_test.cpp +++ b/tests/unit/install_test.cpp @@ -28,7 +28,6 @@ #include <android-base/properties.h> #include <android-base/strings.h> #include <gtest/gtest.h> -#include <vintf/VintfObjectRecovery.h> #include <ziparchive/zip_archive.h> #include <ziparchive/zip_writer.h> @@ -51,29 +50,6 @@ static void BuildZipArchive(const std::map<std::string, std::string>& file_map, ASSERT_EQ(0, fclose(zip_file)); } -TEST(InstallTest, verify_package_compatibility_no_entry) { - TemporaryFile temp_file; - // The archive must have something to be opened correctly. - BuildZipArchive({ { "dummy_entry", "" } }, temp_file.release(), kCompressStored); - - // Doesn't contain compatibility zip entry. - ZipArchiveHandle zip; - ASSERT_EQ(0, OpenArchive(temp_file.path, &zip)); - ASSERT_TRUE(verify_package_compatibility(zip)); - CloseArchive(zip); -} - -TEST(InstallTest, verify_package_compatibility_invalid_entry) { - TemporaryFile temp_file; - BuildZipArchive({ { "compatibility.zip", "" } }, temp_file.release(), kCompressStored); - - // Empty compatibility zip entry. - ZipArchiveHandle zip; - ASSERT_EQ(0, OpenArchive(temp_file.path, &zip)); - ASSERT_FALSE(verify_package_compatibility(zip)); - CloseArchive(zip); -} - TEST(InstallTest, read_metadata_from_package_smoke) { TemporaryFile temp_file; const std::string content("abc=defg"); @@ -135,64 +111,6 @@ TEST(InstallTest, read_wipe_ab_partition_list) { ASSERT_EQ(expected, read_partition_list); } -TEST(InstallTest, verify_package_compatibility_with_libvintf_malformed_xml) { - TemporaryFile compatibility_zip_file; - std::string malformed_xml = "malformed"; - BuildZipArchive({ { "system_manifest.xml", malformed_xml } }, compatibility_zip_file.release(), - kCompressDeflated); - - TemporaryFile temp_file; - std::string compatibility_zip_content; - ASSERT_TRUE( - android::base::ReadFileToString(compatibility_zip_file.path, &compatibility_zip_content)); - BuildZipArchive({ { "compatibility.zip", compatibility_zip_content } }, temp_file.release(), - kCompressStored); - - ZipArchiveHandle zip; - ASSERT_EQ(0, OpenArchive(temp_file.path, &zip)); - std::vector<std::string> compatibility_info; - compatibility_info.push_back(malformed_xml); - // Malformed compatibility zip is expected to be rejected by libvintf. But we defer that to - // libvintf. - std::string err; - bool result = - android::vintf::VintfObjectRecovery::CheckCompatibility(compatibility_info, &err) == 0; - ASSERT_EQ(result, verify_package_compatibility(zip)); - CloseArchive(zip); -} - -TEST(InstallTest, verify_package_compatibility_with_libvintf_system_manifest_xml) { - static constexpr const char* system_manifest_xml_path = "/system/manifest.xml"; - if (access(system_manifest_xml_path, R_OK) == -1) { - GTEST_LOG_(INFO) << "Test skipped on devices w/o /system/manifest.xml."; - return; - } - std::string system_manifest_xml_content; - ASSERT_TRUE( - android::base::ReadFileToString(system_manifest_xml_path, &system_manifest_xml_content)); - TemporaryFile compatibility_zip_file; - BuildZipArchive({ { "system_manifest.xml", system_manifest_xml_content } }, - compatibility_zip_file.release(), kCompressDeflated); - - TemporaryFile temp_file; - std::string compatibility_zip_content; - ASSERT_TRUE( - android::base::ReadFileToString(compatibility_zip_file.path, &compatibility_zip_content)); - BuildZipArchive({ { "compatibility.zip", compatibility_zip_content } }, temp_file.release(), - kCompressStored); - - ZipArchiveHandle zip; - ASSERT_EQ(0, OpenArchive(temp_file.path, &zip)); - std::vector<std::string> compatibility_info; - compatibility_info.push_back(system_manifest_xml_content); - std::string err; - bool result = - android::vintf::VintfObjectRecovery::CheckCompatibility(compatibility_info, &err) == 0; - // Make sure the result is consistent with libvintf library. - ASSERT_EQ(result, verify_package_compatibility(zip)); - CloseArchive(zip); -} - TEST(InstallTest, SetUpNonAbUpdateCommands) { TemporaryFile temp_file; static constexpr const char* UPDATE_BINARY_NAME = "META-INF/com/google/android/update-binary"; |