Cast HIDL uint16_t to char16_t in AIDL cpp backend service
Note that 16 bit int in AIDL interface is char type, while the
corresponding type in cpp/ndk backend is chat16_t type.
See https://source.android.com/devices/architecture/aidl/aidl-backends#types
This CL changes all the casting from uint16_t to char16_t instead of
char to keep the right size of the data.
Test: make
Bug: 185627837
Change-Id: Ic41c7d15df62adb4f78216580fcd9af2c806d891
diff --git a/services/tuner/TunerFilter.cpp b/services/tuner/TunerFilter.cpp
index d3d138d..ca280f2 100644
--- a/services/tuner/TunerFilter.cpp
+++ b/services/tuner/TunerFilter.cpp
@@ -732,10 +732,10 @@
DemuxFilterSectionEvent sectionEvent = e.section();
TunerFilterSectionEvent tunerSection;
- tunerSection.tableId = static_cast<char>(sectionEvent.tableId);
- tunerSection.version = static_cast<char>(sectionEvent.version);
- tunerSection.sectionNum = static_cast<char>(sectionEvent.sectionNum);
- tunerSection.dataLength = static_cast<char>(sectionEvent.dataLength);
+ tunerSection.tableId = static_cast<char16_t>(sectionEvent.tableId);
+ tunerSection.version = static_cast<char16_t>(sectionEvent.version);
+ tunerSection.sectionNum = static_cast<char16_t>(sectionEvent.sectionNum);
+ tunerSection.dataLength = static_cast<char16_t>(sectionEvent.dataLength);
TunerFilterEvent tunerEvent;
tunerEvent.set<TunerFilterEvent::section>(move(tunerSection));
@@ -749,7 +749,7 @@
DemuxFilterPesEvent pesEvent = e.pes();
TunerFilterPesEvent tunerPes;
- tunerPes.streamId = static_cast<char>(pesEvent.streamId);
+ tunerPes.streamId = static_cast<char16_t>(pesEvent.streamId);
tunerPes.dataLength = static_cast<int>(pesEvent.dataLength);
tunerPes.mpuSequenceNumber = static_cast<int>(pesEvent.mpuSequenceNumber);
@@ -777,9 +777,9 @@
}
if (tsRecordEvent.pid.getDiscriminator() == DemuxPid::hidl_discriminator::tPid) {
- tunerTsRecord.pid = static_cast<char>(tsRecordEvent.pid.tPid());
+ tunerTsRecord.pid = static_cast<char16_t>(tsRecordEvent.pid.tPid());
} else {
- tunerTsRecord.pid = static_cast<char>(Constant::INVALID_TS_PID);
+ tunerTsRecord.pid = static_cast<char16_t>(Constant::INVALID_TS_PID);
}
tunerTsRecord.scIndexMask = scIndexMask;
@@ -839,7 +839,7 @@
tunerDownload.itemFragmentIndex = static_cast<int>(downloadEvent.itemFragmentIndex);
tunerDownload.mpuSequenceNumber = static_cast<int>(downloadEvent.mpuSequenceNumber);
tunerDownload.lastItemFragmentIndex = static_cast<int>(downloadEvent.lastItemFragmentIndex);
- tunerDownload.dataLength = static_cast<char>(downloadEvent.dataLength);
+ tunerDownload.dataLength = static_cast<char16_t>(downloadEvent.dataLength);
TunerFilterEvent tunerEvent;
tunerEvent.set<TunerFilterEvent::download>(move(tunerDownload));
@@ -853,7 +853,7 @@
DemuxFilterIpPayloadEvent ipPayloadEvent = e.ipPayload();
TunerFilterIpPayloadEvent tunerIpPayload;
- tunerIpPayload.dataLength = static_cast<char>(ipPayloadEvent.dataLength);
+ tunerIpPayload.dataLength = static_cast<char16_t>(ipPayloadEvent.dataLength);
TunerFilterEvent tunerEvent;
tunerEvent.set<TunerFilterEvent::ipPayload>(move(tunerIpPayload));