aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--platform/linux/platform_pal.cc6
-rw-r--r--platform/linux/testing/platform_audio.cc14
-rw-r--r--platform/shared/include/chre/platform/shared/platform_pal.h17
-rw-r--r--platform/shared/platform_ble.cc14
-rw-r--r--platform/shared/platform_gnss.cc16
-rw-r--r--platform/shared/platform_wifi.cc24
-rw-r--r--platform/shared/platform_wwan.cc10
-rw-r--r--platform/slpi/platform_pal.cc4
8 files changed, 63 insertions, 42 deletions
diff --git a/platform/linux/platform_pal.cc b/platform/linux/platform_pal.cc
index 0d61afb3..c6a2a5d2 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 e7add9b6..4662a93c 100644
--- a/platform/linux/testing/platform_audio.cc
+++ b/platform/linux/testing/platform_audio.cc
@@ -36,14 +36,14 @@ PlatformAudio::PlatformAudio() {}
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 @@ void PlatformAudio::setHandleEnabled(uint32_t handle, bool enabled) {
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 @@ bool PlatformAudio::requestAudioDataEvent(uint32_t handle, uint32_t numSamples,
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 @@ size_t PlatformAudio::getSourceCount() {
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 75ca448d..2364e1eb 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 c7d0ad37..b2754898 100644
--- a/platform/shared/platform_ble.cc
+++ b/platform/shared/platform_ble.cc
@@ -34,14 +34,14 @@ const chrePalBleCallbacks PlatformBleBase::sBleCallbacks = {
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 @@ void PlatformBle::init() {
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::getCapabilities() {
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 @@ uint32_t PlatformBle::getFilterCapabilities() {
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::startScanAsync(chreBleScanMode mode, uint32_t reportDelayMs,
bool PlatformBle::stopScanAsync() {
if (mBleApi != nullptr) {
- prePalApiCall();
+ prePalApiCall(PalType::BLE);
return mBleApi->stopScan();
} else {
return false;
@@ -95,7 +95,7 @@ bool PlatformBle::stopScanAsync() {
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 4a82d238..2c712bf0 100644
--- a/platform/shared/platform_gnss.cc
+++ b/platform/shared/platform_gnss.cc
@@ -35,14 +35,14 @@ const chrePalGnssCallbacks PlatformGnssBase::sGnssCallbacks = {
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 @@ void PlatformGnss::init() {
uint32_t PlatformGnss::getCapabilities() {
if (mGnssApi != nullptr) {
- prePalApiCall();
+ prePalApiCall(PalType::GNSS);
return mGnssApi->getCapabilities();
} else {
return CHRE_GNSS_CAPABILITIES_NONE;
@@ -75,7 +75,7 @@ uint32_t PlatformGnss::getCapabilities() {
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 @@ bool PlatformGnss::controlLocationSession(bool enable, Milliseconds minInterval,
void PlatformGnss::releaseLocationEvent(chreGnssLocationEvent *event) {
if (mGnssApi != nullptr) {
- prePalApiCall();
+ prePalApiCall(PalType::GNSS);
mGnssApi->releaseLocationEvent(event);
}
}
@@ -116,7 +116,7 @@ void PlatformGnssBase::locationEventCallback(
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 @@ bool PlatformGnss::controlMeasurementSession(bool enable,
void PlatformGnss::releaseMeasurementDataEvent(chreGnssDataEvent *event) {
if (mGnssApi != nullptr) {
- prePalApiCall();
+ prePalApiCall(PalType::GNSS);
mGnssApi->releaseMeasurementDataEvent(event);
}
}
@@ -135,7 +135,7 @@ bool PlatformGnss::configurePassiveLocationListener(bool enable) {
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 f4c33d89..84c9a3c5 100644
--- a/platform/shared/platform_wifi.cc
+++ b/platform/shared/platform_wifi.cc
@@ -40,14 +40,14 @@ const chrePalWifiCallbacks PlatformWifiBase::sWifiCallbacks = {
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 @@ void PlatformWifi::init() {
uint32_t PlatformWifi::getCapabilities() {
if (mWifiApi != nullptr) {
- prePalApiCall();
+ prePalApiCall(PalType::WIFI);
return mWifiApi->getCapabilities();
} else {
return CHRE_WIFI_CAPABILITIES_NONE;
@@ -79,7 +79,7 @@ uint32_t PlatformWifi::getCapabilities() {
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::configureScanMonitor(bool enable) {
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 @@ bool PlatformWifi::requestNanRanging(
#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::requestNanRanging(
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 @@ bool PlatformWifi::requestScan(const struct chreWifiScanParams *params) {
}
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 @@ bool PlatformWifi::nanSubscribe(
#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 @@ bool PlatformWifi::nanSubscribeCancel(uint32_t subscriptionId) {
#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 6449dea0..2e1119a0 100644
--- a/platform/shared/platform_wwan.cc
+++ b/platform/shared/platform_wwan.cc
@@ -31,14 +31,14 @@ const chrePalWwanCallbacks PlatformWwanBase::sWwanCallbacks = {
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 @@ void PlatformWwan::init() {
uint32_t PlatformWwan::getCapabilities() {
if (mWwanApi != nullptr) {
- prePalApiCall();
+ prePalApiCall(PalType::WWAN);
return mWwanApi->getCapabilities();
} else {
return CHRE_WWAN_CAPABILITIES_NONE;
@@ -70,7 +70,7 @@ uint32_t PlatformWwan::getCapabilities() {
bool PlatformWwan::requestCellInfo() {
if (mWwanApi != nullptr) {
- prePalApiCall();
+ prePalApiCall(PalType::WWAN);
return mWwanApi->requestCellInfo();
} else {
return false;
@@ -79,7 +79,7 @@ bool PlatformWwan::requestCellInfo() {
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 0f9d8721..163b7ffe 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();
}