Snap for 8426163 from 3468f55d442bf980af9c3e675e0edf2efe2cff11 to mainline-tzdata2-release
Change-Id: I70647011247ce55e016b3f63f8679f11090f4823
diff --git a/Android.bp b/Android.bp
index b6a685d..65bcaf1 100644
--- a/Android.bp
+++ b/Android.bp
@@ -17,25 +17,14 @@
// libartpalette-system is the implementation of the platform
// abstraction layer for ART. It is intended to be dynamically loaded by
// ART which now ships as an APEX and not part of the system.
-package {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
cc_library {
name: "libartpalette-system",
- cpp_std: "experimental",
compile_multilib: "both",
- header_libs: [
- "libartpalette-headers",
- "jni_headers",
- ],
+ header_libs: ["libartpalette-headers"],
host_supported: true,
target: {
android: {
- srcs: [
- "palette_android.cc",
- "palette_android_partner.cc",
- ],
+ srcs: ["palette_android.cc"],
header_libs: ["libbase_headers"],
shared_libs: [
"libbase",
@@ -43,9 +32,7 @@
"liblog",
"libprocessgroup",
"libtombstoned_client",
- "libselinux",
],
- static_libs: ["libc++fs"],
},
host: {
header_libs: ["libbase_headers"],
@@ -63,53 +50,4 @@
enabled: false,
},
version_script: "libartpalette.map.txt",
- stubs: {
- versions: [
- "1",
- ],
- symbol_file: "libartpalette.map.txt",
- },
-}
-
-// Definition of the extended SDK offered by the platform for mainline modules.
-// TODO: this is in the palette directory as it's only being used by ART.
-// It used to be in prebuilts/sdk/mainline, but this doesn't work for ART
-// unbundled which also includes the prebuilts/sdk git repository. We need to find
-// a better location for this SDK, see b/162706448.
-sdk {
- name: "platform-mainline-sdk",
- host_supported: true,
- native_shared_libs: [
- "libartpalette-system",
- ],
- target: {
- darwin: {
- enabled: false,
- },
- android: {
- native_shared_libs: [
- "heapprofd_client_api",
- "liblog",
- ],
- native_static_libs: [
- "libperfetto_client_experimental",
- "perfetto_trace_protos",
- ],
- },
- not_windows: {
- native_libs: [
- "liblog",
- ],
- }
- },
-}
-
-module_exports {
- name: "platform-mainline-test-exports",
- host_supported: false,
- native_shared_libs: [
- // Required by the implementation of libartpalette-system,
- // which ART uses in replacement of stubs in its testing environment.
- "libtombstoned_client",
- ],
}
diff --git a/libartpalette.map.txt b/libartpalette.map.txt
index 31526d1..d2c90d5 100644
--- a/libartpalette.map.txt
+++ b/libartpalette.map.txt
@@ -17,24 +17,16 @@
LIBARTPALETTE_1 {
global:
# --- VERSION 01 API ---
- PaletteSchedSetPriority; # apex
- PaletteSchedGetPriority; # apex
- PaletteWriteCrashThreadStacks; # apex
- PaletteTraceEnabled; # apex
- PaletteTraceBegin; # apex
- PaletteTraceEnd; # apex
- PaletteTraceIntegerValue; # apex
- PaletteAshmemCreateRegion; # apex
- PaletteAshmemSetProtRegion; # apex
- PaletteCreateOdrefreshStagingDirectory; # apex
- PaletteShouldReportDex2oatCompilation; #apex
- PaletteNotifyStartDex2oatCompilation; #apex
- PaletteNotifyEndDex2oatCompilation; #apex
- PaletteNotifyDexFileLoaded; #apex
- PaletteNotifyOatFileLoaded; #apex
- PaletteShouldReportJniInvocations; #apex
- PaletteNotifyBeginJniInvocation; #apex
- PaletteNotifyEndJniInvocation; #apex
+ PaletteGetVersion;
+ PaletteSchedSetPriority;
+ PaletteSchedGetPriority;
+ PaletteWriteCrashThreadStacks;
+ PaletteTraceEnabled;
+ PaletteTraceBegin;
+ PaletteTraceEnd;
+ PaletteTraceIntegerValue;
+ PaletteAshmemCreateRegion;
+ PaletteAshmemSetProtRegion;
local:
*;
diff --git a/palette_android.cc b/palette_android.cc
index 42c4960..cb13720 100644
--- a/palette_android.cc
+++ b/palette_android.cc
@@ -23,7 +23,6 @@
#include <sys/time.h>
#include <unistd.h>
-#include <filesystem>
#include <mutex>
#include <android-base/file.h>
@@ -31,14 +30,19 @@
#include <android-base/macros.h>
#include <cutils/ashmem.h>
#include <cutils/trace.h>
+#include <log/event_tag_map.h>
#include <processgroup/processgroup.h>
#include <processgroup/sched_policy.h>
-#include <selinux/selinux.h>
#include <tombstoned/tombstoned.h>
#include <utils/Thread.h>
#include "palette_system.h"
+enum PaletteStatus PaletteGetVersion(int32_t* version) {
+ *version = art::palette::kPaletteVersion;
+ return PaletteStatus::kOkay;
+}
+
// Conversion map for "nice" values.
//
// We use Android thread priority constants to be consistent with the rest
@@ -57,16 +61,16 @@
ANDROID_PRIORITY_URGENT_DISPLAY // 10 (MAX_PRIORITY)
};
-palette_status_t PaletteSchedSetPriority(int32_t tid, int32_t managed_priority) {
+enum PaletteStatus PaletteSchedSetPriority(int32_t tid, int32_t managed_priority) {
if (managed_priority < art::palette::kMinManagedThreadPriority ||
managed_priority > art::palette::kMaxManagedThreadPriority) {
- return PALETTE_STATUS_INVALID_ARGUMENT;
+ return PaletteStatus::kInvalidArgument;
}
int new_nice = kNiceValues[managed_priority - art::palette::kMinManagedThreadPriority];
int curr_nice = getpriority(PRIO_PROCESS, tid);
if (curr_nice == new_nice) {
- return PALETTE_STATUS_OK;
+ return PaletteStatus::kOkay;
}
if (new_nice >= ANDROID_PRIORITY_BACKGROUND) {
@@ -81,17 +85,17 @@
}
if (setpriority(PRIO_PROCESS, tid, new_nice) != 0) {
- return PALETTE_STATUS_CHECK_ERRNO;
+ return PaletteStatus::kCheckErrno;
}
- return PALETTE_STATUS_OK;
+ return PaletteStatus::kOkay;
}
-palette_status_t PaletteSchedGetPriority(int32_t tid, /*out*/ int32_t* managed_priority) {
+enum PaletteStatus PaletteSchedGetPriority(int32_t tid, /*out*/ int32_t* managed_priority) {
errno = 0;
int native_priority = getpriority(PRIO_PROCESS, tid);
if (native_priority == -1 && errno != 0) {
*managed_priority = art::palette::kNormalManagedThreadPriority;
- return PALETTE_STATUS_CHECK_ERRNO;
+ return PaletteStatus::kCheckErrno;
}
for (int p = art::palette::kMinManagedThreadPriority;
@@ -99,14 +103,14 @@
int index = p - art::palette::kMinManagedThreadPriority;
if (native_priority >= kNiceValues[index]) {
*managed_priority = p;
- return PALETTE_STATUS_OK;
+ return PaletteStatus::kOkay;
}
}
*managed_priority = art::palette::kMaxManagedThreadPriority;
- return PALETTE_STATUS_OK;
+ return PaletteStatus::kOkay;
}
-palette_status_t PaletteWriteCrashThreadStacks(/*in*/ const char* stacks, size_t stacks_len) {
+enum PaletteStatus PaletteWriteCrashThreadStacks(/*in*/ const char* stacks, size_t stacks_len) {
android::base::unique_fd tombstone_fd;
android::base::unique_fd output_fd;
@@ -116,71 +120,71 @@
// debug that.
LOG(INFO) << std::string_view(stacks, stacks_len);
// tombstoned_connect() logs failure reason.
- return PALETTE_STATUS_FAILED_CHECK_LOG;
+ return PaletteStatus::kFailedCheckLog;
}
- palette_status_t status = PALETTE_STATUS_OK;
+ PaletteStatus status = PaletteStatus::kOkay;
if (!android::base::WriteFully(output_fd, stacks, stacks_len)) {
PLOG(ERROR) << "Failed to write tombstoned output";
TEMP_FAILURE_RETRY(ftruncate(output_fd, 0));
- status = PALETTE_STATUS_FAILED_CHECK_LOG;
+ status = PaletteStatus::kFailedCheckLog;
}
if (TEMP_FAILURE_RETRY(fdatasync(output_fd)) == -1 && errno != EINVAL) {
// Ignore EINVAL so we don't report failure if we just tried to flush a pipe
// or socket.
- if (status == PALETTE_STATUS_OK) {
+ if (status == PaletteStatus::kOkay) {
PLOG(ERROR) << "Failed to fsync tombstoned output";
- status = PALETTE_STATUS_FAILED_CHECK_LOG;
+ status = PaletteStatus::kFailedCheckLog;
}
TEMP_FAILURE_RETRY(ftruncate(output_fd, 0));
TEMP_FAILURE_RETRY(fdatasync(output_fd));
}
if (close(output_fd.release()) == -1 && errno != EINTR) {
- if (status == PALETTE_STATUS_OK) {
+ if (status == PaletteStatus::kOkay) {
PLOG(ERROR) << "Failed to close tombstoned output";
- status = PALETTE_STATUS_FAILED_CHECK_LOG;
+ status = PaletteStatus::kFailedCheckLog;
}
}
if (!tombstoned_notify_completion(tombstone_fd)) {
// tombstoned_notify_completion() logs failure.
- status = PALETTE_STATUS_FAILED_CHECK_LOG;
+ status = PaletteStatus::kFailedCheckLog;
}
return status;
}
-palette_status_t PaletteTraceEnabled(/*out*/ bool* enabled) {
- *enabled = (ATRACE_ENABLED() != 0) ? true : false;
- return PALETTE_STATUS_OK;
+enum PaletteStatus PaletteTraceEnabled(/*out*/ int32_t* enabled) {
+ *enabled = (ATRACE_ENABLED() != 0) ? 1 : 0;
+ return PaletteStatus::kOkay;
}
-palette_status_t PaletteTraceBegin(const char* name) {
+enum PaletteStatus PaletteTraceBegin(const char* name) {
ATRACE_BEGIN(name);
- return PALETTE_STATUS_OK;
+ return PaletteStatus::kOkay;
}
-palette_status_t PaletteTraceEnd() {
+enum PaletteStatus PaletteTraceEnd() {
ATRACE_END();
- return PALETTE_STATUS_OK;
+ return PaletteStatus::kOkay;
}
-palette_status_t PaletteTraceIntegerValue(const char* name, int32_t value) {
+enum PaletteStatus PaletteTraceIntegerValue(const char* name, int32_t value) {
ATRACE_INT(name, value);
- return PALETTE_STATUS_OK;
+ return PaletteStatus::kOkay;
}
// Flag whether to use legacy ashmem or current (b/139855428)
static std::atomic_bool g_assume_legacy_ashmemd(false);
-palette_status_t PaletteAshmemCreateRegion(const char* name, size_t size, int* fd) {
+enum PaletteStatus PaletteAshmemCreateRegion(const char* name, size_t size, int* fd) {
if (g_assume_legacy_ashmemd.load(std::memory_order_acquire) == false) {
// Current platform behaviour which open ashmem fd in process (b/139855428)
*fd = ashmem_create_region(name, size);
if (*fd >= 0) {
- return PALETTE_STATUS_OK;
+ return PaletteStatus::kOkay;
}
}
@@ -192,7 +196,7 @@
// cannot communicate to binder.
*fd = TEMP_FAILURE_RETRY(open("/dev/ashmem", O_RDWR | O_CLOEXEC));
if (*fd == -1) {
- return PALETTE_STATUS_CHECK_ERRNO;
+ return PaletteStatus::kCheckErrno;
}
if (TEMP_FAILURE_RETRY(ioctl(*fd, ASHMEM_SET_SIZE, size)) < 0) {
@@ -208,52 +212,25 @@
}
g_assume_legacy_ashmemd.store(true, std::memory_order_release);
- return PALETTE_STATUS_OK;
+ return PaletteStatus::kOkay;
error:
// Save errno before closing.
int save_errno = errno;
close(*fd);
errno = save_errno;
- return PALETTE_STATUS_CHECK_ERRNO;
+ return PaletteStatus::kCheckErrno;
}
-palette_status_t PaletteAshmemSetProtRegion(int fd, int prot) {
+enum PaletteStatus PaletteAshmemSetProtRegion(int fd, int prot) {
if (!g_assume_legacy_ashmemd.load(std::memory_order_acquire)) {
if (ashmem_set_prot_region(fd, prot) < 0) {
- return PALETTE_STATUS_CHECK_ERRNO;
+ return PaletteStatus::kCheckErrno;
}
} else if (TEMP_FAILURE_RETRY(ioctl(fd, ASHMEM_SET_PROT_MASK, prot)) < 0) {
// Legacy behavior just required for ART build bots which may be running tests on older
// platform builds.
- return PALETTE_STATUS_CHECK_ERRNO;
+ return PaletteStatus::kCheckErrno;
}
- return PALETTE_STATUS_OK;
-}
-
-palette_status_t PaletteCreateOdrefreshStagingDirectory(const char** staging_dir) {
- static constexpr const char* kStagingDirectory = "/data/misc/apexdata/com.android.art/staging";
-
- std::error_code ec;
- if (std::filesystem::exists(kStagingDirectory, ec)) {
- if (!std::filesystem::remove_all(kStagingDirectory, ec)) {
- LOG(ERROR) << ec.message()
- << "Could not remove existing staging directory: " << kStagingDirectory;
- DCHECK_EQ(ec.value(), errno);
- return PALETTE_STATUS_CHECK_ERRNO;
- }
- }
-
- if (mkdir(kStagingDirectory, S_IRWXU) != 0) {
- PLOG(ERROR) << "Could not set permissions on staging directory: " << kStagingDirectory;
- return PALETTE_STATUS_CHECK_ERRNO;
- }
-
- if (setfilecon(kStagingDirectory, "u:object_r:apex_art_staging_data_file:s0") != 0) {
- PLOG(ERROR) << "Could not set label on staging directory: " << kStagingDirectory;
- return PALETTE_STATUS_CHECK_ERRNO;
- }
-
- *staging_dir = kStagingDirectory;
- return PALETTE_STATUS_OK;
+ return PaletteStatus::kOkay;
}
diff --git a/palette_android_partner.cc b/palette_android_partner.cc
deleted file mode 100644
index f74a5a9..0000000
--- a/palette_android_partner.cc
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "palette/palette.h"
-
-#include <android-base/macros.h>
-#include <stdbool.h>
-
-palette_status_t PaletteShouldReportDex2oatCompilation(bool* value) {
- *value = 0;
- return PALETTE_STATUS_OK;
-}
-
-palette_status_t PaletteNotifyStartDex2oatCompilation(int source_fd ATTRIBUTE_UNUSED,
- int art_fd ATTRIBUTE_UNUSED,
- int oat_fd ATTRIBUTE_UNUSED,
- int vdex_fd ATTRIBUTE_UNUSED) {
- return PALETTE_STATUS_OK;
-}
-
-palette_status_t PaletteNotifyEndDex2oatCompilation(int source_fd ATTRIBUTE_UNUSED,
- int art_fd ATTRIBUTE_UNUSED,
- int oat_fd ATTRIBUTE_UNUSED,
- int vdex_fd ATTRIBUTE_UNUSED) {
- return PALETTE_STATUS_OK;
-}
-
-palette_status_t PaletteNotifyDexFileLoaded(const char* path ATTRIBUTE_UNUSED) {
- return PALETTE_STATUS_OK;
-}
-
-palette_status_t PaletteNotifyOatFileLoaded(const char* path ATTRIBUTE_UNUSED) {
- return PALETTE_STATUS_OK;
-}
-
-palette_status_t PaletteShouldReportJniInvocations(bool* value) {
- *value = 0;
- return PALETTE_STATUS_OK;
-}
-
-palette_status_t PaletteNotifyBeginJniInvocation(JNIEnv* env ATTRIBUTE_UNUSED) {
- return PALETTE_STATUS_OK;
-}
-
-palette_status_t PaletteNotifyEndJniInvocation(JNIEnv* env ATTRIBUTE_UNUSED) {
- return PALETTE_STATUS_OK;
-}
diff --git a/palette_fake.cc b/palette_fake.cc
index 5d6e4e5..17e3d00 100644
--- a/palette_fake.cc
+++ b/palette_fake.cc
@@ -18,111 +18,70 @@
#include <map>
#include <mutex>
-#include <stdbool.h>
#include <android-base/logging.h>
#include <android-base/macros.h> // For ATTRIBUTE_UNUSED
#include "palette_system.h"
+enum PaletteStatus PaletteGetVersion(int32_t* version) {
+ *version = art::palette::kPaletteVersion;
+ return PaletteStatus::kOkay;
+}
+
// Cached thread priority for testing. No thread priorities are ever affected.
static std::mutex g_tid_priority_map_mutex;
static std::map<int32_t, int32_t> g_tid_priority_map;
-palette_status_t PaletteSchedSetPriority(int32_t tid, int32_t priority) {
+enum PaletteStatus PaletteSchedSetPriority(int32_t tid, int32_t priority) {
if (priority < art::palette::kMinManagedThreadPriority ||
priority > art::palette::kMaxManagedThreadPriority) {
- return PALETTE_STATUS_INVALID_ARGUMENT;
+ return PaletteStatus::kInvalidArgument;
}
std::lock_guard guard(g_tid_priority_map_mutex);
g_tid_priority_map[tid] = priority;
- return PALETTE_STATUS_OK;
+ return PaletteStatus::kOkay;
}
-palette_status_t PaletteSchedGetPriority(int32_t tid,
+enum PaletteStatus PaletteSchedGetPriority(int32_t tid,
/*out*/ int32_t* priority) {
std::lock_guard guard(g_tid_priority_map_mutex);
if (g_tid_priority_map.find(tid) == g_tid_priority_map.end()) {
g_tid_priority_map[tid] = art::palette::kNormalManagedThreadPriority;
}
*priority = g_tid_priority_map[tid];
- return PALETTE_STATUS_OK;
+ return PaletteStatus::kOkay;
}
-palette_status_t PaletteWriteCrashThreadStacks(/*in*/ const char* stacks, size_t stacks_len) {
+enum PaletteStatus PaletteWriteCrashThreadStacks(/*in*/ const char* stacks, size_t stacks_len) {
LOG(INFO) << std::string_view(stacks, stacks_len);
- return PALETTE_STATUS_OK;
+ return PaletteStatus::kOkay;
}
-palette_status_t PaletteTraceEnabled(/*out*/ bool* enabled) {
- *enabled = false;
- return PALETTE_STATUS_OK;
+enum PaletteStatus PaletteTraceEnabled(/*out*/ int32_t* enabled) {
+ *enabled = 0;
+ return PaletteStatus::kOkay;
}
-palette_status_t PaletteTraceBegin(const char* name ATTRIBUTE_UNUSED) {
- return PALETTE_STATUS_OK;
+enum PaletteStatus PaletteTraceBegin(const char* name ATTRIBUTE_UNUSED) {
+ return PaletteStatus::kOkay;
}
-palette_status_t PaletteTraceEnd() {
- return PALETTE_STATUS_OK;
+enum PaletteStatus PaletteTraceEnd() {
+ return PaletteStatus::kOkay;
}
-palette_status_t PaletteTraceIntegerValue(const char* name ATTRIBUTE_UNUSED,
- int32_t value ATTRIBUTE_UNUSED) {
- return PALETTE_STATUS_OK;
+enum PaletteStatus PaletteTraceIntegerValue(const char* name ATTRIBUTE_UNUSED,
+ int32_t value ATTRIBUTE_UNUSED) {
+ return PaletteStatus::kOkay;
}
-palette_status_t PaletteAshmemCreateRegion(const char* name ATTRIBUTE_UNUSED,
- size_t size ATTRIBUTE_UNUSED, int* fd) {
+enum PaletteStatus PaletteAshmemCreateRegion(const char* name ATTRIBUTE_UNUSED,
+ size_t size ATTRIBUTE_UNUSED, int* fd) {
*fd = -1;
- return PALETTE_STATUS_NOT_SUPPORTED;
+ return PaletteStatus::kNotSupported;
}
-palette_status_t PaletteAshmemSetProtRegion(int fd ATTRIBUTE_UNUSED, int prot ATTRIBUTE_UNUSED) {
- return PALETTE_STATUS_NOT_SUPPORTED;
-}
-
-palette_status_t PaletteCreateOdrefreshStagingDirectory(const char** staging_dir) {
- *staging_dir = nullptr;
- return PALETTE_STATUS_NOT_SUPPORTED;
-}
-
-palette_status_t PaletteShouldReportDex2oatCompilation(bool* value) {
- *value = false;
- return PALETTE_STATUS_OK;
-}
-
-palette_status_t PaletteNotifyStartDex2oatCompilation(int source_fd ATTRIBUTE_UNUSED,
- int art_fd ATTRIBUTE_UNUSED,
- int oat_fd ATTRIBUTE_UNUSED,
- int vdex_fd ATTRIBUTE_UNUSED) {
- return PALETTE_STATUS_OK;
-}
-
-palette_status_t PaletteNotifyEndDex2oatCompilation(int source_fd ATTRIBUTE_UNUSED,
- int art_fd ATTRIBUTE_UNUSED,
- int oat_fd ATTRIBUTE_UNUSED,
- int vdex_fd ATTRIBUTE_UNUSED) {
- return PALETTE_STATUS_OK;
-}
-
-palette_status_t PaletteNotifyDexFileLoaded(const char* path ATTRIBUTE_UNUSED) {
- return PALETTE_STATUS_OK;
-}
-
-palette_status_t PaletteNotifyOatFileLoaded(const char* path ATTRIBUTE_UNUSED) {
- return PALETTE_STATUS_OK;
-}
-
-palette_status_t PaletteShouldReportJniInvocations(bool* value) {
- *value = false;
- return PALETTE_STATUS_OK;
-}
-
-palette_status_t PaletteNotifyBeginJniInvocation(JNIEnv* env ATTRIBUTE_UNUSED) {
- return PALETTE_STATUS_OK;
-}
-
-palette_status_t PaletteNotifyEndJniInvocation(JNIEnv* env ATTRIBUTE_UNUSED) {
- return PALETTE_STATUS_OK;
+enum PaletteStatus PaletteAshmemSetProtRegion(int fd ATTRIBUTE_UNUSED, int prot ATTRIBUTE_UNUSED) {
+ return PaletteStatus::kNotSupported;
}
diff --git a/palette_system.h b/palette_system.h
index ab88139..e238113 100644
--- a/palette_system.h
+++ b/palette_system.h
@@ -22,6 +22,8 @@
namespace art {
namespace palette {
+static constexpr int32_t kPaletteVersion = 1;
+
// Managed thread definitions
static constexpr int32_t kNormalManagedThreadPriority = 5;
static constexpr int32_t kMinManagedThreadPriority = 1;