Merge "Migrate to packages/modules/StatsD/lib/*"
diff --git a/init/init.cpp b/init/init.cpp
index 1d0a9dc..d1998a5 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -266,12 +266,10 @@
if (shutdown_state.do_shutdown()) {
LOG(ERROR) << "sys.powerctl set while a previous shutdown command has not been handled";
UnwindMainThreadStack();
- DumpShutdownDebugInformation();
}
if (IsShuttingDown()) {
LOG(ERROR) << "sys.powerctl set while init is already shutting down";
UnwindMainThreadStack();
- DumpShutdownDebugInformation();
}
}
@@ -760,7 +758,7 @@
trigger_shutdown = [](const std::string& command) { shutdown_state.TriggerShutdown(command); };
SetStdioToDevNull(argv);
- InitSecondStageLogging(argv);
+ InitKernelLogging(argv);
LOG(INFO) << "init second stage started!";
// Update $PATH in the case the second stage init is newer than first stage init, where it is
diff --git a/init/util.cpp b/init/util.cpp
index aec3173..255434a 100644
--- a/init/util.cpp
+++ b/init/util.cpp
@@ -30,9 +30,7 @@
#include <time.h>
#include <unistd.h>
-#include <mutex>
#include <thread>
-#include <vector>
#include <android-base/file.h>
#include <android-base/logging.h>
@@ -724,50 +722,5 @@
return access("/system/bin/recovery", F_OK) == 0;
}
-// TODO(b/155203339): remove this
-// Devices in the lab seem to be stuck during shutdown, but the logs don't capture the last actions
-// before shutdown started, so we record those lines, ignoring requests to shutdown, and replay them
-// if we identify that the device is stuck.
-constexpr size_t kRecordedLogsSize = 30;
-std::string recorded_logs[kRecordedLogsSize];
-size_t recorded_log_position = 0;
-std::mutex recorded_logs_lock;
-
-void InitSecondStageLogging(char** argv) {
- SetFatalRebootTarget();
- auto second_stage_logger = [](android::base::LogId log_id, android::base::LogSeverity severity,
- const char* tag, const char* file, unsigned int line,
- const char* message) {
- // We only store logs for init, not its children, and only if they're not related to
- // sys.powerctl.
- if (getpid() == 1 && strstr(message, "sys.powerctl") == nullptr) {
- auto lock = std::lock_guard{recorded_logs_lock};
- recorded_logs[recorded_log_position++] = message;
- if (recorded_log_position == kRecordedLogsSize) {
- recorded_log_position = 0;
- }
- }
- android::base::KernelLogger(log_id, severity, tag, file, line, message);
- };
- android::base::InitLogging(argv, second_stage_logger, InitAborter);
-}
-
-void DumpShutdownDebugInformation() {
- auto lock = std::lock_guard{recorded_logs_lock};
- android::base::KernelLogger(
- android::base::MAIN, android::base::ERROR, "init", nullptr, 0,
- "===================== Dumping previous init lines =====================");
- for (size_t i = recorded_log_position; i < kRecordedLogsSize; ++i) {
- android::base::KernelLogger(android::base::MAIN, android::base::ERROR, "init", nullptr, 0,
- recorded_logs[i].c_str());
- }
- for (size_t i = 0; i < recorded_log_position; ++i) {
- android::base::KernelLogger(android::base::MAIN, android::base::ERROR, "init", nullptr, 0,
- recorded_logs[i].c_str());
- }
- android::base::KernelLogger(android::base::MAIN, android::base::ERROR, "init", nullptr, 0,
- "===================== End of dump =====================");
-}
-
} // namespace init
} // namespace android
diff --git a/init/util.h b/init/util.h
index 8a6aa60..3cdc9f4 100644
--- a/init/util.h
+++ b/init/util.h
@@ -98,8 +98,6 @@
void SetStdioToDevNull(char** argv);
void InitKernelLogging(char** argv);
-void InitSecondStageLogging(char** argv);
-void DumpShutdownDebugInformation();
bool IsRecoveryMode();
} // namespace init
} // namespace android
diff --git a/libcutils/include/cutils/threads.h b/libcutils/include/cutils/threads.h
index bbbba6d..0f7f8a8 100644
--- a/libcutils/include/cutils/threads.h
+++ b/libcutils/include/cutils/threads.h
@@ -18,44 +18,21 @@
#include <sys/types.h>
-#if !defined(_WIN32)
-#include <pthread.h>
-#else
+#if defined(_WIN32)
#include <windows.h>
+#else
+#include <pthread.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
-#if !defined(_WIN32)
-
-typedef struct {
- pthread_mutex_t lock;
- int has_tls;
- pthread_key_t tls;
-} thread_store_t;
-
-#define THREAD_STORE_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0, 0 }
-
-#endif
-
//
// Deprecated: use android::base::GetThreadId instead, which doesn't truncate on Mac/Windows.
//
extern pid_t gettid();
-//
-// Deprecated: use `_Thread_local` in C or `thread_local` in C++.
-//
-#if !defined(_WIN32)
-typedef void (*thread_store_destruct_t)(void* x);
-extern void* thread_store_get(thread_store_t* x)
- __attribute__((__deprecated__("use thread_local instead")));
-extern void thread_store_set(thread_store_t* x, void* y, thread_store_destruct_t z)
- __attribute__((__deprecated__("use thread_local instead")));
-#endif
-
#ifdef __cplusplus
}
#endif
diff --git a/libcutils/threads.cpp b/libcutils/threads.cpp
index eac63b5..8cfee1e 100644
--- a/libcutils/threads.cpp
+++ b/libcutils/threads.cpp
@@ -16,23 +16,18 @@
#include <cutils/threads.h>
-// For gettid.
#if defined(__APPLE__)
-#include "AvailabilityMacros.h" // For MAC_OS_X_VERSION_MAX_ALLOWED
#include <stdint.h>
-#include <stdlib.h>
-#include <sys/syscall.h>
-#include <sys/time.h>
-#include <unistd.h>
-#elif defined(__linux__) && !defined(__ANDROID__)
+#elif defined(__linux__)
#include <syscall.h>
#include <unistd.h>
#elif defined(_WIN32)
#include <windows.h>
#endif
+#if defined(__BIONIC__)
// No definition needed for Android because we'll just pick up bionic's copy.
-#ifndef __ANDROID__
+#else
pid_t gettid() {
#if defined(__APPLE__)
uint64_t tid;
@@ -44,31 +39,4 @@
return GetCurrentThreadId();
#endif
}
-#endif // __ANDROID__
-
-#if !defined(_WIN32)
-void* thread_store_get( thread_store_t* store )
-{
- if (!store->has_tls)
- return NULL;
-
- return pthread_getspecific( store->tls );
-}
-
-extern void thread_store_set( thread_store_t* store,
- void* value,
- thread_store_destruct_t destroy)
-{
- pthread_mutex_lock( &store->lock );
- if (!store->has_tls) {
- if (pthread_key_create( &store->tls, destroy) != 0) {
- pthread_mutex_unlock(&store->lock);
- return;
- }
- store->has_tls = 1;
- }
- pthread_mutex_unlock( &store->lock );
-
- pthread_setspecific( store->tls, value );
-}
#endif
diff --git a/rootdir/init.rc b/rootdir/init.rc
index de608b1..d033afc 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -655,7 +655,7 @@
mkdir /data/apex/backup 0700 root system
mkdir /data/apex/hashtree 0700 root system
mkdir /data/apex/sessions 0700 root system
- mkdir /data/app-staging 0750 system system encryption=DeleteIfNecessary
+ mkdir /data/app-staging 0751 system system encryption=DeleteIfNecessary
start apexd
# Avoid predictable entropy pool. Carry over entropy from previous boot.