Use the new radio_metadata wrapper for safer memory management.
Bug: b/34054813
Test: VTS, manual - both done in internal branch
Change-Id: I3ffb246af9a092d19a4f698d89ed0c03daa04431
diff --git a/radio/IRadio.cpp b/radio/IRadio.cpp
index 0881a91..e6dbdc3 100644
--- a/radio/IRadio.cpp
+++ b/radio/IRadio.cpp
@@ -16,6 +16,7 @@
*/
#define LOG_TAG "IRadio"
+//#define LOG_NDEBUG 0
#include <utils/Log.h>
#include <utils/Errors.h>
#include <binder/IMemory.h>
@@ -23,7 +24,7 @@
#include <radio/IRadioService.h>
#include <radio/IRadioClient.h>
#include <system/radio.h>
-#include <system/radio_metadata.h>
+#include <system/RadioMetadataWrapper.h>
namespace android {
@@ -303,12 +304,9 @@
case GET_PROGRAM_INFORMATION: {
CHECK_INTERFACE(IRadio, data, reply);
struct radio_program_info info;
+ RadioMetadataWrapper metadataWrapper(&info.metadata);
- status_t status = radio_metadata_allocate(&info.metadata, 0, 0);
- if (status != NO_ERROR) {
- return status;
- }
- status = getProgramInformation(&info);
+ status_t status = getProgramInformation(&info);
reply->writeInt32(status);
if (status == NO_ERROR) {
reply->write(&info, sizeof(struct radio_program_info));
@@ -321,7 +319,6 @@
reply->writeInt32(0);
}
}
- radio_metadata_deallocate(info.metadata);
return NO_ERROR;
}
case HAS_CONTROL: {