Use std::optional instead of std::unique_ptr
Since Android R, Parcel provides read/write methods for "@nullable"
values using std::optional.
Bug: 149784838
Test: m
Change-Id: Ide63196c6350df30bf43dca15c9334e2f4b36ed7
diff --git a/include/media/MicrophoneInfo.h b/include/media/MicrophoneInfo.h
index 2287aca..0a24b02 100644
--- a/include/media/MicrophoneInfo.h
+++ b/include/media/MicrophoneInfo.h
@@ -205,11 +205,11 @@
private:
status_t readFloatVector(
const Parcel* parcel, Vector<float> *vectorPtr, size_t defaultLength) {
- std::unique_ptr<std::vector<float>> v;
+ std::optional<std::vector<float>> v;
status_t result = parcel->readFloatVector(&v);
if (result != OK) return result;
vectorPtr->clear();
- if (v.get() != nullptr) {
+ if (v) {
for (const auto& iter : *v) {
vectorPtr->push_back(iter);
}