diff --git a/init/Android.bp b/init/Android.bp index 639d8d1b9..9aeb8371f 100644 --- a/init/Android.bp +++ b/init/Android.bp @@ -132,7 +132,7 @@ cc_library_static { "ueventd_parser.cpp", "util.cpp", ], - whole_static_libs: ["libcap"], + whole_static_libs: ["libcap", "com.android.sysprop.apex"], header_libs: ["bootimg_headers"], proto: { type: "lite", diff --git a/init/Android.mk b/init/Android.mk index 59d7f114e..ac05542d6 100644 --- a/init/Android.mk +++ b/init/Android.mk @@ -93,6 +93,7 @@ LOCAL_STATIC_LIBRARIES := \ libselinux \ libcap \ libgsi \ + libcom.android.sysprop.apex \ LOCAL_SANITIZE := signed-integer-overflow # First stage init is weird: it may start without stdout/stderr, and no /proc. diff --git a/init/mount_namespace.cpp b/init/mount_namespace.cpp index 327446a30..4161df22b 100644 --- a/init/mount_namespace.cpp +++ b/init/mount_namespace.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -132,9 +133,9 @@ static bool BindMountBionic(const std::string& linker_source, const std::string& return true; } -static bool IsBionicUpdatable() { - static bool result = android::base::GetBoolProperty("ro.apex.IsBionicUpdatable", false); - return result; +static bool IsApexUpdatable() { + static bool updatable = android::sysprop::ApexProperties::updatable().value_or(false); + return updatable; } static android::base::unique_fd bootstrap_ns_fd; @@ -187,7 +188,7 @@ bool SetupMountNamespaces() { // bind-mounted. In the namespace for post-apexd processes, the bionic from // the runtime APEX is bind-mounted. bool success = true; - if (IsBionicUpdatable() && !IsRecoveryMode()) { + if (IsApexUpdatable() && !IsRecoveryMode()) { // Creating a new namespace by cloning, saving, and switching back to // the original namespace. if (unshare(CLONE_NEWNS) == -1) { @@ -244,7 +245,7 @@ bool SetupRuntimeBionic() { return true; } // Bind-mount bionic from the runtime APEX since it is now available. Note - // that in case of IsBionicUpdatable() == false, these mounts are over the + // that in case of IsApexUpdatable() == false, these mounts are over the // existing existing bind mounts for the bootstrap bionic, which effectively // becomes hidden. if (!BindMountBionic(kRuntimeLinkerPath, kRuntimeBionicLibsDir, kLinkerMountPoint, @@ -264,7 +265,7 @@ bool SwitchToBootstrapMountNamespaceIfNeeded() { return true; } if (bootstrap_ns_id != GetMountNamespaceId() && bootstrap_ns_fd.get() != -1 && - IsBionicUpdatable()) { + IsApexUpdatable()) { if (setns(bootstrap_ns_fd.get(), CLONE_NEWNS) == -1) { PLOG(ERROR) << "Failed to switch to bootstrap mount namespace."; return false;