Remove palette hooks.

Make the method be part of the official palette API.

Bug: 186016399
Bug: 185778652
Test: m
Change-Id: I3dc9e879c647fd63f5826091813613fd97e25c0d
Merged-In: I3dc9e879c647fd63f5826091813613fd97e25c0d
(cherry picked from commit 0ebaa9865b0d04f1b7b0ef13b5ed7e271b0ab588)
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 75a3e0d..00dd274 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -2420,8 +2420,9 @@
   class ScopedDex2oatReporting {
    public:
     explicit ScopedDex2oatReporting(const Dex2Oat& dex2oat) {
-      PaletteHooks* hooks = nullptr;
-      if (PaletteGetHooks(&hooks) == PALETTE_STATUS_OK) {
+      bool should_report = false;
+      PaletteShouldReportDex2oatCompilation(&should_report);
+      if (should_report) {
         if (dex2oat.zip_fd_ != -1) {
           zip_dup_fd_.reset(DupCloexecOrError(dex2oat.zip_fd_));
           if (zip_dup_fd_ < 0) {
@@ -2443,7 +2444,7 @@
         if (vdex_dup_fd_ < 0) {
           return;
         }
-        hooks->NotifyStartDex2oatCompilation(zip_dup_fd_,
+        PaletteNotifyStartDex2oatCompilation(zip_dup_fd_,
                                              image_dup_fd_,
                                              oat_dup_fd_,
                                              vdex_dup_fd_);
@@ -2452,12 +2453,15 @@
     }
 
     ~ScopedDex2oatReporting() {
-      PaletteHooks* hooks = nullptr;
-      if (!error_reporting_ && (PaletteGetHooks(&hooks) == PALETTE_STATUS_OK)) {
-        hooks->NotifyEndDex2oatCompilation(zip_dup_fd_,
-                                           image_dup_fd_,
-                                           oat_dup_fd_,
-                                           vdex_dup_fd_);
+      if (!error_reporting_) {
+        bool should_report = false;
+        PaletteShouldReportDex2oatCompilation(&should_report);
+        if (should_report) {
+          PaletteNotifyEndDex2oatCompilation(zip_dup_fd_,
+                                             image_dup_fd_,
+                                             oat_dup_fd_,
+                                             vdex_dup_fd_);
+        }
       }
     }
 
diff --git a/libartbase/base/systrace.h b/libartbase/base/systrace.h
index a75f556..42975d7 100644
--- a/libartbase/base/systrace.h
+++ b/libartbase/base/systrace.h
@@ -27,8 +27,8 @@
 namespace art {
 
 inline bool ATraceEnabled() {
-  int enabled = 0;
-  if (UNLIKELY(PaletteTraceEnabled(&enabled) == PALETTE_STATUS_OK && enabled != 0)) {
+  bool enabled = false;
+  if (UNLIKELY(PaletteTraceEnabled(&enabled) == PALETTE_STATUS_OK && enabled)) {
     return true;
   } else {
     return false;
diff --git a/libartpalette/apex/palette.cc b/libartpalette/apex/palette.cc
index 39b1bde..71fd39d 100644
--- a/libartpalette/apex/palette.cc
+++ b/libartpalette/apex/palette.cc
@@ -126,7 +126,7 @@
   return m(stack, stack_len);
 }
 
-palette_status_t PaletteTraceEnabled(/*out*/int32_t* enabled) {
+palette_status_t PaletteTraceEnabled(/*out*/bool* enabled) {
   PaletteTraceEnabledMethod m = PaletteLoader::Instance().GetPaletteTraceEnabledMethod();
   return m(enabled);
 }
@@ -158,16 +158,64 @@
   return m(fd, prot);
 }
 
-palette_status_t PaletteGetHooks(PaletteHooks** hooks) {
-  PaletteGetHooksMethod m =
-      PaletteLoader::Instance().GetPaletteGetHooksMethod();
-  return m(hooks);
-}
-
 palette_status_t PaletteCreateOdrefreshStagingDirectory(const char** staging_dir) {
   PaletteCreateOdrefreshStagingDirectoryMethod m =
       PaletteLoader::Instance().GetPaletteCreateOdrefreshStagingDirectoryMethod();
   return m(staging_dir);
 }
 
+palette_status_t PaletteShouldReportDex2oatCompilation(bool* value) {
+  PaletteShouldReportDex2oatCompilationMethod m =
+      PaletteLoader::Instance().GetPaletteShouldReportDex2oatCompilationMethod();
+  return m(value);
+}
+
+palette_status_t PaletteNotifyStartDex2oatCompilation(int source_fd,
+                                                      int art_fd,
+                                                      int oat_fd,
+                                                      int vdex_fd) {
+  PaletteNotifyStartDex2oatCompilationMethod m =
+      PaletteLoader::Instance().GetPaletteNotifyStartDex2oatCompilationMethod();
+  return m(source_fd, art_fd, oat_fd, vdex_fd);
+}
+
+palette_status_t PaletteNotifyEndDex2oatCompilation(int source_fd,
+                                                    int art_fd,
+                                                    int oat_fd,
+                                                    int vdex_fd) {
+  PaletteNotifyEndDex2oatCompilationMethod m =
+      PaletteLoader::Instance().GetPaletteNotifyEndDex2oatCompilationMethod();
+  return m(source_fd, art_fd, oat_fd, vdex_fd);
+}
+
+palette_status_t PaletteNotifyDexFileLoaded(const char* path) {
+  PaletteNotifyDexFileLoadedMethod m =
+      PaletteLoader::Instance().GetPaletteNotifyDexFileLoadedMethod();
+  return m(path);
+}
+
+palette_status_t PaletteNotifyOatFileLoaded(const char* path) {
+  PaletteNotifyOatFileLoadedMethod m =
+      PaletteLoader::Instance().GetPaletteNotifyOatFileLoadedMethod();
+  return m(path);
+}
+
+palette_status_t PaletteShouldReportJniInvocations(bool* value) {
+  PaletteShouldReportJniInvocationsMethod m =
+      PaletteLoader::Instance().GetPaletteShouldReportJniInvocationsMethod();
+  return m(value);
+}
+
+palette_status_t PaletteNotifyBeginJniInvocation(JNIEnv* env) {
+  PaletteNotifyBeginJniInvocationMethod m =
+      PaletteLoader::Instance().GetPaletteNotifyBeginJniInvocationMethod();
+  return m(env);
+}
+
+palette_status_t PaletteNotifyEndJniInvocation(JNIEnv* env) {
+  PaletteNotifyEndJniInvocationMethod m =
+      PaletteLoader::Instance().GetPaletteNotifyEndJniInvocationMethod();
+  return m(env);
+}
+
 }  // extern "C"
diff --git a/libartpalette/apex/palette_test.cc b/libartpalette/apex/palette_test.cc
index fd17bf9..e6018ee 100644
--- a/libartpalette/apex/palette_test.cc
+++ b/libartpalette/apex/palette_test.cc
@@ -49,15 +49,9 @@
 }
 
 TEST_F(PaletteClientTest, Trace) {
-  int32_t enabled;
+  bool enabled = false;
   EXPECT_EQ(PALETTE_STATUS_OK, PaletteTraceEnabled(&enabled));
   EXPECT_EQ(PALETTE_STATUS_OK, PaletteTraceBegin("Hello world!"));
   EXPECT_EQ(PALETTE_STATUS_OK, PaletteTraceEnd());
   EXPECT_EQ(PALETTE_STATUS_OK, PaletteTraceIntegerValue("Beans", /*value=*/ 3));
 }
-
-TEST_F(PaletteClientTest, GetHooks) {
-  PaletteHooks* hooks = nullptr;
-  palette_status_t status = PaletteGetHooks(&hooks);
-  ASSERT_TRUE(status == PALETTE_STATUS_OK || status == PALETTE_STATUS_NOT_SUPPORTED);
-}
diff --git a/libartpalette/include/palette/palette.h b/libartpalette/include/palette/palette.h
index 6057ace..3e12b14 100644
--- a/libartpalette/include/palette/palette.h
+++ b/libartpalette/include/palette/palette.h
@@ -17,7 +17,6 @@
 #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
deleted file mode 100644
index 40e09fa..0000000
--- a/libartpalette/include/palette/palette_hooks.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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"
-
-#include "jni.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif  // __cplusplus
-
-// Functions provided by the Palette Hooks object, called by ART.
-typedef struct paletteHooksInterface_ {
-  // Notify the Hooks object that dex2oat is starting compilation of the given
-  // `source_fd` dex/apk/zip file, and will generate .art/.oat/.vdex files with
-  // the given file descriptors.
-  void (*NotifyStartDex2oatCompilation)(int source_fd, int art_fd, int oat_fd, int vdex_fd);
-
-  // Notify the Hooks object that dex2oat has ended compilation of the given
-  // `source_fd` dex/apk/zip file, and has written the contents into the given file descriptors.
-  void (*NotifyEndDex2oatCompilation)(int source_fd, int art_fd, int oat_fd, int vdex_fd);
-
-  // Notify the Hooks object that the runtime is loading a dex file.
-  void (*NotifyDexFileLoaded)(const char* path);
-
-  // Notify the Hooks object that the runtime is loading a .oat file.
-  void (*NotifyOatFileLoaded)(const char* path);
-
-  // Whether to report JNI method entry/exit.
-  int (*ShouldReportJniInvocations)();
-
-  // Notify the Hooks object that a native call is starting.
-  void (*NotifyBeginJniInvocation)(JNIEnv* env);
-
-  // Notify the Hooks object that a native call is ending.
-  void (*NotifyEndJniInvocation)(JNIEnv* env);
-} paletteHooksInterface;
-
-struct PaletteHooks {
-  const struct paletteHooksInterface_* functions;
-#ifdef __cplusplus
-  void NotifyStartDex2oatCompilation(int source_fd, int art_fd, int oat_fd, int vdex_fd) {
-    return functions->NotifyStartDex2oatCompilation(source_fd, art_fd, oat_fd, vdex_fd);
-  }
-  void NotifyEndDex2oatCompilation(int source_fd, int art_fd, int oat_fd, int vdex_fd) {
-    return functions->NotifyEndDex2oatCompilation(source_fd, art_fd, oat_fd, vdex_fd);
-  }
-  void NotifyDexFileLoaded(const char* path) {
-    return functions->NotifyDexFileLoaded(path);
-  }
-  void NotifyOatFileLoaded(const char* path) {
-    return functions->NotifyOatFileLoaded(path);
-  }
-  int ShouldReportJniInvocations() {
-    return functions->ShouldReportJniInvocations();
-  }
-  void NotifyBeginJniInvocation(JNIEnv* env) {
-    return functions->NotifyBeginJniInvocation(env);
-  }
-  void NotifyEndJniInvocation(JNIEnv* env) {
-    return functions->NotifyEndJniInvocation(env);
-  }
-#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 4622850..6a7822b 100644
--- a/libartpalette/include/palette/palette_method_list.h
+++ b/libartpalette/include/palette/palette_method_list.h
@@ -17,25 +17,41 @@
 #ifndef ART_LIBARTPALETTE_INCLUDE_PALETTE_PALETTE_METHOD_LIST_H_
 #define ART_LIBARTPALETTE_INCLUDE_PALETTE_PALETTE_METHOD_LIST_H_
 
+#include <stdbool.h>
 #include <stddef.h>
 #include <stdint.h>
 
+#include "jni.h"
+
 // Methods in version 1 API
 #define PALETTE_METHOD_LIST(M)                                              \
   M(PaletteSchedSetPriority, int32_t tid, int32_t java_priority)            \
   M(PaletteSchedGetPriority, int32_t tid, /*out*/int32_t* java_priority)    \
   M(PaletteWriteCrashThreadStacks, const char* stacks, size_t stacks_len)   \
-  M(PaletteTraceEnabled, /*out*/int32_t* enabled)                           \
+  M(PaletteTraceEnabled, /*out*/bool* enabled)                              \
   M(PaletteTraceBegin, const char* name)                                    \
   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(PaletteGetHooks, /*out*/PaletteHooks**)                                 \
   /* Create the staging directory for on-device signing.                 */ \
   /* `staging_dir` is updated to point to a constant string in the       */ \
   /* palette implementation.                                             */ \
   /* This method is not thread-safe.                                     */ \
-  M(PaletteCreateOdrefreshStagingDirectory, /*out*/const char** staging_dir)
+  M(PaletteCreateOdrefreshStagingDirectory, /*out*/const char** staging_dir)\
+  M(PaletteShouldReportDex2oatCompilation, bool*)                           \
+  M(PaletteNotifyStartDex2oatCompilation, int source_fd,                    \
+                                          int art_fd,                       \
+                                          int oat_fd,                       \
+                                          int vdex_fd)                      \
+  M(PaletteNotifyEndDex2oatCompilation, int source_fd,                      \
+                                        int art_fd,                         \
+                                        int oat_fd,                         \
+                                        int vdex_fd)                        \
+  M(PaletteNotifyDexFileLoaded, const char* path)                           \
+  M(PaletteNotifyOatFileLoaded, const char* path)                           \
+  M(PaletteShouldReportJniInvocations, bool*)                               \
+  M(PaletteNotifyBeginJniInvocation, JNIEnv* env)                           \
+  M(PaletteNotifyEndJniInvocation, JNIEnv* env)                             \
 
 #endif  // ART_LIBARTPALETTE_INCLUDE_PALETTE_PALETTE_METHOD_LIST_H_
diff --git a/libartpalette/libartpalette.map.txt b/libartpalette/libartpalette.map.txt
index 9a40bf7..9c846b1 100644
--- a/libartpalette/libartpalette.map.txt
+++ b/libartpalette/libartpalette.map.txt
@@ -26,8 +26,15 @@
     PaletteTraceIntegerValue; # apex
     PaletteAshmemCreateRegion; # apex
     PaletteAshmemSetProtRegion; # apex
-    PaletteGetHooks; # apex
     PaletteCreateOdrefreshStagingDirectory; # apex
+    PaletteShouldReportDex2oatCompilation; #apex
+    PaletteNotifyStartDex2oatCompilation; #apex
+    PaletteNotifyEndDex2oatCompilation; #apex
+    PaletteNotifyDexFileLoaded; #apex
+    PaletteNotifyOatFileLoaded; #apex
+    PaletteShouldReportJniInvocations; #apex
+    PaletteNotifyBeginJniInvocation; #apex
+    PaletteNotifyEndJniInvocation; #apex
 
   local:
     *;
diff --git a/libartpalette/system/palette_fake.cc b/libartpalette/system/palette_fake.cc
index bb307f2..dbbbf89 100644
--- a/libartpalette/system/palette_fake.cc
+++ b/libartpalette/system/palette_fake.cc
@@ -18,6 +18,7 @@
 
 #include <map>
 #include <mutex>
+#include <stdbool.h>
 
 #include <android-base/logging.h>
 #include <android-base/macros.h>  // For ATTRIBUTE_UNUSED
@@ -39,7 +40,7 @@
 }
 
 palette_status_t PaletteSchedGetPriority(int32_t tid,
-                                           /*out*/int32_t* priority) {
+                                         /*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;
@@ -53,8 +54,8 @@
   return PALETTE_STATUS_OK;
 }
 
-palette_status_t PaletteTraceEnabled(/*out*/int32_t* enabled) {
-  *enabled = 0;
+palette_status_t PaletteTraceEnabled(/*out*/bool* enabled) {
+  *enabled = false;
   return PALETTE_STATUS_OK;
 }
 
@@ -67,24 +68,19 @@
 }
 
 palette_status_t PaletteTraceIntegerValue(const char* name ATTRIBUTE_UNUSED,
-                                            int32_t value ATTRIBUTE_UNUSED) {
+                                          int32_t value ATTRIBUTE_UNUSED) {
   return PALETTE_STATUS_OK;
 }
 
 palette_status_t PaletteAshmemCreateRegion(const char* name ATTRIBUTE_UNUSED,
-                                             size_t size ATTRIBUTE_UNUSED,
-                                             int* fd) {
+                                           size_t size ATTRIBUTE_UNUSED,
+                                           int* fd) {
   *fd = -1;
   return PALETTE_STATUS_NOT_SUPPORTED;
 }
 
 palette_status_t PaletteAshmemSetProtRegion(int fd ATTRIBUTE_UNUSED,
-                                              int prot ATTRIBUTE_UNUSED) {
-  return PALETTE_STATUS_NOT_SUPPORTED;
-}
-
-palette_status_t PaletteGetHooks(PaletteHooks** hooks) {
-  *hooks = nullptr;
+                                            int prot ATTRIBUTE_UNUSED) {
   return PALETTE_STATUS_NOT_SUPPORTED;
 }
 
@@ -92,3 +88,43 @@
   *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;
+}
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 2df7d23..5f4f0ab 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -4092,11 +4092,8 @@
     // remembered sets and generational GCs.
     WriteBarrier::ForEveryFieldWrite(h_class_loader.Get());
   }
-  PaletteHooks* hooks = nullptr;
   VLOG(class_linker) << "Registered dex file " << dex_file.GetLocation();
-  if (PaletteGetHooks(&hooks) == PALETTE_STATUS_OK) {
-    hooks->NotifyDexFileLoaded(dex_file.GetLocation().c_str());
-  }
+  PaletteNotifyDexFileLoaded(dex_file.GetLocation().c_str());
   return h_dex_cache.Get();
 }
 
diff --git a/runtime/entrypoints/quick/quick_default_init_entrypoints.h b/runtime/entrypoints/quick/quick_default_init_entrypoints.h
index d74561d..f3fc97e 100644
--- a/runtime/entrypoints/quick/quick_default_init_entrypoints.h
+++ b/runtime/entrypoints/quick/quick_default_init_entrypoints.h
@@ -131,8 +131,9 @@
   qpoints->pUpdateInlineCache = art_quick_update_inline_cache;
   qpoints->pCompileOptimized = art_quick_compile_optimized;
 
-  PaletteHooks* hooks = nullptr;
-  if (PaletteGetHooks(&hooks) == PALETTE_STATUS_OK && hooks->ShouldReportJniInvocations()) {
+  bool should_report = false;
+  PaletteShouldReportJniInvocations(&should_report);
+  if (should_report) {
     qpoints->pJniMethodStart = JniMonitoredMethodStart;
     qpoints->pJniMethodStartSynchronized = JniMonitoredMethodStartSynchronized;
     qpoints->pJniMethodEnd = JniMonitoredMethodEnd;
diff --git a/runtime/entrypoints/quick/quick_jni_entrypoints.cc b/runtime/entrypoints/quick/quick_jni_entrypoints.cc
index 82ec04b..3ac7eca 100644
--- a/runtime/entrypoints/quick/quick_jni_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_jni_entrypoints.cc
@@ -22,18 +22,19 @@
 #include "indirect_reference_table.h"
 #include "mirror/object-inl.h"
 #include "palette/palette.h"
-#include "palette/palette_hooks.h"
 #include "thread-inl.h"
 #include "verify_object.h"
 
 // For methods that monitor JNI invocations and report their begin/end to
 // palette hooks.
-#define MONITOR_JNI(kind)                               \
-  PaletteHooks* hooks = nullptr;                        \
-  if (PaletteGetHooks(&hooks) == PALETTE_STATUS_OK &&   \
-      hooks->ShouldReportJniInvocations()) {            \
-    hooks->kind(self->GetJniEnv());                     \
-  }                                                     \
+#define MONITOR_JNI(kind)                                \
+  {                                                      \
+    bool should_report = false;                          \
+    PaletteShouldReportJniInvocations(&should_report);   \
+    if (should_report) {                                 \
+      kind(self->GetJniEnv());                           \
+    }                                                    \
+  }
 
 namespace art {
 
@@ -235,7 +236,7 @@
   // @CriticalNative does not do a state transition. @FastNative usually does not do a state
   // transition either but it performs a suspend check that may do state transitions.
   if (LIKELY(normal_native)) {
-    MONITOR_JNI(NotifyEndJniInvocation);
+    MONITOR_JNI(PaletteNotifyEndJniInvocation);
     GoToRunnable(self);
   } else if (fast_native) {
     GoToRunnableFast(self);
@@ -291,32 +292,32 @@
 
 extern uint32_t JniMonitoredMethodStart(Thread* self) {
   uint32_t result = JniMethodStart(self);
-  MONITOR_JNI(NotifyBeginJniInvocation);
+  MONITOR_JNI(PaletteNotifyBeginJniInvocation);
   return result;
 }
 
 extern uint32_t JniMonitoredMethodStartSynchronized(jobject to_lock, Thread* self) {
   uint32_t result = JniMethodStartSynchronized(to_lock, self);
-  MONITOR_JNI(NotifyBeginJniInvocation);
+  MONITOR_JNI(PaletteNotifyBeginJniInvocation);
   return result;
 }
 
 extern void JniMonitoredMethodEnd(uint32_t saved_local_ref_cookie, Thread* self) {
-  MONITOR_JNI(NotifyEndJniInvocation);
+  MONITOR_JNI(PaletteNotifyEndJniInvocation);
   return JniMethodEnd(saved_local_ref_cookie, self);
 }
 
 extern void JniMonitoredMethodEndSynchronized(uint32_t saved_local_ref_cookie,
                                              jobject locked,
                                              Thread* self) {
-  MONITOR_JNI(NotifyEndJniInvocation);
+  MONITOR_JNI(PaletteNotifyEndJniInvocation);
   return JniMethodEndSynchronized(saved_local_ref_cookie, locked, self);
 }
 
 extern mirror::Object* JniMonitoredMethodEndWithReference(jobject result,
                                                           uint32_t saved_local_ref_cookie,
                                                           Thread* self) {
-  MONITOR_JNI(NotifyEndJniInvocation);
+  MONITOR_JNI(PaletteNotifyEndJniInvocation);
   return JniMethodEndWithReference(result, saved_local_ref_cookie, self);
 }
 
@@ -325,7 +326,7 @@
     uint32_t saved_local_ref_cookie,
     jobject locked,
     Thread* self) {
-  MONITOR_JNI(NotifyEndJniInvocation);
+  MONITOR_JNI(PaletteNotifyEndJniInvocation);
   return JniMethodEndWithReferenceSynchronized(result, saved_local_ref_cookie, locked, self);
 }
 
diff --git a/runtime/oat_file_manager.cc b/runtime/oat_file_manager.cc
index 22044f4..92929b3 100644
--- a/runtime/oat_file_manager.cc
+++ b/runtime/oat_file_manager.cc
@@ -68,10 +68,7 @@
 const OatFile* OatFileManager::RegisterOatFile(std::unique_ptr<const OatFile> oat_file) {
   // Use class_linker vlog to match the log for dex file registration.
   VLOG(class_linker) << "Registered oat file " << oat_file->GetLocation();
-  PaletteHooks* hooks = nullptr;
-  if (PaletteGetHooks(&hooks) == PALETTE_STATUS_OK) {
-    hooks->NotifyOatFileLoaded(oat_file->GetLocation().c_str());
-  }
+  PaletteNotifyOatFileLoaded(oat_file->GetLocation().c_str());
 
   WriterMutexLock mu(Thread::Current(), *Locks::oat_file_manager_lock_);
   CHECK(!only_use_system_oat_files_ ||