diff options
33 files changed, 256 insertions, 269 deletions
diff --git a/board/16k.mk b/board/16k.mk new file mode 100644 index 00000000..c41802ab --- /dev/null +++ b/board/16k.mk @@ -0,0 +1,19 @@ +# +# Copyright (C) 2024 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Enable large page size support +PRODUCT_MAX_PAGE_SIZE_SUPPORTED := 16384 +PRODUCT_NO_BIONIC_PAGE_SIZE_MACRO := true diff --git a/board/emu64a/details.mk b/board/emu64a/details.mk index 9186a367..f85e713a 100644 --- a/board/emu64a/details.mk +++ b/board/emu64a/details.mk @@ -24,3 +24,5 @@ PRODUCT_COPY_FILES += \ device/generic/goldfish/board/fstab/arm:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.ranchu \ $(EMULATOR_KERNEL_FILE):kernel-ranchu \ device/generic/goldfish/data/etc/advancedFeatures.ini:advancedFeatures.ini \ + +$(call inherit-product, device/generic/goldfish/board/16k.mk) diff --git a/board/emu64a16k/details.mk b/board/emu64a16k/details.mk index 0554dba7..a690da9a 100644 --- a/board/emu64a16k/details.mk +++ b/board/emu64a16k/details.mk @@ -25,7 +25,4 @@ PRODUCT_COPY_FILES += \ $(EMULATOR_KERNEL_FILE):kernel-ranchu \ device/generic/goldfish/data/etc/advancedFeatures.ini:advancedFeatures.ini \ - -# Enable large page size support -PRODUCT_MAX_PAGE_SIZE_SUPPORTED := 65536 -PRODUCT_NO_BIONIC_PAGE_SIZE_MACRO := true +$(call inherit-product, device/generic/goldfish/board/16k.mk) diff --git a/board/emu64x/details.mk b/board/emu64x/details.mk index 978cad4d..00718516 100644 --- a/board/emu64x/details.mk +++ b/board/emu64x/details.mk @@ -30,3 +30,5 @@ PRODUCT_COPY_FILES += \ $(EMULATOR_KERNEL_FILE):kernel-ranchu \ device/generic/goldfish/board/fstab/x86:$(TARGET_COPY_OUT_VENDOR_RAMDISK)/first_stage_ramdisk/fstab.ranchu \ device/generic/goldfish/board/fstab/x86:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.ranchu \ + +$(call inherit-product, device/generic/goldfish/board/16k.mk) diff --git a/board/emu64x16k/details.mk b/board/emu64x16k/details.mk index 745ef165..d80838cc 100644 --- a/board/emu64x16k/details.mk +++ b/board/emu64x16k/details.mk @@ -31,6 +31,4 @@ PRODUCT_COPY_FILES += \ device/generic/goldfish/board/fstab/x86:$(TARGET_COPY_OUT_VENDOR_RAMDISK)/first_stage_ramdisk/fstab.ranchu \ device/generic/goldfish/board/fstab/x86:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.ranchu \ -# Enable large page size support -PRODUCT_MAX_PAGE_SIZE_SUPPORTED := 65536 -PRODUCT_NO_BIONIC_PAGE_SIZE_MACRO := true +$(call inherit-product, device/generic/goldfish/board/16k.mk) diff --git a/board/kernel/arm64.mk b/board/kernel/arm64.mk index e785aabb..48697292 100644 --- a/board/kernel/arm64.mk +++ b/board/kernel/arm64.mk @@ -33,9 +33,7 @@ RAMDISK_KERNEL_MODULES := \ virtio_pci_legacy_dev.ko \ virtio_pci_modern_dev.ko \ virtio-rng.ko \ - vmw_vsock_virtio_transport_common.ko \ vmw_vsock_virtio_transport.ko \ - vsock.ko \ BOARD_SYSTEM_KERNEL_MODULES := $(wildcard $(KERNEL_ARTIFACTS_PATH)/*.ko) diff --git a/board/kernel/x86_64.mk b/board/kernel/x86_64.mk index e07f0bab..2622da6e 100644 --- a/board/kernel/x86_64.mk +++ b/board/kernel/x86_64.mk @@ -32,9 +32,7 @@ RAMDISK_KERNEL_MODULES := \ virtio_pci_legacy_dev.ko \ virtio_pci_modern_dev.ko \ virtio-rng.ko \ - vmw_vsock_virtio_transport_common.ko \ vmw_vsock_virtio_transport.ko \ - vsock.ko \ BOARD_SYSTEM_KERNEL_MODULES := $(wildcard $(KERNEL_ARTIFACTS_PATH)/*.ko) diff --git a/data/etc/handheld_core_hardware.xml b/data/etc/handheld_core_hardware.xml index 5c2227fd..3847bfc8 100644 --- a/data/etc/handheld_core_hardware.xml +++ b/data/etc/handheld_core_hardware.xml @@ -56,6 +56,7 @@ <feature name="android.hardware.telephony.calling" /> <feature name="android.hardware.telephony.data" /> <feature name="android.hardware.telephony.gsm" /> + <feature name="android.hardware.telephony.messaging" /> <feature name="android.hardware.telephony.ims" /> <feature name="android.hardware.telephony.radio.access" /> <feature name="android.hardware.telephony.subscription" /> diff --git a/fingerprint/Android.bp b/fingerprint/Android.bp index eace3916..d57b40e5 100644 --- a/fingerprint/Android.bp +++ b/fingerprint/Android.bp @@ -46,6 +46,7 @@ cc_binary { ], header_libs: [ "libutils_headers", + "libdebug.ranchu", ], cflags: [ "-DLOG_TAG=\"fingerprint-service.ranchu\"", diff --git a/fingerprint/main.cpp b/fingerprint/main.cpp index edc90d34..9ff81ea2 100644 --- a/fingerprint/main.cpp +++ b/fingerprint/main.cpp @@ -17,7 +17,7 @@ #include <memory> #include <android/binder_manager.h> #include <android/binder_process.h> -#include <log/log.h> +#include <debug.h> #include <utils/Errors.h> #include "hal.h" @@ -33,8 +33,8 @@ int main() { const std::string instance = std::string(Hal::descriptor) + "/default"; if (AServiceManager_registerLazyService(hal->asBinder().get(), instance.c_str()) != STATUS_OK) { - ALOGE("%s:%d: Could not register '%s'", __func__, __LINE__, instance.c_str()); - return android::NO_INIT; + return FAILURE_V(android::NO_INIT, + "Could not register '%s'", instance.c_str()); } } diff --git a/fingerprint/session.cpp b/fingerprint/session.cpp index bc28be3f..934a4dd1 100644 --- a/fingerprint/session.cpp +++ b/fingerprint/session.cpp @@ -22,6 +22,7 @@ #include <limits> #include <aidl/android/hardware/biometrics/common/BnCancellationSignal.h> #include <android-base/unique_fd.h> +#include <debug.h> #include <log/log.h> #include <qemud.h> #include <utils/Timers.h> @@ -29,6 +30,13 @@ #include "session.h" #include "storage.h" +#define SESSION_DEBUG(FMT, ...) \ + ALOGD("%p:%s:%d: " FMT, this, __func__, __LINE__, __VA_ARGS__) +#define SESSION_ERR(FMT, ...) \ + ALOGE("%p:%s:%d: " FMT, this, __func__, __LINE__, __VA_ARGS__) + +#define SESSION_DEBUG0(STR) SESSION_DEBUG("%s", STR) + namespace aidl::android::hardware::biometrics::fingerprint { using ::android::base::unique_fd; @@ -83,14 +91,25 @@ template <class T> std::string vec2str(const std::vector<T>& v) { } } -const char* state2str(const Session::State s) { +std::string state2str(const Session::State s) { switch (s) { case Session::State::IDLE: return "IDLE"; case Session::State::ENROLLING_START: return "ENROLLING_START"; case Session::State::ENROLLING_END: return "ENROLLING_END"; case Session::State::AUTHENTICATING: return "AUTHENTICATING"; case Session::State::DETECTING_INTERACTION: return "DETECTING_INTERACTION"; - default: return "?"; + default: return std::to_string(static_cast<int>(s)); + } +} + +std::string errorCode2str(const Session::ErrorCode ec) { + switch (ec) { + case Session::ErrorCode::OK: return "OK"; + case Session::ErrorCode::E_HAT_MAC_EMPTY: return "E_HAT_MAC_EMPTY"; + case Session::ErrorCode::E_HAT_WRONG_CHALLENGE: return "E_HAT_WRONG_CHALLENGE"; + case Session::ErrorCode::E_INCORRECT_STATE: return "E_INCORRECT_STATE"; + case Session::ErrorCode::E_ENROLL_FAILED: return "E_ENROLL_FAILED"; + default: return std::to_string(static_cast<int>(ec)); } } @@ -113,20 +132,19 @@ Session::Session(const int32_t sensorId, const int32_t userId, , mStorage(sensorId, userId) , mRandom(generateSeed(this)) { - ALOGD("%p:%s: New session: sensorId=%d userId=%d", - this, __func__, sensorId, userId); + SESSION_DEBUG("New session: sensorId=%d userId=%d", sensorId, userId); if (::android::base::Socketpair(AF_LOCAL, SOCK_STREAM, 0, &mCallerFd, &mSensorThreadFd)) { mSensorListener = std::thread(&Session::sensorListenerFunc, this); } else { mSensorListener = std::thread([](){}); - LOG_ALWAYS_FATAL("%p:%s: Socketpair failed", this, __func__); + LOG_ALWAYS_FATAL("%p:%s:%d: Socketpair failed", this, __func__, __LINE__); } } Session::~Session() { - ALOGD("%p:%s: Terminating session", this, __func__); + SESSION_DEBUG0("Terminating session"); TEMP_FAILURE_RETRY(write(mCallerFd.get(), &kSensorListenerQuitCmd, 1)); mSensorListener.join(); @@ -141,8 +159,7 @@ ndk::ScopedAStatus Session::generateChallenge() { } if (mChallenges.insert(challenge).second) { - ALOGD("%p:%s: onChallengeGenerated(challenge=%" PRId64 ")", - this, __func__, challenge); + SESSION_DEBUG("onChallengeGenerated(challenge=%" PRId64 ")", challenge); mSessionCb->onChallengeGenerated(challenge); return ndk::ScopedAStatus::ok(); } @@ -151,8 +168,7 @@ ndk::ScopedAStatus Session::generateChallenge() { ndk::ScopedAStatus Session::revokeChallenge(const int64_t challenge) { mChallenges.erase(challenge); - ALOGD("%p:%s: onChallengeRevoked(challenge=%" PRId64 ")", - this, __func__, challenge); + SESSION_DEBUG("onChallengeRevoked(challenge=%" PRId64 ")", challenge); mSessionCb->onChallengeRevoked(challenge); return ndk::ScopedAStatus::ok(); } @@ -176,19 +192,17 @@ ndk::ScopedAStatus Session::enroll(const keymaster::HardwareAuthToken& hat, } if (ok) { - ALOGD("%p:%s: ENROLLING_START hat.userId=%" PRId64, - this, __func__, hat.userId); + SESSION_DEBUG("ENROLLING_START hat.userId=%" PRId64, hat.userId); *out = SharedRefBase::make<CancellationSignal>([this](){ cancellEnroll(); }); } else { - ALOGE("%p:%s: onError(UNABLE_TO_PROCESS, %d): incorrect state, %s", - this, __func__, int(ErrorCode::E_INCORRECT_STATE), - state2str(previousState)); + SESSION_ERR("onError(UNABLE_TO_PROCESS, %d): incorrect state, %s", + int(ErrorCode::E_INCORRECT_STATE), state2str(previousState).c_str()); mSessionCb->onError(Error::UNABLE_TO_PROCESS, int(ErrorCode::E_INCORRECT_STATE)); } } else { - ALOGE("%p:%s: onError(UNABLE_TO_PROCESS, %d): `hat` is invalid", - this, __func__, int(err)); + SESSION_ERR("onError(UNABLE_TO_PROCESS, %d): `hat` is invalid: %s", + int(err), errorCode2str(err).c_str()); mSessionCb->onError(Error::UNABLE_TO_PROCESS, int(err)); } @@ -212,12 +226,12 @@ ndk::ScopedAStatus Session::authenticate(const int64_t operationId, } if (ok) { - ALOGD("%p:%s: AUTHENTICATING operationId=%" PRId64, this, __func__, operationId); + SESSION_DEBUG("AUTHENTICATING operationId=%" PRId64, operationId); *out = SharedRefBase::make<CancellationSignal>([this](){ cancellAuthenticate(); }); } else { - ALOGE("%p:%s: onError(UNABLE_TO_PROCESS, %d): incorrect state, %s", - this, __func__, int(ErrorCode::E_INCORRECT_STATE), - state2str(previousState)); + SESSION_ERR("onError(UNABLE_TO_PROCESS, %d): incorrect state, %s", + int(ErrorCode::E_INCORRECT_STATE), + state2str(previousState).c_str()); mSessionCb->onError(Error::UNABLE_TO_PROCESS, int(ErrorCode::E_INCORRECT_STATE)); } @@ -241,12 +255,12 @@ ndk::ScopedAStatus Session::detectInteraction( } if (ok) { - ALOGD("%p:%s DETECTING_INTERACTION", this, __func__); + SESSION_DEBUG0("DETECTING_INTERACTION"); *out = SharedRefBase::make<CancellationSignal>([this](){ cancellDetectInteraction(); }); } else { - ALOGE("%p:%s: onError(UNABLE_TO_PROCESS, %d): incorrect state, %s", - this, __func__, int(ErrorCode::E_INCORRECT_STATE), - state2str(previousState)); + SESSION_ERR("onError(UNABLE_TO_PROCESS, %d): incorrect state, %s", + int(ErrorCode::E_INCORRECT_STATE), + state2str(previousState).c_str()); mSessionCb->onError(Error::UNABLE_TO_PROCESS, int(ErrorCode::E_INCORRECT_STATE)); } @@ -261,8 +275,8 @@ ndk::ScopedAStatus Session::enumerateEnrollments() { enrollmentIds = mStorage.enumerateEnrollments(); } - ALOGD("%p:%s: onEnrollmentsEnumerated(enrollmentIds=%s)", - this, __func__, vec2str(enrollmentIds).c_str()); + SESSION_DEBUG("onEnrollmentsEnumerated(enrollmentIds=%s)", + vec2str(enrollmentIds).c_str()); mSessionCb->onEnrollmentsEnumerated(enrollmentIds); return ndk::ScopedAStatus::ok(); } @@ -273,8 +287,8 @@ ndk::ScopedAStatus Session::removeEnrollments(const std::vector<int32_t>& enroll mStorage.removeEnrollments(enrollmentIds); } - ALOGD("%p:%s: onEnrollmentsRemoved(enrollmentIds=%s)", - this, __func__, vec2str(enrollmentIds).c_str()); + SESSION_DEBUG("onEnrollmentsRemoved(enrollmentIds=%s)", + vec2str(enrollmentIds).c_str()); mSessionCb->onEnrollmentsRemoved(enrollmentIds); return ndk::ScopedAStatus::ok(); } @@ -286,8 +300,7 @@ ndk::ScopedAStatus Session::getAuthenticatorId() { authId = mStorage.getAuthenticatorId(); } - ALOGD("%p:%s: onAuthenticatorIdRetrieved(authId=%" PRId64 ")", - this, __func__, authId); + SESSION_DEBUG("onAuthenticatorIdRetrieved(authId=%" PRId64 ")", authId); mSessionCb->onAuthenticatorIdRetrieved(authId); return ndk::ScopedAStatus::ok(); } @@ -299,8 +312,7 @@ ndk::ScopedAStatus Session::invalidateAuthenticatorId() { authId = mStorage.invalidateAuthenticatorId(generateInt64()); } - ALOGD("%p:%s: onAuthenticatorIdInvalidated(authId=%" PRId64 ")", - this, __func__, authId); + SESSION_DEBUG("onAuthenticatorIdInvalidated(authId=%" PRId64 ")", authId); mSessionCb->onAuthenticatorIdInvalidated(authId); return ndk::ScopedAStatus::ok(); } @@ -313,11 +325,11 @@ ndk::ScopedAStatus Session::resetLockout(const keymaster::HardwareAuthToken& hat mStorage.resetLockout(); } - ALOGD("%p:%s: onLockoutCleared", this, __func__); + SESSION_DEBUG0("onLockoutCleared"); mSessionCb->onLockoutCleared(); } else { - ALOGE("%p:%s: onError(UNABLE_TO_PROCESS, %d): `hat` is invalid", - this, __func__, int(err)); + SESSION_ERR("onError(UNABLE_TO_PROCESS, %d): `hat` is invalid: %s", + int(err), errorCode2str(err).c_str()); mSessionCb->onError(Error::UNABLE_TO_PROCESS, int(err)); } return ndk::ScopedAStatus::ok(); @@ -325,18 +337,19 @@ ndk::ScopedAStatus Session::resetLockout(const keymaster::HardwareAuthToken& hat ndk::ScopedAStatus Session::close() { mChallenges.clear(); - ALOGD("%p:%s: onSessionClosed", this, __func__); + SESSION_DEBUG0("onSessionClosed"); mSessionCb->onSessionClosed(); return ndk::ScopedAStatus::ok(); } Session::ErrorCode Session::validateHat(const keymaster::HardwareAuthToken& hat) const { if (hat.mac.empty()) { - return ErrorCode::E_HAT_MAC_EMPTY; + return FAILURE(ErrorCode::E_HAT_MAC_EMPTY); } if (!mChallenges.count(hat.challenge)) { - return ErrorCode::E_HAT_WRONG_CHALLENGE; + return FAILURE_V(ErrorCode::E_HAT_WRONG_CHALLENGE, + "unexpected challenge: %" PRId64, hat.challenge); } return ErrorCode::OK; @@ -347,31 +360,31 @@ int64_t Session::generateInt64() { return distrib(mRandom); } -void Session::onSenserEventOn(const int32_t enrollmentId) { +void Session::onSensorEventOn(const int32_t enrollmentId) { std::lock_guard<std::mutex> lock(mMutex); switch (mState) { case State::ENROLLING_START: case State::ENROLLING_END: { - ALOGD("%p:%s: onAcquired(GOOD, %d)", this, __func__, 0); + SESSION_DEBUG("onAcquired(GOOD, %d)", 0); mSessionCb->onAcquired(AcquiredInfo::GOOD, 0); const int left = int(State::ENROLLING_END) - int(mState); if (left > 0) { - ALOGD("%p:%s: onEnrollmentProgress(enrollmentId=%d, left=%d)", - this, __func__, enrollmentId, left); + SESSION_DEBUG("onEnrollmentProgress(enrollmentId=%d, left=%d)", + enrollmentId, left); mSessionCb->onEnrollmentProgress(enrollmentId, left); mState = State(int(mState) + 1); } else if (mStorage.enroll(enrollmentId, mEnrollingSecUserId, generateInt64())) { - ALOGD("%p:%s: onEnrollmentProgress(enrollmentId=%d, left=%d)", - this, __func__, enrollmentId, left); + SESSION_DEBUG("onEnrollmentProgress(enrollmentId=%d, left=%d)", + enrollmentId, left); mSessionCb->onEnrollmentProgress(enrollmentId, left); mState = State::IDLE; } else { - ALOGE("%p:%s: onError(UNABLE_TO_PROCESS, %d): enrollmentId=%d, " - "secureIserId=%" PRId64 , - this, __func__, int(ErrorCode::E_ENROLL_FAILED), - enrollmentId, mEnrollingSecUserId); + SESSION_ERR("onError(UNABLE_TO_PROCESS, %d): enrollmentId=%d, " + "secureIserId=%" PRId64 , + int(ErrorCode::E_ENROLL_FAILED), + enrollmentId, mEnrollingSecUserId); mSessionCb->onError(Error::UNABLE_TO_PROCESS, int(ErrorCode::E_ENROLL_FAILED)); mState = State::IDLE; @@ -384,17 +397,17 @@ void Session::onSenserEventOn(const int32_t enrollmentId) { const auto [res, lockoutDurationMillis, tok] = mStorage.authenticate(enrollmentId); if (res != Storage::AuthResult::LOCKED_OUT_PERMANENT) { - ALOGD("%p:%s: onAcquired(GOOD, %d)", this, __func__, 0); + SESSION_DEBUG("onAcquired(GOOD, %d)", 0); mSessionCb->onAcquired(AcquiredInfo::GOOD, 0); } switch (res) { case Storage::AuthResult::OK: { - ALOGD("%p:%s: onAuthenticationSucceeded(enrollmentId=%d, " - "hat={ .challenge=%" PRId64 ", .userId=%" PRId64 ", " - ".authenticatorId=%" PRId64 " })", - this, __func__, enrollmentId, mAuthChallenge, - tok.userId, tok.authenticatorId); + SESSION_DEBUG("onAuthenticationSucceeded(enrollmentId=%d, " + "hat={ .challenge=%" PRId64 ", .userId=%" PRId64 ", " + ".authenticatorId=%" PRId64 " })", + enrollmentId, mAuthChallenge, + tok.userId, tok.authenticatorId); keymaster::HardwareAuthToken hat; hat.challenge = mAuthChallenge; @@ -408,27 +421,26 @@ void Session::onSenserEventOn(const int32_t enrollmentId) { break; case Storage::AuthResult::FAILED: - ALOGE("%p:%s: onAuthenticationFailed: enrollmentId=%d", - this, __func__, enrollmentId); + SESSION_ERR("onAuthenticationFailed: enrollmentId=%d", enrollmentId); mSessionCb->onAuthenticationFailed(); break; case Storage::AuthResult::LOCKED_OUT_TIMED: - ALOGE("%p:%s: onLockoutTimed(durationMillis=%d): enrollmentId=%d", - this, __func__, lockoutDurationMillis, enrollmentId); + SESSION_ERR("onLockoutTimed(durationMillis=%d): enrollmentId=%d", + lockoutDurationMillis, enrollmentId); mSessionCb->onLockoutTimed(lockoutDurationMillis); mState = State::IDLE; break; case Storage::AuthResult::LOCKED_OUT_PERMANENT: - ALOGE("%p:%s: onLockoutPermanent: enrollmentId=%d", - this, __func__, enrollmentId); + SESSION_ERR("onLockoutPermanent: enrollmentId=%d", enrollmentId); mSessionCb->onLockoutPermanent(); mState = State::IDLE; break; default: - LOG_ALWAYS_FATAL("Unexpected result from `mStorage.authenticate`"); + LOG_ALWAYS_FATAL("%p:%s:%d: Unexpected result from `mStorage.authenticate`", + this, __func__, __LINE__); break; } } @@ -443,12 +455,12 @@ void Session::onSenserEventOn(const int32_t enrollmentId) { break; default: - LOG_ALWAYS_FATAL("Unexpected session state"); + LOG_ALWAYS_FATAL("%p:%s:%d: Unexpected session state", this, __func__, __LINE__); break; } } -void Session::onSenserEventOff() {} +void Session::onSensorEventOff() {} void Session::cancellEnroll() { { @@ -458,7 +470,7 @@ void Session::cancellEnroll() { } } - ALOGD("%p:%s: onError(CANCELED, %d)", this, __func__, 0); + SESSION_DEBUG("onError(CANCELED, %d)", 0); mSessionCb->onError(Error::CANCELED, 0); } @@ -470,7 +482,7 @@ void Session::cancellAuthenticate() { } } - ALOGD("%p:%s: onError(CANCELED, %d)", this, __func__, 0); + SESSION_DEBUG("onError(CANCELED, %d)", 0); mSessionCb->onError(Error::CANCELED, 0); } @@ -482,14 +494,15 @@ void Session::cancellDetectInteraction() { } } - ALOGD("%p:%s: onError(CANCELED, %d)", this, __func__, 0); + SESSION_DEBUG("onError(CANCELED, %d)", 0); mSessionCb->onError(Error::CANCELED, 0); } bool Session::sensorListenerFuncImpl() { unique_fd sensorFd(qemud_channel_open(kSensorServiceName)); - LOG_ALWAYS_FATAL_IF(!sensorFd.ok(), "Could not open the sensor service: '%s'", - kSensorServiceName); + LOG_ALWAYS_FATAL_IF(!sensorFd.ok(), + "%p:%s:%d: Could not open the sensor service: '%s'", + this, __func__, __LINE__, kSensorServiceName); const unique_fd epollFd(epoll_create1(EPOLL_CLOEXEC)); epollCtlAdd(epollFd.get(), sensorFd.get()); @@ -511,7 +524,7 @@ bool Session::sensorListenerFuncImpl() { } if (lockoutCleared) { - ALOGD("%p:%s: onLockoutCleared", this, __func__); + SESSION_DEBUG0("onLockoutCleared"); mSessionCb->onLockoutCleared(); } continue; @@ -521,8 +534,7 @@ bool Session::sensorListenerFuncImpl() { const int ev_events = event.events; if (fd == sensorFd.get()) { if (ev_events & (EPOLLERR | EPOLLHUP)) { - ALOGE("%p:%s: epoll_wait: devFd has an error, ev_events=%x", - this, __func__, ev_events); + SESSION_ERR("epoll_wait: devFd has an error, ev_events=%x", ev_events); return true; } else if (ev_events & EPOLLIN) { char buf[64]; @@ -532,28 +544,25 @@ bool Session::sensorListenerFuncImpl() { int32_t fid; if (sscanf(buf, "on:%d", &fid) == 1) { if (fid > 0) { - onSenserEventOn(fid); + onSensorEventOn(fid); } else { - ALOGE("%p:%s: incorrect fingerprint: %d", - this, __func__, fid); + SESSION_ERR("incorrect fingerprint: %d", fid); } } else if (!strcmp(buf, "off")) { - onSenserEventOff(); + onSensorEventOff(); } else { - ALOGE("%p:%s: unexpected hw message: '%s'", - this, __func__, buf); + SESSION_ERR("unexpected hw message: '%s'", buf); return true; } } else { - ALOGE("%p:%s: hw read error, n=%d, errno=%d", - this, __func__, __LINE__, n, errno); + SESSION_ERR("hw read error, n=%d, errno=%d", n, errno); return true; } } } else if (fd == mSensorThreadFd.get()) { if (ev_events & (EPOLLERR | EPOLLHUP)) { - LOG_ALWAYS_FATAL("%p:%s: epoll_wait: threadsFd has an error, ev_events=%x", - this, __func__, ev_events); + LOG_ALWAYS_FATAL("%p:%s:%d: epoll_wait: threadsFd has an error, ev_events=%x", + this, __func__, __LINE__, ev_events); } else if (ev_events & EPOLLIN) { char cmd; int n = TEMP_FAILURE_RETRY(read(fd, &cmd, sizeof(cmd))); @@ -563,18 +572,17 @@ bool Session::sensorListenerFuncImpl() { return false; // quit default: - LOG_ALWAYS_FATAL("%p:%s: unexpected command, cmd=%c", - this, __func__, cmd); + LOG_ALWAYS_FATAL("%p:%s:%d: unexpected command, cmd=%c", + this, __func__, __LINE__, cmd); break; } } else { - LOG_ALWAYS_FATAL("%p:%s: error readind from mThreadsFd, errno=%d", - this, __func__, errno); + LOG_ALWAYS_FATAL("%p:%s:%d: error readind from mThreadsFd, errno=%d", + this, __func__, __LINE__, errno); } } } else { - ALOGE("%p:%s: epoll_wait() returned unexpected fd", - this, __func__); + SESSION_ERR("%s", "epoll_wait() returned unexpected fd"); } } } diff --git a/fingerprint/session.h b/fingerprint/session.h index 1daafcc0..d7b5ff1c 100644 --- a/fingerprint/session.h +++ b/fingerprint/session.h @@ -68,8 +68,8 @@ struct Session : public BnSession { ErrorCode validateHat(const keymaster::HardwareAuthToken& hat) const; bool sensorListenerFuncImpl(); void sensorListenerFunc() { while (sensorListenerFuncImpl()) {} } - void onSenserEventOn(int fid); - void onSenserEventOff(); + void onSensorEventOn(int fid); + void onSensorEventOff(); void cancellEnroll(); void cancellAuthenticate(); void cancellDetectInteraction(); diff --git a/fingerprint/storage.cpp b/fingerprint/storage.cpp index c256294b..1523dc4e 100644 --- a/fingerprint/storage.cpp +++ b/fingerprint/storage.cpp @@ -19,7 +19,7 @@ #include <unistd.h> #include <cstdio> #include <android-base/unique_fd.h> -#include <log/log.h> +#include <debug.h> #include "storage.h" namespace aidl::android::hardware::biometrics::fingerprint { @@ -44,9 +44,8 @@ unique_fd openFile(const int32_t sensorId, const int32_t userId, const bool outp if (fd >= 0) { return unique_fd(fd); } else { - ALOGE("%s:%d open('%s', output=%d) failed with errno=%d", - __func__, __LINE__, filename, output, errno); - return {}; + return FAILURE_V(unique_fd(), "open('%s', output=%d) failed with errno=%d", + filename, output, errno); } } @@ -61,9 +60,8 @@ std::vector<uint8_t> loadFile(const int fd) { if (n > 0) { size += n; } else if (n < 0) { - ALOGE("%s:%d error reading from a file, errno=%d", - __func__, __LINE__, errno); - return {}; + decltype(result) empty; + return FAILURE_V(empty, "error reading from a file, errno=%d", errno); } else { result.resize(size); return result; @@ -78,13 +76,10 @@ bool saveFile(const int fd, const uint8_t* i, size_t size) { i += n; size -= n; } else if (n < 0) { - ALOGE("%s:%d error writing to a file, errno=%d", - __func__, __LINE__, errno); - return false; + return FAILURE_V(false, "error writing to a file, errno=%d", errno); } else { - ALOGE("%s:%d `write` returned zero, size=%zu, errno=%d", - __func__, __LINE__, size, errno); - return false; + return FAILURE_V(false, "`write` returned zero, size=%zu, errno=%d", + size, errno); } } return true; @@ -223,7 +218,7 @@ Storage::authenticate(const int32_t enrollmentId) { const int64_t inMs = std::chrono::duration_cast< std::chrono::milliseconds>(mLockOut.nextAttempt - now).count(); - return {AuthResult::LOCKED_OUT_TIMED, inMs, {}}; + return {AuthResult::LOCKED_OUT_TIMED, static_cast<int>(inMs), {}}; } break; diff --git a/init.ranchu.rc b/init.ranchu.rc index dfff0d47..7ee7c20e 100644 --- a/init.ranchu.rc +++ b/init.ranchu.rc @@ -57,12 +57,11 @@ on init start qemu-props on post-fs-data - mkdir /data/vendor/adb 0755 root root - mkdir /data/vendor/devicestate 0755 root root mkdir /data/vendor/var 0755 root root mkdir /data/vendor/var/run 0755 root root start qemu-device-state + start ranchu-adb-setup on zygote-start # Create the directories used by the Wireless subsystem @@ -105,7 +104,6 @@ on property:vendor.qemu.timezone=* on property:dev.bootcomplete=1 && property:vendor.qemu.dev.bootcomplete=0 setprop vendor.qemu.dev.bootcomplete 1 - start ranchu-adb-setup start qemu-props-bootcomplete start ranchu-setup @@ -147,11 +145,12 @@ service qemu-props-bootcomplete /vendor/bin/qemu-props "bootcomplete" oneshot disabled -service qemu-device-state /vendor/bin/qemu-export-property -f qemu.device_state /data/vendor/devicestate/device_state_configuration.xml +service qemu-device-state /vendor/bin/init_ranchu_device_state.sh user root group root oneshot disabled + stdio_to_kmsg service goldfish-logcat /system/bin/logcat -f /dev/hvc1 ${ro.boot.logcat} class main diff --git a/init.system_ext.rc b/init.system_ext.rc index a053c814..07711d16 100644 --- a/init.system_ext.rc +++ b/init.system_ext.rc @@ -3,6 +3,6 @@ on property:init.svc.ranchu-adb-setup=stopped on property:init.svc.qemu-device-state=stopped && property:ro.boot.qemu.device_state=* mkdir /data/system/devicestate/ 0755 system system - copy /data/vendor/devicestate/device_state_configuration.xml /data/system/devicestate/device_state_configuration.xml - rm /data/vendor/devicestate/device_state_configuration.xml + copy /data/vendor/device_state_configuration.xml /data/system/devicestate/device_state_configuration.xml + rm /data/vendor/device_state_configuration.xml chown system system /data/system/devicestate/device_state_configuration.xml diff --git a/init_ranchu_device_state.sh b/init_ranchu_device_state.sh new file mode 100755 index 00000000..fbe71ac3 --- /dev/null +++ b/init_ranchu_device_state.sh @@ -0,0 +1,8 @@ +#!/system/bin/sh -e +DEVICE_STATE_FILE="/data/vendor/device_state_configuration.xml" +STATE=`getprop ro.boot.qemu.device_state` + +if [ -n "$STATE" ]; then + echo "$STATE" > "$DEVICE_STATE_FILE" + chmod 0755 "$DEVICE_STATE_FILE" +fi diff --git a/overlay/frameworks/base/packages/SystemUI/res/values/dimens.xml b/overlay/frameworks/base/packages/SystemUI/res/values/dimens.xml new file mode 100644 index 00000000..763077f1 --- /dev/null +++ b/overlay/frameworks/base/packages/SystemUI/res/values/dimens.xml @@ -0,0 +1,4 @@ +<resources> + <!-- The starting padding for the clock in the status bar. --> + <dimen name="status_bar_clock_starting_padding">12dp</dimen> +</resources> diff --git a/pc/data/etc/pc.xml b/pc/data/etc/pc.xml index f98acb58..15b4b2b6 100644 --- a/pc/data/etc/pc.xml +++ b/pc/data/etc/pc.xml @@ -31,6 +31,7 @@ <unavailable-feature name="android.hardware.telephony" /> <unavailable-feature name="android.hardware.telephony.data" /> <unavailable-feature name="android.hardware.telephony.gsm" /> + <unavailable-feature name="android.hardware.telephony.messaging" /> <unavailable-feature name="android.hardware.telephony.ims" /> <unavailable-feature name="android.hardware.telephony.radio.access" /> <unavailable-feature name="android.hardware.telephony.subscription" /> diff --git a/product/generic.mk b/product/generic.mk index b1590015..2558349e 100644 --- a/product/generic.mk +++ b/product/generic.mk @@ -31,6 +31,9 @@ PRODUCT_SOONG_NAMESPACES += \ TARGET_USES_MKE2FS := true +# Set Vendor SPL to match platform +VENDOR_SECURITY_PATCH = $(PLATFORM_SECURITY_PATCH) + # RKPD PRODUCT_PRODUCT_PROPERTIES += \ remote_provisioning.enable_rkpd=true \ @@ -55,10 +58,12 @@ PRODUCT_VENDOR_PROPERTIES += \ ro.surface_flinger.supports_background_blur=1 \ ro.surface_flinger.use_color_management=false \ ro.zygote.disable_gl_preload=1 \ + debug.renderengine.backend=skiaglthreaded \ debug.sf.vsync_reactor_ignore_present_fences=true \ debug.stagefright.c2inputsurface=-1 \ debug.stagefright.ccodec=4 \ graphics.gpu.profiler.support=true \ + persist.sys.usb.config="" \ persist.sys.zram_enabled=1 \ wifi.direct.interface=p2p-dev-wlan0 \ wifi.interface=wlan0 \ @@ -72,7 +77,6 @@ PRODUCT_PACKAGES += \ libandroidemu \ libOpenglCodecCommon \ libOpenglSystemCommon \ - qemu-export-property \ qemu-props \ stagefright \ android.hardware.graphics.composer3-service.ranchu \ @@ -300,6 +304,7 @@ PRODUCT_COPY_FILES += \ device/generic/goldfish/data/etc/numeric_operator.xml:data/misc/modem_simulator/etc/modem_simulator/files/numeric_operator.xml \ device/generic/goldfish/data/etc/local.prop:data/local.prop \ device/generic/goldfish/init.ranchu.adb.setup.sh:$(TARGET_COPY_OUT_SYSTEM_EXT)/bin/init.ranchu.adb.setup.sh \ + device/generic/goldfish/init_ranchu_device_state.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init_ranchu_device_state.sh \ device/generic/goldfish/init.ranchu-core.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.ranchu-core.sh \ device/generic/goldfish/init.ranchu-net.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.ranchu-net.sh \ device/generic/goldfish/init.ranchu.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/hw/init.ranchu.rc \ diff --git a/provision/EmulatorProvisonLib/src/com/android/sdksetup/ProvisionActivity.java b/provision/EmulatorProvisonLib/src/com/android/sdksetup/ProvisionActivity.java index 8c3a7bff..8ba2c913 100644 --- a/provision/EmulatorProvisonLib/src/com/android/sdksetup/ProvisionActivity.java +++ b/provision/EmulatorProvisonLib/src/com/android/sdksetup/ProvisionActivity.java @@ -46,7 +46,7 @@ public abstract class ProvisionActivity extends Activity { protected void onCreate(Bundle icicle) { super.onCreate(icicle); - if (Settings.Global.getInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0) != 1) { + if (provisionRequired()) { preProvivion(); doProvision(); postProvision(); @@ -225,4 +225,13 @@ public abstract class ProvisionActivity extends Activity { } } } + + protected boolean provisionRequired() { + return (Settings.Global.getInt(getContentResolver(), + Settings.Global.DEVICE_PROVISIONED, 0) != 1) || forceProvision(); + } + + protected boolean forceProvision() { + return SystemProperties.get("ro.automotive_emulator.provisioning", "").equals("SdkSetup"); + } } diff --git a/qemu-export-property/Android.bp b/qemu-export-property/Android.bp deleted file mode 100644 index 8bbca83e..00000000 --- a/qemu-export-property/Android.bp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2021 The Android Open Source Project -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// this file is used to build emulator-specific program tools -// that should only run in the emulator. -// - -package { - // See: http://go/android-license-faq - // A large-scale-change added 'default_applicable_licenses' to import - // all of the 'license_kinds' from "device_generic_goldfish_license" - // to get the below license kinds: - // SPDX-license-identifier-Apache-2.0 - default_applicable_licenses: ["device_generic_goldfish_license"], -} - -cc_binary { - name: "qemu-export-property", - vendor: true, - srcs: [ - "main.cpp", - ], - shared_libs: [ - "libbase", - "liblog", - ], - static_libs: [ - "libfstab", - ], - cflags: [ - "-DLOG_TAG=\"qemu-export-property\"", - ], -} diff --git a/qemu-export-property/main.cpp b/qemu-export-property/main.cpp deleted file mode 100644 index 480ea08a..00000000 --- a/qemu-export-property/main.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <fstream> -#include <string> -#include <log/log.h> -#include <sys/stat.h> - -extern bool fs_mgr_get_boot_config(const std::string& key, std::string* out_val); - -namespace { -int printUsage() { - ALOGE("Usage: qemu-export-property [-f] property_name filename"); - return 1; -} - -int exportPropertyImpl(const char* propName, const char* filename) { - std::string propValue; - if (!fs_mgr_get_boot_config(propName, &propValue)) { - ALOGV("'%s' bootconfig property is not set", propName); - return 0; - } - - std::ofstream f; - f.open(filename); - if (f.is_open()) { - f << propValue; - f.close(); - return 0; - } else { - ALOGE("Failed to open '%s'\n", filename); - return 1; - } -} -} // namespace - -int main(const int argc, const char* argv[]) { - if (argc < 2) { - return printUsage(); - } - - if (strcmp(argv[1], "-f") == 0) { - if (argc == 4) { - return exportPropertyImpl(argv[2], argv[3]); - } else { - return printUsage(); - } - } else if (argc == 3) { - struct stat st; - if (stat(argv[2], &st) == 0) { - ALOGV("'%s' already exists", argv[2]); - return 0; - } else { - return exportPropertyImpl(argv[1], argv[2]); - } - } else { - return printUsage(); - } -} diff --git a/sensors/multihal_sensors.cpp b/sensors/multihal_sensors.cpp index beb34d92..829c501c 100644 --- a/sensors/multihal_sensors.cpp +++ b/sensors/multihal_sensors.cpp @@ -39,6 +39,17 @@ struct SensorsTransportStub : public SensorsTransport { const char* Name() const override { return "stub"; } }; +// https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/main/sensors/aidl/android/hardware/sensors/SensorInfo.aidl#146 +// 3 bits starting from the 1st: MMMx +uint32_t getSensorReportingMode(const uint32_t sensorFlagBits) { + return sensorFlagBits & (7U << 1); +} + +bool isOnChangeSensor(const uint32_t sensorFlagBits) { + return getSensorReportingMode(sensorFlagBits) == + static_cast<uint32_t>(SensorFlagBits::ON_CHANGE_MODE); +} + const SensorsTransportStub g_sensorsTransportStub; } @@ -140,7 +151,7 @@ Return<Result> MultihalSensors::activate(const int32_t sensorHandle, if (enabled) { const SensorInfo* sensor = getSensorInfoByHandle(sensorHandle); LOG_ALWAYS_FATAL_IF(!sensor); - if (sensor->flags & static_cast<uint32_t>(SensorFlagBits::ON_CHANGE_MODE)) { + if (isOnChangeSensor(sensor->flags)) { doPostSensorEventLocked(*sensor, activationOnChangeSensorEvent(sensorHandle, *sensor)); } else { diff --git a/sepolicy/system_ext/private/property_contexts b/sepolicy/system_ext/private/property_contexts deleted file mode 100644 index 836ecd76..00000000 --- a/sepolicy/system_ext/private/property_contexts +++ /dev/null @@ -1,4 +0,0 @@ -persist.bootanim.color1 u:object_r:bootanim_system_prop:s0 exact int -persist.bootanim.color2 u:object_r:bootanim_system_prop:s0 exact int -persist.bootanim.color3 u:object_r:bootanim_system_prop:s0 exact int -persist.bootanim.color4 u:object_r:bootanim_system_prop:s0 exact int diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index f20af17d..67dd9379 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -11,7 +11,6 @@ /dev/block/vde u:object_r:system_block_device:s0 /dev/block/zram0 u:object_r:swap_block_device:s0 -/dev/goldfish_pipe u:object_r:qemu_device:s0 /dev/goldfish_pipe_dprctd u:object_r:qemu_device:s0 /dev/vport.*p.* u:object_r:qemu_device:s0 /dev/goldfish_sync u:object_r:qemu_device:s0 @@ -32,10 +31,10 @@ /system_ext/bin/init\.ranchu\.adb\.setup\.sh u:object_r:goldfish_system_setup_exec:s0 +/vendor/bin/init_ranchu_device_state\.sh u:object_r:init_ranchu_device_state_exec:s0 /vendor/bin/init\.ranchu-core\.sh u:object_r:goldfish_setup_exec:s0 /vendor/bin/init\.ranchu-net\.sh u:object_r:goldfish_setup_exec:s0 /vendor/bin/dlkm_loader u:object_r:dlkm_loader_exec:s0 -/vendor/bin/qemu-export-property u:object_r:qemu_export_property_exec:s0 /vendor/bin/qemu-props u:object_r:qemu_props_exec:s0 /vendor/bin/mac80211_create_radios u:object_r:mac80211_create_radios_exec:s0 /vendor/bin/hw/libgoldfish-rild u:object_r:rild_exec:s0 diff --git a/sepolicy/vendor/goldfish_system_setup.te b/sepolicy/vendor/goldfish_system_setup.te index e57e0159..3152230d 100644 --- a/sepolicy/vendor/goldfish_system_setup.te +++ b/sepolicy/vendor/goldfish_system_setup.te @@ -7,7 +7,7 @@ init_daemon_domain(goldfish_system_setup) allow goldfish_system_setup shell_exec:file { rx_file_perms }; # Allow write to /dev/kmsg -allow goldfish_system_setup kmsg_debug_device:chr_file { getattr write }; +allow goldfish_system_setup kmsg_debug_device:chr_file { w_file_perms getattr ioctl }; # Allow read/write /data/misc/adb/adb_keys allow goldfish_system_setup adb_keys_file:file { create setattr rw_file_perms }; diff --git a/sepolicy/vendor/init_ranchu_device_state.te b/sepolicy/vendor/init_ranchu_device_state.te new file mode 100644 index 00000000..a7fb82a4 --- /dev/null +++ b/sepolicy/vendor/init_ranchu_device_state.te @@ -0,0 +1,11 @@ +type init_ranchu_device_state, domain; +type init_ranchu_device_state_exec, vendor_file_type, exec_type, file_type; + +init_daemon_domain(init_ranchu_device_state) + +# Permission to write to /data/vendor/* +allow init_ranchu_device_state vendor_data_file:dir create_dir_perms; +allow init_ranchu_device_state vendor_data_file:file create_file_perms; + +# Allow write to /dev/kmsg +allow init_ranchu_device_state kmsg_debug_device:chr_file { w_file_perms getattr ioctl }; diff --git a/sepolicy/vendor/qemu_export_property.te b/sepolicy/vendor/qemu_export_property.te deleted file mode 100644 index e73589ea..00000000 --- a/sepolicy/vendor/qemu_export_property.te +++ /dev/null @@ -1,14 +0,0 @@ -type qemu_export_property, domain; -type qemu_export_property_exec, vendor_file_type, exec_type, file_type; - -init_daemon_domain(qemu_export_property) - -# Allow qemu_export_property to read /proc/bootconfig -allow qemu_export_property proc_cmdline:file r_file_perms; -allow qemu_export_property proc_bootconfig:file r_file_perms; - -# Permission to write to /data/vendor/* -allow qemu_export_property vendor_data_file:dir create_dir_perms; -allow qemu_export_property vendor_data_file:file create_file_perms; -allow qemu_export_property sysfs_dt_firmware_android:dir search; -allow qemu_export_property sysfs_dt_firmware_android:file r_file_perms; diff --git a/slim/data/etc/slim_handheld_core_hardware.xml b/slim/data/etc/slim_handheld_core_hardware.xml index 7f17a64f..23a6cdf1 100644 --- a/slim/data/etc/slim_handheld_core_hardware.xml +++ b/slim/data/etc/slim_handheld_core_hardware.xml @@ -45,7 +45,13 @@ This file should be almost identical to device/generic/goldfish/data/etc/handhel <feature name="android.hardware.sensor.gyroscope" /> <feature name="android.hardware.sensor.hinge_angle" /> <feature name="android.hardware.telephony" /> + <feature name="android.hardware.telephony.calling" /> + <feature name="android.hardware.telephony.data" /> <feature name="android.hardware.telephony.gsm" /> + <feature name="android.hardware.telephony.messaging" /> + <feature name="android.hardware.telephony.ims" /> + <feature name="android.hardware.telephony.radio.access" /> + <feature name="android.hardware.telephony.subscription" /> <feature name="android.hardware.touchscreen" /> <feature name="android.hardware.microphone" /> <feature name="android.hardware.screen.portrait" /> @@ -62,6 +68,7 @@ This file should be almost identical to device/generic/goldfish/data/etc/handhel <feature name="android.software.print" /> <feature name="android.software.cant_save_state" /> <feature name="android.software.companion_device_setup" /> + <feature name="android.software.credentials" /> <!-- Feature to specify if the device supports adding device admins. --> <feature name="android.software.device_admin" /> @@ -73,6 +80,8 @@ This file should be almost identical to device/generic/goldfish/data/etc/handhel <feature name="android.software.cts" /> + <feature name="android.hardware.security.model.compatible" /> + <!-- Feature to specify if the device supports controls. --> <feature name="android.software.controls" /> diff --git a/wifi/wifi_hal/Android.bp b/wifi/wifi_hal/Android.bp index b21ddb46..62987df6 100644 --- a/wifi/wifi_hal/Android.bp +++ b/wifi/wifi_hal/Android.bp @@ -40,7 +40,7 @@ cc_library_static { "libnl", "liblog", "libcutils", - "libhardware_legacy", + "wifi_legacy", ], proprietary: true, } diff --git a/wifi/wifi_hal/interface.cpp b/wifi/wifi_hal/interface.cpp index 4320541f..45ef7fb2 100644 --- a/wifi/wifi_hal/interface.cpp +++ b/wifi/wifi_hal/interface.cpp @@ -22,8 +22,11 @@ #include <linux/rtnetlink.h> +#include <algorithm> #include <future> +static const int kApfRamSize = 4096; + // Provide some arbitrary firmware and driver versions for now static const char kFirmwareVersion[] = "1.0"; static const char kDriverVersion[] = "1.0"; @@ -54,13 +57,15 @@ constexpr size_t arraySize(const T (&)[N]) { Interface::Interface(Netlink& netlink, const char* name) : mNetlink(netlink) , mName(name) - , mInterfaceIndex(0) { + , mInterfaceIndex(0) + , mApfMemory(kApfRamSize) { } Interface::Interface(Interface&& other) noexcept : mNetlink(other.mNetlink) , mName(std::move(other.mName)) - , mInterfaceIndex(other.mInterfaceIndex) { + , mInterfaceIndex(other.mInterfaceIndex) + , mApfMemory(std::move(other.mApfMemory)) { } bool Interface::init() { @@ -258,7 +263,24 @@ wifi_error Interface::getPacketFilterCapabilities(u32* version, return WIFI_ERROR_INVALID_ARGS; } *version = 4; - *maxLength = 4096; + *maxLength = kApfRamSize; + return WIFI_SUCCESS; +} + +wifi_error Interface::readPacketFilter(u32 src_offset, u8 *host_dst, u32 length) { + if (src_offset >= mApfMemory.size() || host_dst == nullptr + || length > mApfMemory.size() - src_offset) { + return WIFI_ERROR_INVALID_ARGS; + } + std::copy(mApfMemory.begin() + src_offset, mApfMemory.begin() + src_offset + length, host_dst); + return WIFI_SUCCESS; +} + +wifi_error Interface::setPacketFilter(const u8 *program, u32 len) { + if (program == nullptr || len > mApfMemory.size()) { + return WIFI_ERROR_INVALID_ARGS; + } + std::copy(program, program + len, mApfMemory.begin()); return WIFI_SUCCESS; } diff --git a/wifi/wifi_hal/interface.h b/wifi/wifi_hal/interface.h index de01c16f..9ebc502e 100644 --- a/wifi/wifi_hal/interface.h +++ b/wifi/wifi_hal/interface.h @@ -18,6 +18,7 @@ #include <stdint.h> #include <string> +#include <vector> #include <hardware_legacy/wifi_hal.h> class Netlink; @@ -69,6 +70,8 @@ public: size_t numRequestedFates, size_t* numProvidedFates); wifi_error getPacketFilterCapabilities(u32* version, u32* maxLength); + wifi_error readPacketFilter(u32 src_offset, u8 *host_dst, u32 length); + wifi_error setPacketFilter(const u8 *program, u32 len); wifi_error getWakeReasonStats(WLAN_DRIVER_WAKE_REASON_CNT* wakeReasonCount); wifi_error startSendingOffloadedPacket(wifi_request_id id, u16 ether_type, @@ -90,5 +93,6 @@ private: Netlink& mNetlink; std::string mName; uint32_t mInterfaceIndex; + std::vector<u8> mApfMemory; }; diff --git a/wifi/wifi_hal/wifi_hal.cpp b/wifi/wifi_hal/wifi_hal.cpp index 62ac061b..09551481 100644 --- a/wifi/wifi_hal/wifi_hal.cpp +++ b/wifi/wifi_hal/wifi_hal.cpp @@ -357,6 +357,25 @@ wifi_error wifi_get_packet_filter_capabilities(wifi_interface_handle handle, return asInterface(handle)->getPacketFilterCapabilities(version, max_len); } +wifi_error wifi_set_packet_filter(wifi_interface_handle handle, + const u8 *program, u32 len) { + if (handle == nullptr) { + return WIFI_ERROR_INVALID_ARGS; + } + + return asInterface(handle)->setPacketFilter(program, len); +} + +wifi_error wifi_read_packet_filter(wifi_interface_handle handle, + u32 src_offset, u8 *host_dst, + u32 length) { + if (handle == nullptr) { + return WIFI_ERROR_INVALID_ARGS; + } + + return asInterface(handle)->readPacketFilter(src_offset, host_dst, length); +} + wifi_error wifi_get_wake_reason_stats(wifi_interface_handle handle, WLAN_DRIVER_WAKE_REASON_CNT *wifi_wake_reason_cnt) { @@ -432,6 +451,8 @@ wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn* fn) fn->wifi_get_rx_pkt_fates = wifi_get_rx_pkt_fates; fn->wifi_get_packet_filter_capabilities = wifi_get_packet_filter_capabilities; + fn->wifi_set_packet_filter = wifi_set_packet_filter; + fn->wifi_read_packet_filter = wifi_read_packet_filter; fn->wifi_get_wake_reason_stats = wifi_get_wake_reason_stats; fn->wifi_start_sending_offloaded_packet @@ -461,7 +482,6 @@ wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn* fn) notSupported(fn->wifi_reset_log_handler); notSupported(fn->wifi_start_rssi_monitoring); notSupported(fn->wifi_stop_rssi_monitoring); - notSupported(fn->wifi_set_packet_filter); return WIFI_SUCCESS; } |