diff options
-rw-r--r-- | cmds/installd/InstalldNativeService.cpp | 31 | ||||
-rw-r--r-- | libs/ui/Gralloc4.cpp | 4 |
2 files changed, 25 insertions, 10 deletions
diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp index e14af77194..c8ab8c07e6 100644 --- a/cmds/installd/InstalldNativeService.cpp +++ b/cmds/installd/InstalldNativeService.cpp @@ -40,6 +40,7 @@ #include <fstream> #include <functional> #include <regex> +#include <thread> #include <unordered_set> #include <android-base/file.h> @@ -555,19 +556,33 @@ static int restorecon_app_data_lazy(const std::string& path, const std::string& // If the initial top-level restorecon above changed the label, then go // back and restorecon everything recursively if (inProgress || before != after) { - ScopedTrace tracer("label-change"); if (existing) { LOG(DEBUG) << "Detected label change from " << before << " to " << after << " at " - << path << "; running recursive restorecon"; + << path << "; running recursive restorecon"; } - // Temporary mark the folder as "in-progress" to resume in case of reboot/other failure. - RestoreconInProgress fence(path); + auto restorecon = [path, seInfo, uid]() { + ScopedTrace tracer("label-change"); - if (selinux_android_restorecon_pkgdir(path.c_str(), seInfo.c_str(), uid, - SELINUX_ANDROID_RESTORECON_RECURSE) < 0) { - PLOG(ERROR) << "Failed recursive restorecon for " << path; - return -1; + // Temporary mark the folder as "in-progress" to resume in case of reboot/other failure. + RestoreconInProgress fence(path); + + if (selinux_android_restorecon_pkgdir(path.c_str(), seInfo.c_str(), uid, + SELINUX_ANDROID_RESTORECON_RECURSE) < 0) { + PLOG(ERROR) << "Failed recursive restorecon for " << path; + return -1; + } + return 0; + }; + if (inProgress) { + // The previous restorecon was interrupted. It's either crashed (unlikely), or the phone + // was rebooted. Possibly because it took too much time. This time let's move it to a + // separate thread - so it won't block the rest of the OS. + std::thread(restorecon).detach(); + } else { + if (int result = restorecon(); result) { + return result; + } } } diff --git a/libs/ui/Gralloc4.cpp b/libs/ui/Gralloc4.cpp index b6274ab9c0..03ff58a76c 100644 --- a/libs/ui/Gralloc4.cpp +++ b/libs/ui/Gralloc4.cpp @@ -468,8 +468,8 @@ status_t Gralloc4Mapper::isSupported(uint32_t width, uint32_t height, PixelForma uint32_t layerCount, uint64_t usage, bool* outSupported) const { IMapper::BufferDescriptorInfo descriptorInfo; - if (auto error = sBufferDescriptorInfo("isSupported", width, height, format, layerCount, usage, - &descriptorInfo) != OK) { + if (sBufferDescriptorInfo("isSupported", width, height, format, layerCount, usage, + &descriptorInfo) != OK) { // Usage isn't known to the HAL or otherwise failed validation. *outSupported = false; return OK; |