Create an empty hooks data structure in palette.
To enable reporting ART information to the platform.
Bug: 162715919
Test: m
Change-Id: I799ddea1bf07df486204a24ec69a76c470e787db
diff --git a/libartpalette/apex/palette.cc b/libartpalette/apex/palette.cc
index e0697c6..bc447bf 100644
--- a/libartpalette/apex/palette.cc
+++ b/libartpalette/apex/palette.cc
@@ -163,4 +163,10 @@
return m(fd, prot);
}
+enum PaletteStatus PaletteGetHooks(PaletteHooks** hooks) {
+ PaletteGetHooksMethod m =
+ PaletteLoader::Instance().GetPaletteGetHooksMethod();
+ return m(hooks);
+}
+
} // extern "C"
diff --git a/libartpalette/apex/palette_test.cc b/libartpalette/apex/palette_test.cc
index 8bbe0ee..3946b18 100644
--- a/libartpalette/apex/palette_test.cc
+++ b/libartpalette/apex/palette_test.cc
@@ -62,3 +62,9 @@
EXPECT_EQ(PaletteStatus::kOkay, PaletteTraceEnd());
EXPECT_EQ(PaletteStatus::kOkay, PaletteTraceIntegerValue("Beans", /*value=*/ 3));
}
+
+TEST_F(PaletteClientTest, GetHooks) {
+ PaletteHooks* hooks = nullptr;
+ PaletteStatus status = PaletteGetHooks(&hooks);
+ ASSERT_TRUE(status == PaletteStatus::kOkay || status == PaletteStatus::kNotSupported);
+}
diff --git a/libartpalette/include/palette/palette.h b/libartpalette/include/palette/palette.h
index 1f58403..8548407 100644
--- a/libartpalette/include/palette/palette.h
+++ b/libartpalette/include/palette/palette.h
@@ -17,6 +17,7 @@
#ifndef ART_LIBARTPALETTE_INCLUDE_PALETTE_PALETTE_H_
#define ART_LIBARTPALETTE_INCLUDE_PALETTE_PALETTE_H_
+#include "palette_hooks.h"
#include "palette_types.h"
#ifdef __cplusplus
diff --git a/libartpalette/include/palette/palette_hooks.h b/libartpalette/include/palette/palette_hooks.h
new file mode 100644
index 0000000..2f5e3bd
--- /dev/null
+++ b/libartpalette/include/palette/palette_hooks.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#ifndef ART_LIBARTPALETTE_INCLUDE_PALETTE_PALETTE_HOOKS_H_
+#define ART_LIBARTPALETTE_INCLUDE_PALETTE_PALETTE_HOOKS_H_
+
+#include "palette_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
+
+// Functions provided by the Palette Hooks object, called by ART.
+typedef struct paletteHooksInterface_ {
+ // TODO: add functions. Currently only one field to ensure the struct has a
+ // size.
+ void* empty;
+} paletteHooksInterface;
+
+struct PaletteHooks {
+ const struct paletteHooksInterface_* functions;
+#ifdef __cplusplus
+ // TODO: Add member functions.
+#endif
+};
+
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
+#endif // ART_LIBARTPALETTE_INCLUDE_PALETTE_PALETTE_HOOKS_H_
diff --git a/libartpalette/include/palette/palette_method_list.h b/libartpalette/include/palette/palette_method_list.h
index 1140399..559e3f4 100644
--- a/libartpalette/include/palette/palette_method_list.h
+++ b/libartpalette/include/palette/palette_method_list.h
@@ -31,6 +31,7 @@
M(PaletteTraceEnd) \
M(PaletteTraceIntegerValue, const char* name, int32_t value) \
M(PaletteAshmemCreateRegion, const char* name, size_t size, int* fd) \
- M(PaletteAshmemSetProtRegion, int, int)
+ M(PaletteAshmemSetProtRegion, int, int) \
+ M(PaletteGetHooks, /*out*/PaletteHooks**)
#endif // ART_LIBARTPALETTE_INCLUDE_PALETTE_PALETTE_METHOD_LIST_H_
diff --git a/libartpalette/libartpalette.map.txt b/libartpalette/libartpalette.map.txt
index d2c90d5..c5564f0 100644
--- a/libartpalette/libartpalette.map.txt
+++ b/libartpalette/libartpalette.map.txt
@@ -27,6 +27,7 @@
PaletteTraceIntegerValue;
PaletteAshmemCreateRegion;
PaletteAshmemSetProtRegion;
+ PaletteGetHooks;
local:
*;
diff --git a/libartpalette/system/palette_fake.cc b/libartpalette/system/palette_fake.cc
index dc0ee76..6fff433 100644
--- a/libartpalette/system/palette_fake.cc
+++ b/libartpalette/system/palette_fake.cc
@@ -87,3 +87,8 @@
int prot ATTRIBUTE_UNUSED) {
return PaletteStatus::kNotSupported;
}
+
+enum PaletteStatus PaletteGetHooks(PaletteHooks** hooks) {
+ *hooks = nullptr;
+ return PaletteStatus::kNotSupported;
+}