libartpalette: add PaletteCreateOdrefreshStagingDirectory

Add libartpalette method for creating the staging directory for
odrefresh and setting the appropriate SELinux labels.

Bug: 160683548
Test: m
Change-Id: I7838188089b815df7df19391dcc9dcd2777c38ce
diff --git a/libartpalette/apex/palette.cc b/libartpalette/apex/palette.cc
index 9f3bb89..9b6c49a 100644
--- a/libartpalette/apex/palette.cc
+++ b/libartpalette/apex/palette.cc
@@ -169,4 +169,10 @@
   return m(hooks);
 }
 
+palette_status_t PaletteCreateOdrefreshStagingDirectory(const char** staging_dir) {
+  PaletteCreateOdrefreshStagingDirectoryMethod m =
+      PaletteLoader::Instance().GetPaletteCreateOdrefreshStagingDirectoryMethod();
+  return m(staging_dir);
+}
+
 }  // extern "C"
diff --git a/libartpalette/include/palette/palette_method_list.h b/libartpalette/include/palette/palette_method_list.h
index 559e3f4..904062e 100644
--- a/libartpalette/include/palette/palette_method_list.h
+++ b/libartpalette/include/palette/palette_method_list.h
@@ -32,6 +32,11 @@
   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**)
+  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)
 
 #endif  // ART_LIBARTPALETTE_INCLUDE_PALETTE_PALETTE_METHOD_LIST_H_
diff --git a/libartpalette/libartpalette.map.txt b/libartpalette/libartpalette.map.txt
index 91d025c..d7e64a7 100644
--- a/libartpalette/libartpalette.map.txt
+++ b/libartpalette/libartpalette.map.txt
@@ -28,6 +28,7 @@
     PaletteAshmemCreateRegion; # apex
     PaletteAshmemSetProtRegion; # apex
     PaletteGetHooks; # apex
+    PaletteCreateOdrefreshStagingDirectory; # apex
 
   local:
     *;
diff --git a/libartpalette/system/palette_fake.cc b/libartpalette/system/palette_fake.cc
index 966632f..4cb6c15 100644
--- a/libartpalette/system/palette_fake.cc
+++ b/libartpalette/system/palette_fake.cc
@@ -92,3 +92,8 @@
   *hooks = nullptr;
   return PALETTE_STATUS_NOT_SUPPORTED;
 }
+
+palette_status_t PaletteCreateOdrefreshStagingDirectory(const char** staging_dir) {
+  *staging_dir = nullptr;
+  return PALETTE_STATUS_NOT_SUPPORTED;
+}