Revert "[platform] Use memoryAllocDram to store app binary tempo..."

Revert submission 33422885

Reason for revert: Verify if this is the root cause of b/419095638. Revert if verified.

Reverted changes: /q/submissionid:33422885

Change-Id: I9d430371d3a8b16ccf157289d7d2106e9b820987
diff --git a/platform/freertos/platform_nanoapp.cc b/platform/freertos/platform_nanoapp.cc
index 8b57c51..6db3852 100644
--- a/platform/freertos/platform_nanoapp.cc
+++ b/platform/freertos/platform_nanoapp.cc
@@ -60,22 +60,6 @@
   return strdup(source, dramAllocator);
 }
 
-// TODO(b/417791623) - This is a temperory solution and should be updated once
-//  we have memoryAlignedAlloc ready for use.
-template <typename T>
-T roundUpToNanoappLoadAlignment(T size) {
-  if (CHRE_NANOAPP_LOAD_ALIGNMENT == 0 || CHRE_NANOAPP_LOAD_ALIGNMENT == 1) {
-    return size;
-  }
-
-  static_assert(
-      (CHRE_NANOAPP_LOAD_ALIGNMENT & (CHRE_NANOAPP_LOAD_ALIGNMENT - 1)) == 0,
-      "CHRE_NANOAPP_LOAD_ALIGNMENT must be a power of 2");
-
-  return (size + CHRE_NANOAPP_LOAD_ALIGNMENT - 1) &
-         ~(CHRE_NANOAPP_LOAD_ALIGNMENT - 1);
-}
-
 void cleanUpAppInfo(const chreNslNanoappInfo *appInfo) {
   if (appInfo == nullptr) {
     return;
@@ -145,7 +129,7 @@
 
   if (mAppBinary != nullptr) {
     forceDramAccess();
-    memoryFreeDram(mAppBinaryAllocatedMemory);
+    nanoappBinaryDramFree(mAppBinary);
   }
 }
 
@@ -302,10 +286,8 @@
   forceDramAccess();
 
   bool success = false;
-  mAppBinaryAllocatedMemory = memoryAllocDram(roundUpToNanoappLoadAlignment(
-      CHRE_NANOAPP_LOAD_ALIGNMENT - 1 + appBinaryLen));
-  mAppBinary = reinterpret_cast<void *>(roundUpToNanoappLoadAlignment(
-      reinterpret_cast<uintptr_t>(mAppBinaryAllocatedMemory)));
+  mAppBinary =
+      nanoappBinaryDramAlloc(appBinaryLen, CHRE_NANOAPP_LOAD_ALIGNMENT);
 
   bool isSigned = IS_BIT_SET(appFlags, CHRE_NAPP_HEADER_SIGNED);
   if (!isSigned) {
@@ -420,9 +402,8 @@
   }
 
   if (mAppBinary != nullptr) {
-    memoryFreeDram(mAppBinaryAllocatedMemory);
+    nanoappBinaryDramFree(mAppBinary);
     mAppBinary = nullptr;
-    mAppBinaryAllocatedMemory = nullptr;
   }
 
   // Save this flag locally since it may be referenced while the system is in
diff --git a/platform/freertos/public_platform_nanoapp/chre/target_platform/platform_nanoapp_base.h b/platform/freertos/public_platform_nanoapp/chre/target_platform/platform_nanoapp_base.h
index 3b37b83..7755654 100644
--- a/platform/freertos/public_platform_nanoapp/chre/target_platform/platform_nanoapp_base.h
+++ b/platform/freertos/public_platform_nanoapp/chre/target_platform/platform_nanoapp_base.h
@@ -117,8 +117,6 @@
   //! Buffer containing the complete DSO binary - only populated if
   //! copyNanoappFragment() was used to load this nanoapp
   void *mAppBinary = nullptr;
-  //! The raw buffer allocated, used to guarantee the alignment requirements
-  void *mAppBinaryAllocatedMemory = nullptr;
   size_t mAppBinaryLen = 0;
 
   //! Null-terminated ASCII string containing the file name that contains the