Merge "native_loader: add libvulkan.so to public native library list" into nyc-dev
diff --git a/fs_mgr/fs_mgr_format.c b/fs_mgr/fs_mgr_format.c
index c73045d..f8df081 100644
--- a/fs_mgr/fs_mgr_format.c
+++ b/fs_mgr/fs_mgr_format.c
@@ -52,7 +52,7 @@
info.len = ((off64_t)nr_sec * 512);
/* Use make_ext4fs_internal to avoid wiping an already-wiped partition. */
- rc = make_ext4fs_internal(fd, NULL, NULL, fs_mnt_point, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL);
+ rc = make_ext4fs_internal(fd, NULL, NULL, fs_mnt_point, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL);
if (rc) {
ERROR("make_ext4fs returned %d.\n", rc);
}
diff --git a/healthd/Android.mk b/healthd/Android.mk
index 27c985c..a4469fc 100644
--- a/healthd/Android.mk
+++ b/healthd/Android.mk
@@ -6,6 +6,16 @@
LOCAL_SRC_FILES := healthd_board_default.cpp
LOCAL_MODULE := libhealthd.default
LOCAL_CFLAGS := -Werror
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := BatteryMonitor.cpp
+LOCAL_MODULE := libbatterymonitor
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
+LOCAL_STATIC_LIBRARIES := libutils
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
@@ -14,7 +24,6 @@
healthd.cpp \
healthd_mode_android.cpp \
healthd_mode_charger.cpp \
- BatteryMonitor.cpp \
BatteryPropertiesRegistrar.cpp
LOCAL_MODULE := healthd
@@ -35,7 +44,7 @@
LOCAL_C_INCLUDES := bootable/recovery
-LOCAL_STATIC_LIBRARIES := libbatteryservice libbinder libminui libpng libz libutils libcutils liblog libm libc
+LOCAL_STATIC_LIBRARIES := libbatterymonitor libbatteryservice libbinder libminui libpng libz libutils libcutils liblog libm libc
ifeq ($(strip $(BOARD_CHARGER_ENABLE_SUSPEND)),true)
LOCAL_STATIC_LIBRARIES += libsuspend
diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp
index 11ddd3e..48af70e 100644
--- a/healthd/BatteryMonitor.cpp
+++ b/healthd/BatteryMonitor.cpp
@@ -16,8 +16,8 @@
#define LOG_TAG "healthd"
-#include "healthd.h"
-#include "BatteryMonitor.h"
+#include <healthd/healthd.h>
+#include <healthd/BatteryMonitor.h>
#include <dirent.h>
#include <errno.h>
@@ -340,6 +340,17 @@
props.chargerWirelessOnline;
}
+int BatteryMonitor::getChargeStatus() {
+ int result = BATTERY_STATUS_UNKNOWN;
+ if (!mHealthdConfig->batteryStatusPath.isEmpty()) {
+ char buf[128];
+ if (readFromFile(mHealthdConfig->batteryStatusPath, buf, sizeof(buf)) > 0) {
+ result = getBatteryStatus(buf);
+ }
+ }
+ return result;
+}
+
status_t BatteryMonitor::getProperty(int id, struct BatteryProperty *val) {
status_t ret = BAD_VALUE;
diff --git a/healthd/BatteryPropertiesRegistrar.cpp b/healthd/BatteryPropertiesRegistrar.cpp
index d3a89d7..5d1fa52 100644
--- a/healthd/BatteryPropertiesRegistrar.cpp
+++ b/healthd/BatteryPropertiesRegistrar.cpp
@@ -26,7 +26,7 @@
#include <utils/Mutex.h>
#include <utils/String16.h>
-#include "healthd.h"
+#include <healthd/healthd.h>
namespace android {
diff --git a/healthd/healthd.cpp b/healthd/healthd.cpp
index 85888c3..d9ac356 100644
--- a/healthd/healthd.cpp
+++ b/healthd/healthd.cpp
@@ -17,8 +17,8 @@
#define LOG_TAG "healthd"
#define KLOG_LEVEL 6
-#include "healthd.h"
-#include "BatteryMonitor.h"
+#include <healthd/healthd.h>
+#include <healthd/BatteryMonitor.h>
#include <errno.h>
#include <libgen.h>
diff --git a/healthd/healthd_board_default.cpp b/healthd/healthd_board_default.cpp
index ed4ddb4..eb55773 100644
--- a/healthd/healthd_board_default.cpp
+++ b/healthd/healthd_board_default.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <healthd.h>
+#include <healthd/healthd.h>
void healthd_board_init(struct healthd_config*)
{
diff --git a/healthd/healthd_mode_android.cpp b/healthd/healthd_mode_android.cpp
index 0a64099..323ef52 100644
--- a/healthd/healthd_mode_android.cpp
+++ b/healthd/healthd_mode_android.cpp
@@ -16,7 +16,7 @@
#define LOG_TAG "healthd-android"
-#include "healthd.h"
+#include <healthd/healthd.h>
#include "BatteryPropertiesRegistrar.h"
#include <binder/IPCThreadState.h>
diff --git a/healthd/healthd_mode_charger.cpp b/healthd/healthd_mode_charger.cpp
index 46bad4e..5846626 100644
--- a/healthd/healthd_mode_charger.cpp
+++ b/healthd/healthd_mode_charger.cpp
@@ -46,7 +46,7 @@
#include "minui/minui.h"
-#include "healthd.h"
+#include <healthd/healthd.h>
char *locale;
diff --git a/healthd/BatteryMonitor.h b/healthd/include/healthd/BatteryMonitor.h
similarity index 96%
rename from healthd/BatteryMonitor.h
rename to healthd/include/healthd/BatteryMonitor.h
index 6001073..440f2e4 100644
--- a/healthd/BatteryMonitor.h
+++ b/healthd/include/healthd/BatteryMonitor.h
@@ -22,7 +22,7 @@
#include <utils/String8.h>
#include <utils/Vector.h>
-#include "healthd.h"
+#include <healthd/healthd.h>
namespace android {
@@ -40,6 +40,7 @@
BatteryMonitor();
void init(struct healthd_config *hc);
bool update(void);
+ int getChargeStatus();
status_t getProperty(int id, struct BatteryProperty *val);
void dumpState(int fd);
diff --git a/healthd/healthd.h b/healthd/include/healthd/healthd.h
similarity index 100%
rename from healthd/healthd.h
rename to healthd/include/healthd/healthd.h
diff --git a/libnativeloader/Android.mk b/libnativeloader/Android.mk
index 5e65c4c..6c064c7 100644
--- a/libnativeloader/Android.mk
+++ b/libnativeloader/Android.mk
@@ -17,7 +17,8 @@
LOCAL_CPPFLAGS := -std=gnu++14 -fvisibility=hidden
LOCAL_LDFLAGS := -ldl
LOCAL_MULTILIB := both
-
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
include $(BUILD_SHARED_LIBRARY)
# Shared library for host
@@ -34,7 +35,8 @@
LOCAL_CPPFLAGS := -std=gnu++14 -fvisibility=hidden
LOCAL_LDFLAGS := -ldl
LOCAL_MULTILIB := both
-
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
include $(BUILD_HOST_SHARED_LIBRARY)
# Static library for host
@@ -50,5 +52,6 @@
LOCAL_CPPFLAGS := -std=gnu++14 -fvisibility=hidden
LOCAL_LDFLAGS := -ldl
LOCAL_MULTILIB := both
-
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/include/nativeloader/native_loader.h b/libnativeloader/include/nativeloader/native_loader.h
similarity index 75%
rename from include/nativeloader/native_loader.h
rename to libnativeloader/include/nativeloader/native_loader.h
index da07253..2dec71f 100644
--- a/include/nativeloader/native_loader.h
+++ b/libnativeloader/include/nativeloader/native_loader.h
@@ -19,6 +19,9 @@
#include "jni.h"
#include <stdint.h>
+#if defined(__ANDROID__)
+#include <android/dlext.h>
+#endif
namespace android {
@@ -27,6 +30,13 @@
jobject class_loader, bool is_shared, jstring library_path,
jstring permitted_path);
+#if defined(__ANDROID__)
+// Look up linker namespace by class_loader. Returns nullptr if
+// there is no namespace associated with the class_loader.
+__attribute__((visibility("default")))
+android_namespace_t* FindNamespaceByClassLoader(JNIEnv* env, jobject class_loader);
+#endif
+
}; // namespace android
#endif // NATIVE_BRIDGE_H_
diff --git a/libnativeloader/native_loader.cpp b/libnativeloader/native_loader.cpp
index 20d4293..e06be23 100644
--- a/libnativeloader/native_loader.cpp
+++ b/libnativeloader/native_loader.cpp
@@ -82,10 +82,10 @@
std::lock_guard<std::mutex> guard(mutex_);
- auto it = FindNamespaceByClassLoader(env, class_loader);
+ android_namespace_t* ns = FindNamespaceByClassLoader(env, class_loader);
- if (it != namespaces_.end()) {
- return it->second;
+ if (ns != nullptr) {
+ return ns;
}
uint64_t namespace_type = ANDROID_NAMESPACE_TYPE_ISOLATED;
@@ -93,20 +93,27 @@
namespace_type |= ANDROID_NAMESPACE_TYPE_SHARED;
}
- android_namespace_t* ns =
- android_create_namespace("classloader-namespace",
- nullptr,
- library_path.c_str(),
- namespace_type,
- java_permitted_path != nullptr ?
- permitted_path.c_str() :
- nullptr);
+ ns = android_create_namespace("classloader-namespace",
+ nullptr,
+ library_path.c_str(),
+ namespace_type,
+ java_permitted_path != nullptr ?
+ permitted_path.c_str() :
+ nullptr);
namespaces_.push_back(std::make_pair(env->NewWeakGlobalRef(class_loader), ns));
return ns;
}
+ android_namespace_t* FindNamespaceByClassLoader(JNIEnv* env, jobject class_loader) {
+ auto it = std::find_if(namespaces_.begin(), namespaces_.end(),
+ [&](const std::pair<jweak, android_namespace_t*>& value) {
+ return env->IsSameObject(value.first, class_loader);
+ });
+ return it != namespaces_.end() ? it->second : nullptr;
+ }
+
private:
void PreloadPublicLibraries() {
// android_init_namespaces() expects all the public libraries
@@ -134,14 +141,6 @@
return initialized_;
}
- std::vector<std::pair<jweak, android_namespace_t*>>::const_iterator
- FindNamespaceByClassLoader(JNIEnv* env, jobject class_loader) {
- return std::find_if(namespaces_.begin(), namespaces_.end(),
- [&](const std::pair<jweak, android_namespace_t*>& value) {
- return env->IsSameObject(value.first, class_loader);
- });
- }
-
bool initialized_;
std::mutex mutex_;
std::vector<std::pair<jweak, android_namespace_t*>> namespaces_;
@@ -181,4 +180,10 @@
#endif
}
+#if defined(__ANDROID__)
+android_namespace_t* FindNamespaceByClassLoader(JNIEnv* env, jobject class_loader) {
+ return g_namespaces->FindNamespaceByClassLoader(env, class_loader);
+}
+#endif
+
}; // android namespace