vibrator: common: Check whether file is opened correctly

- Add compile-time type checking inside the has() function to ensure it
  receives the correct type.
- Add is_open() inside the has() function.

Bug: 350911314
Test: alarm, ringtone vibrations
Test: keyboard vibrations
Test: idlcli commands
Test: atest PTS, CTS, VTS
Flag: EXEMPT bugfix
Change-Id: Ifa8f197f6f4b25d51b2edaf6fec27a086bd4f73c
This commit is contained in:
leonardian 2024-07-08 17:00:50 +08:00
parent 0dcee74707
commit 1d29f93863
3 changed files with 14 additions and 6 deletions

View file

@ -40,10 +40,6 @@ void HwApiBase::saveName(const std::string &name, const std::ios *stream) {
mNames[stream] = name;
}
bool HwApiBase::has(const std::ios &stream) {
return !!stream;
}
void HwApiBase::debug(int fd) {
dprintf(fd, "Kernel:\n");