summaryrefslogtreecommitdiffstats
path: root/recovery_main.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-07-31 18:37:12 +0200
committerTao Bao <tbao@google.com>2018-08-06 21:35:23 +0200
commit42c45e2b66790a7fe97acf7a300b025d79f2aa57 (patch)
tree3ec91a5a43fe8933147aeda206f857b94203ef80 /recovery_main.cpp
parentMerge "minui: Move to Soong." (diff)
downloadandroid_bootable_recovery-42c45e2b66790a7fe97acf7a300b025d79f2aa57.tar
android_bootable_recovery-42c45e2b66790a7fe97acf7a300b025d79f2aa57.tar.gz
android_bootable_recovery-42c45e2b66790a7fe97acf7a300b025d79f2aa57.tar.bz2
android_bootable_recovery-42c45e2b66790a7fe97acf7a300b025d79f2aa57.tar.lz
android_bootable_recovery-42c45e2b66790a7fe97acf7a300b025d79f2aa57.tar.xz
android_bootable_recovery-42c45e2b66790a7fe97acf7a300b025d79f2aa57.tar.zst
android_bootable_recovery-42c45e2b66790a7fe97acf7a300b025d79f2aa57.zip
Diffstat (limited to '')
-rw-r--r--recovery_main.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/recovery_main.cpp b/recovery_main.cpp
index c79d7d8d8..9a9890de0 100644
--- a/recovery_main.cpp
+++ b/recovery_main.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
@@ -329,7 +330,32 @@ int main(int argc, char** argv) {
printf("locale is [%s]\n", locale.c_str());
- Device* device = make_device();
+ static constexpr const char* kDefaultLibRecoveryUIExt = "librecovery_ui_ext.so";
+ // Intentionally not calling dlclose(3) to avoid potential gotchas (e.g. `make_device` may have
+ // handed out pointers to code or static [or thread-local] data and doesn't collect them all back
+ // in on dlclose).
+ void* librecovery_ui_ext = dlopen(kDefaultLibRecoveryUIExt, RTLD_NOW);
+
+ using MakeDeviceType = decltype(&make_device);
+ MakeDeviceType make_device_func = nullptr;
+ if (librecovery_ui_ext == nullptr) {
+ printf("Failed to dlopen %s: %s\n", kDefaultLibRecoveryUIExt, dlerror());
+ } else {
+ reinterpret_cast<void*&>(make_device_func) = dlsym(librecovery_ui_ext, "make_device");
+ if (make_device_func == nullptr) {
+ printf("Failed to dlsym make_device: %s\n", dlerror());
+ }
+ }
+
+ Device* device;
+ if (make_device_func == nullptr) {
+ printf("Falling back to the default make_device() instead\n");
+ device = make_device();
+ } else {
+ printf("Loading make_device from %s\n", kDefaultLibRecoveryUIExt);
+ device = (*make_device_func)();
+ }
+
if (android::base::GetBoolProperty("ro.boot.quiescent", false)) {
printf("Quiescent recovery mode.\n");
device->ResetUI(new StubRecoveryUI());