Merge "Mark libdiskconfig vendor_available." into oc-dev
diff --git a/adb/bugreport.cpp b/adb/bugreport.cpp
index d159d6a..b3e391b 100644
--- a/adb/bugreport.cpp
+++ b/adb/bugreport.cpp
@@ -149,7 +149,7 @@
int progress = std::stoi(line.substr(idx1, (idx2 - idx1)));
int total = std::stoi(line.substr(idx2 + 1));
int progress_percentage = (progress * 100 / total);
- if (progress_percentage <= last_progress_percentage_) {
+ if (progress_percentage != 0 && progress_percentage <= last_progress_percentage_) {
// Ignore.
return;
}
diff --git a/adb/bugreport_test.cpp b/adb/bugreport_test.cpp
index 2b368d7..d3787b4 100644
--- a/adb/bugreport_test.cpp
+++ b/adb/bugreport_test.cpp
@@ -311,6 +311,29 @@
ASSERT_EQ(0, br_.DoIt(kTransportLocal, "HannibalLecter", 2, args));
}
+// Tests 'adb bugreport file.zip' when it succeeds and displays the initial progress of 0%
+TEST_F(BugreportTest, OkProgressZeroPercentIsNotIgnored) {
+ ExpectBugreportzVersion("1.1");
+ ExpectProgress(0);
+ ExpectProgress(1);
+ // clang-format off
+ EXPECT_CALL(br_, SendShellCommand(kTransportLocal, "HannibalLecter", "bugreportz -p", false, _))
+ // NOTE: DoAll accepts at most 10 arguments, and we're almost reached that limit...
+ .WillOnce(DoAll(
+ WithArg<4>(WriteOnStdout("BEGIN:/device/bugreport.zip\n")),
+ WithArg<4>(WriteOnStdout("PROGRESS:1/100000\n")),
+ WithArg<4>(WriteOnStdout("PROGRESS:1/100\n")), // 1%
+ WithArg<4>(WriteOnStdout("OK:/device/bugreport.zip")),
+ WithArg<4>(ReturnCallbackDone())));
+ // clang-format on
+ EXPECT_CALL(br_, DoSyncPull(ElementsAre(StrEq("/device/bugreport.zip")), StrEq("file.zip"),
+ true, StrEq("pulling file.zip")))
+ .WillOnce(Return(true));
+
+ const char* args[] = {"bugreport", "file.zip"};
+ ASSERT_EQ(0, br_.DoIt(kTransportLocal, "HannibalLecter", 2, args));
+}
+
// Tests 'adb bugreport dir' when it succeeds and destination is a directory.
TEST_F(BugreportTest, OkDirectory) {
ExpectBugreportzVersion("1.1");
diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp
index e224aec..803b894 100644
--- a/fs_mgr/fs_mgr.cpp
+++ b/fs_mgr/fs_mgr.cpp
@@ -949,16 +949,20 @@
}
encryptable = FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED;
} else {
+ // fs_options might be null so we cannot use PERROR << directly.
+ // Use StringPrintf to output "(null)" instead.
if (fs_mgr_is_nofail(&fstab->recs[attempted_idx])) {
- PERROR << "Ignoring failure to mount an un-encryptable or wiped partition on"
- << fstab->recs[attempted_idx].blk_device << " at "
- << fstab->recs[attempted_idx].mount_point << " options: "
- << fstab->recs[attempted_idx].fs_options;
+ PERROR << android::base::StringPrintf(
+ "Ignoring failure to mount an un-encryptable or wiped "
+ "partition on %s at %s options: %s",
+ fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point,
+ fstab->recs[attempted_idx].fs_options);
} else {
- PERROR << "Failed to mount an un-encryptable or wiped partition on"
- << fstab->recs[attempted_idx].blk_device << " at "
- << fstab->recs[attempted_idx].mount_point << " options: "
- << fstab->recs[attempted_idx].fs_options;
+ PERROR << android::base::StringPrintf(
+ "Failed to mount an un-encryptable or wiped partition "
+ "on %s at %s options: %s",
+ fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point,
+ fstab->recs[attempted_idx].fs_options);
++error_count;
}
continue;
diff --git a/fs_mgr/fs_mgr_fstab.cpp b/fs_mgr/fs_mgr_fstab.cpp
index 0a694c1..7d09d01 100644
--- a/fs_mgr/fs_mgr_fstab.cpp
+++ b/fs_mgr/fs_mgr_fstab.cpp
@@ -397,6 +397,15 @@
std::vector<std::string> fstab_entry;
std::string file_name;
std::string value;
+ // skip a partition entry if the status property is present and not set to ok
+ file_name = android::base::StringPrintf("%s/%s/status", fstabdir_name.c_str(), dp->d_name);
+ if (read_dt_file(file_name, &value)) {
+ if (value != "okay" && value != "ok") {
+ LINFO << "dt_fstab: Skip disabled entry for partition " << dp->d_name;
+ continue;
+ }
+ }
+
file_name = android::base::StringPrintf("%s/%s/dev", fstabdir_name.c_str(), dp->d_name);
if (!read_dt_file(file_name, &value)) {
LERROR << "dt_fstab: Failed to find device for partition " << dp->d_name;
diff --git a/include/nativebridge/native_bridge.h b/include/nativebridge/native_bridge.h
index 929b8ae..9bfc935 100644
--- a/include/nativebridge/native_bridge.h
+++ b/include/nativebridge/native_bridge.h
@@ -161,6 +161,9 @@
// Use NativeBridgeLoadLibrary() instead in non-namespace scenario.
void* NativeBridgeLoadLibraryExt(const char* libpath, int flag, native_bridge_namespace_t* ns);
+// Returns vendor namespace if it is enabled for the device and null otherwise
+native_bridge_namespace_t* NativeBridgeGetVendorNamespace();
+
// Native bridge interfaces to runtime.
struct NativeBridgeCallbacks {
// Version number of the interface.
@@ -348,6 +351,15 @@
// Starting with v3, NativeBridge has two scenarios: with/without namespace.
// Use loadLibrary instead in non-namespace scenario.
void* (*loadLibraryExt)(const char* libpath, int flag, native_bridge_namespace_t* ns);
+
+ // Get native bridge version of vendor namespace.
+ // The vendor namespace is the namespace used to load vendor public libraries.
+ // With O release this namespace can be different from the default namespace.
+ // For the devices without enable vendor namespaces this function should return null
+ //
+ // Returns:
+ // vendor namespace or null if it was not set up for the device
+ native_bridge_namespace_t* (*getVendorNamespace)();
};
// Runtime interfaces to native bridge.
diff --git a/init/reboot.cpp b/init/reboot.cpp
index c997519..aac1b5c 100644
--- a/init/reboot.cpp
+++ b/init/reboot.cpp
@@ -331,7 +331,7 @@
// keep debugging tools until non critical ones are all gone.
const std::set<std::string> kill_after_apps{"tombstoned", "logd", "adbd"};
// watchdogd is a vendor specific component but should be alive to complete shutdown safely.
- const std::set<std::string> to_starts{"watchdogd", "vold"};
+ const std::set<std::string> to_starts{"watchdogd", "vold", "ueventd"};
ServiceManager::GetInstance().ForEachService([&kill_after_apps, &to_starts](Service* s) {
if (kill_after_apps.count(s->name())) {
s->SetShutdownCritical();
diff --git a/libcutils/fs_config.c b/libcutils/fs_config.c
index 17d7cb9..d98a923 100644
--- a/libcutils/fs_config.c
+++ b/libcutils/fs_config.c
@@ -214,6 +214,9 @@
/* Support wifi_hal_legacy administering a network interface. */
{ 00755, AID_WIFI, AID_WIFI, CAP_MASK_LONG(CAP_NET_ADMIN) |
CAP_MASK_LONG(CAP_NET_RAW),
+ "system/vendor/bin/hw/android.hardware.wifi@1.0-service" },
+ { 00755, AID_WIFI, AID_WIFI, CAP_MASK_LONG(CAP_NET_ADMIN) |
+ CAP_MASK_LONG(CAP_NET_RAW),
"vendor/bin/hw/android.hardware.wifi@1.0-service" },
/* A non-privileged zygote that spawns
diff --git a/liblog/tests/liblog_test.cpp b/liblog/tests/liblog_test.cpp
index ec32da0..71f74ab 100644
--- a/liblog/tests/liblog_test.cpp
+++ b/liblog/tests/liblog_test.cpp
@@ -36,6 +36,7 @@
#endif
#include <gtest/gtest.h>
#include <log/log_event_list.h>
+#include <log/log_properties.h>
#include <log/log_transport.h>
#include <log/logprint.h>
#include <private/android_filesystem_config.h>
@@ -1786,6 +1787,12 @@
stderr,
"WARNING: test conditions request being run as root and not AID=%d\n",
getuid());
+ if (!__android_log_is_debuggable()) {
+ fprintf(
+ stderr,
+ "WARNING: can not run test on a \"user\" build, bypassing test\n");
+ return;
+ }
}
system((getuid() == AID_ROOT) ? "stop logd" : "su 0 stop logd");
diff --git a/liblog/tests/log_read_test.cpp b/liblog/tests/log_read_test.cpp
index a63ab8e..6ed568a 100644
--- a/liblog/tests/log_read_test.cpp
+++ b/liblog/tests/log_read_test.cpp
@@ -23,6 +23,7 @@
#include <android-base/stringprintf.h>
#include <android/log.h> // minimal logging API
#include <gtest/gtest.h>
+#include <log/log_properties.h>
// Test the APIs in this standalone include file
#include <log/log_read.h>
// Do not use anything in log/log_time.h despite side effects of the above.
@@ -97,9 +98,12 @@
/* security buffer is allowed to be denied */
if (strcmp("security", name)) {
EXPECT_LT(0, get_log_size);
- /* crash buffer is allowed to be empty, that is actually healthy! */
- EXPECT_LE((strcmp("crash", name)) != 0,
- android_logger_get_log_readable_size(logger));
+ // crash buffer is allowed to be empty, that is actually healthy!
+ // kernel buffer is allowed to be empty on "user" builds
+ EXPECT_LE( // boolean 1 or 0 depending on expected content or empty
+ !!((strcmp("crash", name) != 0) &&
+ ((strcmp("kernel", name) != 0) || __android_log_is_debuggable())),
+ android_logger_get_log_readable_size(logger));
} else {
EXPECT_NE(0, get_log_size);
if (get_log_size < 0) {
diff --git a/libmetricslogger/Android.bp b/libmetricslogger/Android.bp
index da8afe1..79d6c3f 100644
--- a/libmetricslogger/Android.bp
+++ b/libmetricslogger/Android.bp
@@ -30,6 +30,7 @@
// -----------------------------------------------------------------------------
cc_library_shared {
name: "libmetricslogger",
+ vendor_available: true,
srcs: metricslogger_lib_src_files,
defaults: ["metricslogger_defaults"],
}
diff --git a/libnativebridge/.clang-format b/libnativebridge/.clang-format
new file mode 120000
index 0000000..fd0645f
--- /dev/null
+++ b/libnativebridge/.clang-format
@@ -0,0 +1 @@
+../.clang-format-2
\ No newline at end of file
diff --git a/libnativebridge/native_bridge.cc b/libnativebridge/native_bridge.cc
index 7976f67..cc30aaf 100644
--- a/libnativebridge/native_bridge.cc
+++ b/libnativebridge/native_bridge.cc
@@ -85,12 +85,14 @@
// Nativebridge implementation.
// Used by isCompatibleWith() which is introduced in v2.
enum NativeBridgeImplementationVersion {
- // first version, not used.
- DEFAULT_VERSION = 1,
- // The version which signal semantic is introduced.
- SIGNAL_VERSION = 2,
- // The version which namespace semantic is introduced.
- NAMESPACE_VERSION = 3,
+ // first version, not used.
+ DEFAULT_VERSION = 1,
+ // The version which signal semantic is introduced.
+ SIGNAL_VERSION = 2,
+ // The version which namespace semantic is introduced.
+ NAMESPACE_VERSION = 3,
+ // The version with vendor namespaces
+ VENDOR_NAMESPACE_VERSION = 4,
};
// Whether we had an error at some point.
@@ -621,6 +623,14 @@
return false;
}
+native_bridge_namespace_t* NativeBridgeGetVendorNamespace() {
+ if (!NativeBridgeInitialized() || !isCompatibleWith(VENDOR_NAMESPACE_VERSION)) {
+ return nullptr;
+ }
+
+ return callbacks->getVendorNamespace();
+}
+
void* NativeBridgeLoadLibraryExt(const char* libpath, int flag, native_bridge_namespace_t* ns) {
if (NativeBridgeInitialized()) {
if (isCompatibleWith(NAMESPACE_VERSION)) {
diff --git a/libnativeloader/.clang-format b/libnativeloader/.clang-format
new file mode 120000
index 0000000..fd0645f
--- /dev/null
+++ b/libnativeloader/.clang-format
@@ -0,0 +1 @@
+../.clang-format-2
\ No newline at end of file
diff --git a/libnativeloader/include/nativeloader/dlext_namespaces.h b/libnativeloader/include/nativeloader/dlext_namespaces.h
index 9121277..43c9329 100644
--- a/libnativeloader/include/nativeloader/dlext_namespaces.h
+++ b/libnativeloader/include/nativeloader/dlext_namespaces.h
@@ -124,6 +124,8 @@
*/
extern void android_get_LD_LIBRARY_PATH(char* buffer, size_t buffer_size);
+extern android_namespace_t* android_get_exported_namespace(const char* name);
+
__END_DECLS
#endif /* __ANDROID_DLEXT_NAMESPACES_H__ */
diff --git a/libnativeloader/native_loader.cpp b/libnativeloader/native_loader.cpp
index 100c31d..36a2e44 100644
--- a/libnativeloader/native_loader.cpp
+++ b/libnativeloader/native_loader.cpp
@@ -83,6 +83,12 @@
static constexpr const char* kPublicNativeLibrariesVendorConfig =
"/vendor/etc/public.libraries.txt";
+// The device may be configured to have the vendor libraries loaded to a separate namespace.
+// For historical reasons this namespace was named sphal but effectively it is intended
+// to use to load vendor libraries to separate namespace with controlled interface between
+// vendor and system namespaces.
+static constexpr const char* kVendorNamespaceName = "sphal";
+
// (http://b/27588281) This is a workaround for apps using custom classloaders and calling
// System.load() with an absolute path which is outside of the classloader library search path.
// This list includes all directories app is allowed to access this way.
@@ -170,11 +176,23 @@
return false;
}
- if (!android_link_namespaces(ns, nullptr, public_libraries_.c_str())) {
+ // Note that when vendor_ns is not configured this function will return nullptr
+ // and it will result in linking vendor_public_libraries_ to the default namespace
+ // which is expected behavior in this case.
+ android_namespace_t* vendor_ns = android_get_exported_namespace(kVendorNamespaceName);
+
+ if (!android_link_namespaces(ns, nullptr, system_public_libraries_.c_str())) {
*error_msg = dlerror();
return false;
}
+ if (!vendor_public_libraries_.empty()) {
+ if (!android_link_namespaces(ns, vendor_ns, vendor_public_libraries_.c_str())) {
+ *error_msg = dlerror();
+ return false;
+ }
+ }
+
native_loader_ns = NativeLoaderNamespace(ns);
} else {
native_bridge_namespace_t* ns = NativeBridgeCreateNamespace("classloader-namespace",
@@ -183,14 +201,24 @@
namespace_type,
permitted_path.c_str(),
parent_ns.get_native_bridge_ns());
+
if (ns == nullptr) {
*error_msg = NativeBridgeGetError();
return false;
}
- if (!NativeBridgeLinkNamespaces(ns, nullptr, public_libraries_.c_str())) {
+ native_bridge_namespace_t* vendor_ns = NativeBridgeGetVendorNamespace();
+
+ if (!NativeBridgeLinkNamespaces(ns, nullptr, system_public_libraries_.c_str())) {
+ *error_msg = NativeBridgeGetError();
+ return false;
+ }
+
+ if (!vendor_public_libraries_.empty()) {
+ if (!NativeBridgeLinkNamespaces(ns, vendor_ns, vendor_public_libraries_.c_str())) {
*error_msg = NativeBridgeGetError();
return false;
+ }
}
native_loader_ns = NativeLoaderNamespace(ns);
@@ -249,9 +277,6 @@
}
}
- // This file is optional, quietly ignore if the file does not exist.
- ReadConfig(kPublicNativeLibrariesVendorConfig, &sonames);
-
// android_init_namespaces() expects all the public libraries
// to be loaded so that they can be found by soname alone.
//
@@ -266,7 +291,13 @@
soname.c_str(), dlerror());
}
- public_libraries_ = base::Join(sonames, ':');
+ system_public_libraries_ = base::Join(sonames, ':');
+
+ sonames.clear();
+ // This file is optional, quietly ignore if the file does not exist.
+ ReadConfig(kPublicNativeLibrariesVendorConfig, &sonames);
+
+ vendor_public_libraries_ = base::Join(sonames, ':');
}
void Reset() {
@@ -325,7 +356,7 @@
// code is one example) unknown to linker in which case linker uses anonymous
// namespace. The second argument specifies the search path for the anonymous
// namespace which is the library_path of the classloader.
- initialized_ = android_init_anonymous_namespace(public_libraries_.c_str(),
+ initialized_ = android_init_anonymous_namespace(system_public_libraries_.c_str(),
is_native_bridge ? nullptr : library_path);
if (!initialized_) {
*error_msg = dlerror();
@@ -334,10 +365,10 @@
// and now initialize native bridge namespaces if necessary.
if (NativeBridgeInitialized()) {
- initialized_ = NativeBridgeInitAnonymousNamespace(
- public_libraries_.c_str(), is_native_bridge ? library_path : nullptr);
- if (!initialized_) {
- *error_msg = NativeBridgeGetError();
+ initialized_ = NativeBridgeInitAnonymousNamespace(system_public_libraries_.c_str(),
+ is_native_bridge ? library_path : nullptr);
+ if (!initialized_) {
+ *error_msg = NativeBridgeGetError();
}
}
@@ -371,8 +402,8 @@
bool initialized_;
std::vector<std::pair<jweak, NativeLoaderNamespace>> namespaces_;
- std::string public_libraries_;
-
+ std::string system_public_libraries_;
+ std::string vendor_public_libraries_;
DISALLOW_COPY_AND_ASSIGN(LibraryNamespaces);
};
diff --git a/libnetutils/Android.bp b/libnetutils/Android.bp
index f710ba2..d63d619 100644
--- a/libnetutils/Android.bp
+++ b/libnetutils/Android.bp
@@ -1,5 +1,6 @@
cc_library_shared {
name: "libnetutils",
+ vendor_available: true,
srcs: [
"dhcpclient.c",
diff --git a/libsuspend/Android.bp b/libsuspend/Android.bp
index d442c94..130800e 100644
--- a/libsuspend/Android.bp
+++ b/libsuspend/Android.bp
@@ -2,6 +2,8 @@
cc_library {
name: "libsuspend",
+ vendor_available: true,
+
srcs: [
"autosuspend.c",
"autosuspend_wakeup_count.c",
diff --git a/libsysutils/Android.bp b/libsysutils/Android.bp
index 296bd26..550ef42 100644
--- a/libsysutils/Android.bp
+++ b/libsysutils/Android.bp
@@ -1,5 +1,7 @@
cc_library_shared {
name: "libsysutils",
+ vendor_available: true,
+
srcs: [
"src/SocketListener.cpp",
"src/FrameworkListener.cpp",
diff --git a/libutils/Android.bp b/libutils/Android.bp
index 696db3b..5e76279 100644
--- a/libutils/Android.bp
+++ b/libutils/Android.bp
@@ -94,6 +94,7 @@
"libcutils",
"libdl",
"liblog",
+ "libvndksupport",
],
sanitize: {
diff --git a/libutils/misc.cpp b/libutils/misc.cpp
index ab72fe6..d95fd05 100644
--- a/libutils/misc.cpp
+++ b/libutils/misc.cpp
@@ -23,6 +23,13 @@
#include <utils/Log.h>
#include <utils/Vector.h>
+#if defined(__ANDROID__)
+#include <dlfcn.h>
+#include <vndksupport/linker.h>
+#endif
+
+extern "C" void do_report_sysprop_change();
+
using namespace android;
namespace android {
@@ -61,7 +68,36 @@
#endif
}
+#if defined(__ANDROID__)
+void (*get_report_sysprop_change_func())() {
+ void (*func)() = nullptr;
+ void* handle = android_load_sphal_library("libutils.so", RTLD_NOW);
+ if (handle != nullptr) {
+ func = reinterpret_cast<decltype(func)>(dlsym(handle, "do_report_sysprop_change"));
+ }
+
+ return func;
+}
+#endif
+
void report_sysprop_change() {
+ do_report_sysprop_change();
+
+#if defined(__ANDROID__)
+ // libutils.so is double loaded; from the default namespace and from the
+ // 'sphal' namespace. Redirect the sysprop change event to the other instance
+ // of libutils.so loaded in the 'sphal' namespace so that listeners attached
+ // to that instance is also notified with this event.
+ static auto func = get_report_sysprop_change_func();
+ if (func != nullptr) {
+ (*func)();
+ }
+#endif
+}
+
+}; // namespace android
+
+void do_report_sysprop_change() {
#if !defined(_WIN32)
pthread_mutex_lock(&gSyspropMutex);
Vector<sysprop_change_callback_info> listeners;
@@ -76,5 +112,3 @@
}
#endif
}
-
-}; // namespace android
diff --git a/libvndksupport/Android.bp b/libvndksupport/Android.bp
index ab9e26f..b624223 100644
--- a/libvndksupport/Android.bp
+++ b/libvndksupport/Android.bp
@@ -1,6 +1,6 @@
subdirs = ["tests"]
-cc_library_shared {
+cc_library {
name: "libvndksupport",
srcs: ["linker.c"],
local_include_dirs: ["include/vndksupport"],
diff --git a/libziparchive/Android.bp b/libziparchive/Android.bp
index 44daf36..0a4f088 100644
--- a/libziparchive/Android.bp
+++ b/libziparchive/Android.bp
@@ -56,6 +56,8 @@
cc_library {
name: "libziparchive",
host_supported: true,
+ vendor_available:true,
+
defaults: ["libziparchive_defaults", "libziparchive_flags"],
shared_libs: ["liblog", "libbase"],
target: {
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 944aae7..3b996a4 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -7,6 +7,7 @@
import /init.environ.rc
import /init.usb.rc
import /init.${ro.hardware}.rc
+import /vendor/etc/init/hw/init.${ro.hardware}.rc
import /init.usb.configfs.rc
import /init.${ro.zygote}.rc
diff --git a/shell_and_utilities/Android.bp b/shell_and_utilities/Android.bp
new file mode 100644
index 0000000..4f4fc5d
--- /dev/null
+++ b/shell_and_utilities/Android.bp
@@ -0,0 +1,16 @@
+phony {
+ name: "shell_and_utilities",
+ required: [
+ "bzip2",
+ "grep",
+ "gzip",
+ "mkshrc",
+ "mkshrc_vendor",
+ "reboot",
+ "sh",
+ "sh_vendor",
+ "toolbox",
+ "toybox",
+ "toybox_vendor",
+ ],
+}