Snap for 9397138 from 646bced4437672d566bc2309f82c94e943c568a1 to tm-qpr2-release

Change-Id: Ic1ad9c22722d4bb882204c36758cffa72a584020
diff --git a/platform/linux/platform_pal.cc b/platform/linux/platform_pal.cc
index 0d61afb..c6a2a5d 100644
--- a/platform/linux/platform_pal.cc
+++ b/platform/linux/platform_pal.cc
@@ -16,8 +16,12 @@
 
 #include "chre/platform/shared/platform_pal.h"
 
+#include "chre/util/macros.h"
+
 namespace chre {
 
-void PlatformPal::prePalApiCall() const {}
+void PlatformPal::prePalApiCall(PalType palType) const {
+  UNUSED_VAR(palType);
+}
 
 }  // namespace chre
diff --git a/platform/linux/testing/platform_audio.cc b/platform/linux/testing/platform_audio.cc
index e7add9b..4662a93 100644
--- a/platform/linux/testing/platform_audio.cc
+++ b/platform/linux/testing/platform_audio.cc
@@ -36,14 +36,14 @@
 PlatformAudio::~PlatformAudio() {
   if (mApi != nullptr) {
     LOGD("Platform audio closing");
-    prePalApiCall();
+    prePalApiCall(PalType::AUDIO);
     mApi->close();
     LOGD("Platform audio closed");
   }
 }
 
 void PlatformAudio::init() {
-  prePalApiCall();
+  prePalApiCall(PalType::AUDIO);
   mApi = chrePalAudioGetApi(CHRE_PAL_AUDIO_API_CURRENT_VERSION);
   if (mApi != nullptr) {
     if (!mApi->open(&gChrePalSystemApi, &sCallbacks)) {
@@ -66,7 +66,7 @@
 bool PlatformAudio::requestAudioDataEvent(uint32_t handle, uint32_t numSamples,
                                           Nanoseconds eventDelay) {
   if (mApi != nullptr) {
-    prePalApiCall();
+    prePalApiCall(PalType::AUDIO);
     return mApi->requestAudioDataEvent(handle, numSamples,
                                        eventDelay.toRawNanoseconds());
   }
@@ -76,21 +76,21 @@
 
 void PlatformAudio::cancelAudioDataEventRequest(uint32_t handle) {
   if (mApi != nullptr) {
-    prePalApiCall();
+    prePalApiCall(PalType::AUDIO);
     mApi->cancelAudioDataEvent(handle);
   }
 }
 
 void PlatformAudio::releaseAudioDataEvent(struct chreAudioDataEvent *event) {
   if (mApi != nullptr) {
-    prePalApiCall();
+    prePalApiCall(PalType::AUDIO);
     mApi->releaseAudioDataEvent(event);
   }
 }
 
 size_t PlatformAudio::getSourceCount() {
   if (mApi != nullptr) {
-    prePalApiCall();
+    prePalApiCall(PalType::AUDIO);
     return static_cast<size_t>(mApi->getSourceCount());
   }
 
@@ -100,7 +100,7 @@
 bool PlatformAudio::getAudioSource(uint32_t handle,
                                    chreAudioSource *audioSource) const {
   if (mApi != nullptr) {
-    prePalApiCall();
+    prePalApiCall(PalType::AUDIO);
     return mApi->getAudioSource(handle, audioSource);
   }
 
diff --git a/platform/shared/include/chre/platform/shared/platform_pal.h b/platform/shared/include/chre/platform/shared/platform_pal.h
index 75ca448..2364e1e 100644
--- a/platform/shared/include/chre/platform/shared/platform_pal.h
+++ b/platform/shared/include/chre/platform/shared/platform_pal.h
@@ -17,17 +17,32 @@
 #ifndef CHRE_PLATFORM_SHARED_PLATFORM_PAL_H_
 #define CHRE_PLATFORM_SHARED_PLATFORM_PAL_H_
 
+#include <cinttypes>
+
 namespace chre {
 
 /**
+ * Represents the various types of PALs that can use the PlatformPal class
+ */
+enum class PalType : uint8_t {
+  AUDIO = 1,
+  BLE = 2,
+  GNSS = 3,
+  WIFI = 4,
+  WWAN = 5,
+};
+
+/**
  * Provides an instance of the PlatformPal class that uses the CHRE PAL.
  */
 class PlatformPal {
  protected:
   /**
    * Routine to be performed before any call to a platform PAL API.
+   *
+   * @param palType Indicates the type of PAL about to be accessed.
    */
-  void prePalApiCall() const;
+  void prePalApiCall(PalType palType) const;
 };
 
 }  // namespace chre
diff --git a/platform/shared/platform_ble.cc b/platform/shared/platform_ble.cc
index c7d0ad3..b275489 100644
--- a/platform/shared/platform_ble.cc
+++ b/platform/shared/platform_ble.cc
@@ -34,14 +34,14 @@
 PlatformBle::~PlatformBle() {
   if (mBleApi != nullptr) {
     LOGD("Platform BLE closing");
-    prePalApiCall();
+    prePalApiCall(PalType::BLE);
     mBleApi->close();
     LOGD("Platform BLE closed");
   }
 }
 
 void PlatformBle::init() {
-  prePalApiCall();
+  prePalApiCall(PalType::BLE);
   mBleApi = chrePalBleGetApi(CHRE_PAL_BLE_API_CURRENT_VERSION);
   if (mBleApi != nullptr) {
     if (!mBleApi->open(&gChrePalSystemApi, &sBleCallbacks)) {
@@ -58,7 +58,7 @@
 
 uint32_t PlatformBle::getCapabilities() {
   if (mBleApi != nullptr) {
-    prePalApiCall();
+    prePalApiCall(PalType::BLE);
     return mBleApi->getCapabilities();
   } else {
     return CHRE_BLE_CAPABILITIES_NONE;
@@ -67,7 +67,7 @@
 
 uint32_t PlatformBle::getFilterCapabilities() {
   if (mBleApi != nullptr) {
-    prePalApiCall();
+    prePalApiCall(PalType::BLE);
     return mBleApi->getFilterCapabilities();
   } else {
     return CHRE_BLE_FILTER_CAPABILITIES_NONE;
@@ -77,7 +77,7 @@
 bool PlatformBle::startScanAsync(chreBleScanMode mode, uint32_t reportDelayMs,
                                  const struct chreBleScanFilter *filter) {
   if (mBleApi != nullptr) {
-    prePalApiCall();
+    prePalApiCall(PalType::BLE);
     return mBleApi->startScan(mode, reportDelayMs, filter);
   } else {
     return false;
@@ -86,7 +86,7 @@
 
 bool PlatformBle::stopScanAsync() {
   if (mBleApi != nullptr) {
-    prePalApiCall();
+    prePalApiCall(PalType::BLE);
     return mBleApi->stopScan();
   } else {
     return false;
@@ -95,7 +95,7 @@
 
 void PlatformBle::releaseAdvertisingEvent(
     struct chreBleAdvertisementEvent *event) {
-  prePalApiCall();
+  prePalApiCall(PalType::BLE);
   mBleApi->releaseAdvertisingEvent(event);
 }
 
diff --git a/platform/shared/platform_gnss.cc b/platform/shared/platform_gnss.cc
index 4a82d23..2c712bf 100644
--- a/platform/shared/platform_gnss.cc
+++ b/platform/shared/platform_gnss.cc
@@ -35,14 +35,14 @@
 PlatformGnss::~PlatformGnss() {
   if (mGnssApi != nullptr) {
     LOGD("Platform GNSS closing");
-    prePalApiCall();
+    prePalApiCall(PalType::GNSS);
     mGnssApi->close();
     LOGD("Platform GNSS closed");
   }
 }
 
 void PlatformGnss::init() {
-  prePalApiCall();
+  prePalApiCall(PalType::GNSS);
   mGnssApi = chrePalGnssGetApi(CHRE_PAL_GNSS_API_CURRENT_VERSION);
   if (mGnssApi != nullptr) {
     if (!mGnssApi->open(&gChrePalSystemApi, &sGnssCallbacks)) {
@@ -65,7 +65,7 @@
 
 uint32_t PlatformGnss::getCapabilities() {
   if (mGnssApi != nullptr) {
-    prePalApiCall();
+    prePalApiCall(PalType::GNSS);
     return mGnssApi->getCapabilities();
   } else {
     return CHRE_GNSS_CAPABILITIES_NONE;
@@ -75,7 +75,7 @@
 bool PlatformGnss::controlLocationSession(bool enable, Milliseconds minInterval,
                                           Milliseconds minTimeToNextFix) {
   if (mGnssApi != nullptr) {
-    prePalApiCall();
+    prePalApiCall(PalType::GNSS);
     return mGnssApi->controlLocationSession(
         enable, static_cast<uint32_t>(minInterval.getMilliseconds()),
         static_cast<uint32_t>(minTimeToNextFix.getMilliseconds()));
@@ -86,7 +86,7 @@
 
 void PlatformGnss::releaseLocationEvent(chreGnssLocationEvent *event) {
   if (mGnssApi != nullptr) {
-    prePalApiCall();
+    prePalApiCall(PalType::GNSS);
     mGnssApi->releaseLocationEvent(event);
   }
 }
@@ -116,7 +116,7 @@
 bool PlatformGnss::controlMeasurementSession(bool enable,
                                              Milliseconds minInterval) {
   if (mGnssApi != nullptr) {
-    prePalApiCall();
+    prePalApiCall(PalType::GNSS);
     return mGnssApi->controlMeasurementSession(
         enable, static_cast<uint32_t>(minInterval.getMilliseconds()));
   } else {
@@ -126,7 +126,7 @@
 
 void PlatformGnss::releaseMeasurementDataEvent(chreGnssDataEvent *event) {
   if (mGnssApi != nullptr) {
-    prePalApiCall();
+    prePalApiCall(PalType::GNSS);
     mGnssApi->releaseMeasurementDataEvent(event);
   }
 }
@@ -135,7 +135,7 @@
   bool success = false;
   if (mGnssApi != nullptr &&
       mGnssApi->moduleVersion >= CHRE_PAL_GNSS_API_V1_2) {
-    prePalApiCall();
+    prePalApiCall(PalType::GNSS);
     success = mGnssApi->configurePassiveLocationListener(enable);
   }
   return success;
diff --git a/platform/shared/platform_wifi.cc b/platform/shared/platform_wifi.cc
index f4c33d8..84c9a3c 100644
--- a/platform/shared/platform_wifi.cc
+++ b/platform/shared/platform_wifi.cc
@@ -40,14 +40,14 @@
 PlatformWifi::~PlatformWifi() {
   if (mWifiApi != nullptr) {
     LOGD("Platform WiFi closing");
-    prePalApiCall();
+    prePalApiCall(PalType::WIFI);
     mWifiApi->close();
     LOGD("Platform WiFi closed");
   }
 }
 
 void PlatformWifi::init() {
-  prePalApiCall();
+  prePalApiCall(PalType::WIFI);
   mWifiApi = chrePalWifiGetApi(CHRE_PAL_WIFI_API_CURRENT_VERSION);
   if (mWifiApi != nullptr) {
     if (!mWifiApi->open(&gChrePalSystemApi, &sWifiCallbacks)) {
@@ -70,7 +70,7 @@
 
 uint32_t PlatformWifi::getCapabilities() {
   if (mWifiApi != nullptr) {
-    prePalApiCall();
+    prePalApiCall(PalType::WIFI);
     return mWifiApi->getCapabilities();
   } else {
     return CHRE_WIFI_CAPABILITIES_NONE;
@@ -79,7 +79,7 @@
 
 bool PlatformWifi::configureScanMonitor(bool enable) {
   if (mWifiApi != nullptr) {
-    prePalApiCall();
+    prePalApiCall(PalType::WIFI);
     return mWifiApi->configureScanMonitor(enable);
   } else {
     return false;
@@ -89,7 +89,7 @@
 bool PlatformWifi::requestRanging(const struct chreWifiRangingParams *params) {
   if (mWifiApi != nullptr &&
       mWifiApi->moduleVersion >= CHRE_PAL_WIFI_API_V1_2) {
-    prePalApiCall();
+    prePalApiCall(PalType::WIFI);
     return mWifiApi->requestRanging(params);
   } else {
     return false;
@@ -102,7 +102,7 @@
 #ifdef CHRE_WIFI_NAN_SUPPORT_ENABLED
   if (mWifiApi != nullptr &&
       mWifiApi->moduleVersion >= CHRE_PAL_WIFI_API_V1_6) {
-    prePalApiCall();
+    prePalApiCall(PalType::WIFI);
     success = mWifiApi->requestNanRanging(params);
   }
 #endif
@@ -111,7 +111,7 @@
 
 bool PlatformWifi::requestScan(const struct chreWifiScanParams *params) {
   if (mWifiApi != nullptr) {
-    prePalApiCall();
+    prePalApiCall(PalType::WIFI);
 
     if (mWifiApi->moduleVersion < CHRE_PAL_WIFI_API_V1_5) {
       const struct chreWifiScanParams paramsCompat =
@@ -126,19 +126,19 @@
 }
 
 void PlatformWifi::releaseRangingEvent(struct chreWifiRangingEvent *event) {
-  prePalApiCall();
+  prePalApiCall(PalType::WIFI);
   mWifiApi->releaseRangingEvent(event);
 }
 
 void PlatformWifi::releaseScanEvent(struct chreWifiScanEvent *event) {
-  prePalApiCall();
+  prePalApiCall(PalType::WIFI);
   mWifiApi->releaseScanEvent(event);
 }
 
 void PlatformWifi::releaseNanDiscoveryEvent(
     struct chreWifiNanDiscoveryEvent *event) {
 #ifdef CHRE_WIFI_NAN_SUPPORT_ENABLED
-  prePalApiCall();
+  prePalApiCall(PalType::WIFI);
   mWifiApi->releaseNanDiscoveryEvent(event);
 #else
   UNUSED_VAR(event);
@@ -151,7 +151,7 @@
 #ifdef CHRE_WIFI_NAN_SUPPORT_ENABLED
   if (mWifiApi != nullptr &&
       mWifiApi->moduleVersion >= CHRE_PAL_WIFI_API_V1_6) {
-    prePalApiCall();
+    prePalApiCall(PalType::WIFI);
     success = mWifiApi->nanSubscribe(config);
   }
 #else
@@ -165,7 +165,7 @@
 #ifdef CHRE_WIFI_NAN_SUPPORT_ENABLED
   if (mWifiApi != nullptr &&
       mWifiApi->moduleVersion >= CHRE_PAL_WIFI_API_V1_6) {
-    prePalApiCall();
+    prePalApiCall(PalType::WIFI);
     success = mWifiApi->nanSubscribeCancel(subscriptionId);
   }
 #else
diff --git a/platform/shared/platform_wwan.cc b/platform/shared/platform_wwan.cc
index 6449dea..2e1119a 100644
--- a/platform/shared/platform_wwan.cc
+++ b/platform/shared/platform_wwan.cc
@@ -31,14 +31,14 @@
 PlatformWwan::~PlatformWwan() {
   if (mWwanApi != nullptr) {
     LOGD("Platform WWAN closing");
-    prePalApiCall();
+    prePalApiCall(PalType::WWAN);
     mWwanApi->close();
     LOGD("Platform WWAN closed");
   }
 }
 
 void PlatformWwan::init() {
-  prePalApiCall();
+  prePalApiCall(PalType::WWAN);
   mWwanApi = chrePalWwanGetApi(CHRE_PAL_WWAN_API_CURRENT_VERSION);
   if (mWwanApi != nullptr) {
     if (!mWwanApi->open(&gChrePalSystemApi, &sWwanCallbacks)) {
@@ -61,7 +61,7 @@
 
 uint32_t PlatformWwan::getCapabilities() {
   if (mWwanApi != nullptr) {
-    prePalApiCall();
+    prePalApiCall(PalType::WWAN);
     return mWwanApi->getCapabilities();
   } else {
     return CHRE_WWAN_CAPABILITIES_NONE;
@@ -70,7 +70,7 @@
 
 bool PlatformWwan::requestCellInfo() {
   if (mWwanApi != nullptr) {
-    prePalApiCall();
+    prePalApiCall(PalType::WWAN);
     return mWwanApi->requestCellInfo();
   } else {
     return false;
@@ -79,7 +79,7 @@
 
 void PlatformWwan::releaseCellInfoResult(chreWwanCellInfoResult *result) {
   if (mWwanApi != nullptr) {
-    prePalApiCall();
+    prePalApiCall(PalType::WWAN);
     mWwanApi->releaseCellInfoResult(result);
   }
 }
diff --git a/platform/slpi/platform_pal.cc b/platform/slpi/platform_pal.cc
index 0f9d872..163b7ff 100644
--- a/platform/slpi/platform_pal.cc
+++ b/platform/slpi/platform_pal.cc
@@ -17,10 +17,12 @@
 #include "chre/platform/shared/platform_pal.h"
 
 #include "chre/platform/slpi/power_control_util.h"
+#include "chre/util/macros.h"
 
 namespace chre {
 
-void PlatformPal::prePalApiCall() const {
+void PlatformPal::prePalApiCall(PalType palType) const {
+  UNUSED_VAR(palType);
   slpiForceBigImage();
 }