Loading cmds/servicemanager/ServiceManager.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -150,7 +150,7 @@ static std::optional<std::string> getVintfUpdatableApex(const std::string& name) std::optional<std::string> updatableViaApex; forEachManifest([&](const ManifestWithDescription& mwd) { mwd.manifest->forEachInstance([&](const auto& manifestInstance) { bool cont = mwd.manifest->forEachInstance([&](const auto& manifestInstance) { if (manifestInstance.format() != vintf::HalFormat::AIDL) return true; if (manifestInstance.package() != aname.package) return true; if (manifestInstance.interface() != aname.iface) return true; Loading @@ -158,8 +158,7 @@ static std::optional<std::string> getVintfUpdatableApex(const std::string& name) updatableViaApex = manifestInstance.updatableViaApex(); return false; // break (libvintf uses opposite convention) }); if (updatableViaApex.has_value()) return true; // break (found match) return false; // continue return !cont; }); return updatableViaApex; Loading data/etc/android.hardware.location.gps.xml +0 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,5 @@ <!-- These are the location-related features for devices that include GPS. --> <permissions> <feature name="android.hardware.location" /> <feature name="android.hardware.location.network" /> <feature name="android.hardware.location.gps" /> </permissions> data/etc/car_core_hardware.xml +0 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ <feature name="android.hardware.audio.output" /> <feature name="android.hardware.location" /> <feature name="android.hardware.location.network" /> <feature name="android.hardware.bluetooth" /> <feature name="android.hardware.touchscreen" /> <feature name="android.hardware.microphone" /> Loading include/ftl/expected.h 0 → 100644 +65 −0 Original line number Diff line number Diff line /* * Copyright 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. */ #pragma once #include <android-base/expected.h> #include <ftl/optional.h> #include <utility> namespace android::ftl { // Superset of base::expected<T, E> with monadic operations. // // TODO: Extend std::expected<T, E> in C++23. // template <typename T, typename E> struct Expected final : base::expected<T, E> { using Base = base::expected<T, E>; using Base::expected; using Base::error; using Base::has_value; using Base::value; template <typename P> constexpr bool has_error(P predicate) const { return !has_value() && predicate(error()); } constexpr Optional<T> value_opt() const& { return has_value() ? Optional(value()) : std::nullopt; } constexpr Optional<T> value_opt() && { return has_value() ? Optional(std::move(value())) : std::nullopt; } // Delete new for this class. Its base doesn't have a virtual destructor, and // if it got deleted via base class pointer, it would cause undefined // behavior. There's not a good reason to allocate this object on the heap // anyway. static void* operator new(size_t) = delete; static void* operator new[](size_t) = delete; }; template <typename E> constexpr auto Unexpected(E&& error) { return base::unexpected(std::forward<E>(error)); } } // namespace android::ftl include/input/InputTransport.h +12 −36 Original line number Diff line number Diff line Loading @@ -35,18 +35,16 @@ #include <android-base/result.h> #include <android-base/unique_fd.h> #include <android/os/InputChannelCore.h> #include <binder/IBinder.h> #include <binder/Parcelable.h> #include <input/Input.h> #include <input/InputVerifier.h> #include <sys/stat.h> #include <ui/Transform.h> #include <utils/BitSet.h> #include <utils/Errors.h> #include <utils/RefBase.h> #include <utils/Timers.h> namespace android { class Parcel; Loading Loading @@ -231,18 +229,15 @@ struct InputMessage { * input messages across processes. Each channel has a descriptive name for debugging purposes. * * Each endpoint has its own InputChannel object that specifies its file descriptor. * For parceling, this relies on android::os::InputChannelCore, defined in aidl. * * The input channel is closed when all references to it are released. */ class InputChannel : public Parcelable { class InputChannel : private android::os::InputChannelCore { public: static std::unique_ptr<InputChannel> create(const std::string& name, android::base::unique_fd fd, sp<IBinder> token); InputChannel() = default; InputChannel(const InputChannel& other) : mName(other.mName), mFd(other.dupFd()), mToken(other.mToken){}; InputChannel(const std::string name, android::base::unique_fd fd, sp<IBinder> token); ~InputChannel() override; static std::unique_ptr<InputChannel> create(android::os::InputChannelCore&& parceledChannel); ~InputChannel(); /** * Create a pair of input channels. * The two returned input channels are equivalent, and are labeled as "server" and "client" Loading @@ -254,9 +249,8 @@ public: std::unique_ptr<InputChannel>& outServerChannel, std::unique_ptr<InputChannel>& outClientChannel); inline std::string getName() const { return mName; } inline const android::base::unique_fd& getFd() const { return mFd; } inline sp<IBinder> getToken() const { return mToken; } inline std::string getName() const { return name; } inline int getFd() const { return fd.get(); } /* Send a message to the other endpoint. * Loading Loading @@ -304,10 +298,7 @@ public: /* Return a new object that has a duplicate of this channel's fd. */ std::unique_ptr<InputChannel> dup() const; void copyTo(InputChannel& outChannel) const; status_t readFromParcel(const android::Parcel* parcel) override; status_t writeToParcel(android::Parcel* parcel) const override; void copyTo(android::os::InputChannelCore& outChannel) const; /** * The connection token is used to identify the input connection, i.e. Loading @@ -323,26 +314,11 @@ public: */ sp<IBinder> getConnectionToken() const; bool operator==(const InputChannel& inputChannel) const { struct stat lhs, rhs; if (fstat(mFd.get(), &lhs) != 0) { return false; } if (fstat(inputChannel.getFd().get(), &rhs) != 0) { return false; } // If file descriptors are pointing to same inode they are duplicated fds. return inputChannel.getName() == getName() && inputChannel.getConnectionToken() == mToken && lhs.st_ino == rhs.st_ino; } private: base::unique_fd dupFd() const; std::string mName; base::unique_fd mFd; static std::unique_ptr<InputChannel> create(const std::string& name, android::base::unique_fd fd, sp<IBinder> token); sp<IBinder> mToken; InputChannel(const std::string name, android::base::unique_fd fd, sp<IBinder> token); }; /* Loading Loading
cmds/servicemanager/ServiceManager.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -150,7 +150,7 @@ static std::optional<std::string> getVintfUpdatableApex(const std::string& name) std::optional<std::string> updatableViaApex; forEachManifest([&](const ManifestWithDescription& mwd) { mwd.manifest->forEachInstance([&](const auto& manifestInstance) { bool cont = mwd.manifest->forEachInstance([&](const auto& manifestInstance) { if (manifestInstance.format() != vintf::HalFormat::AIDL) return true; if (manifestInstance.package() != aname.package) return true; if (manifestInstance.interface() != aname.iface) return true; Loading @@ -158,8 +158,7 @@ static std::optional<std::string> getVintfUpdatableApex(const std::string& name) updatableViaApex = manifestInstance.updatableViaApex(); return false; // break (libvintf uses opposite convention) }); if (updatableViaApex.has_value()) return true; // break (found match) return false; // continue return !cont; }); return updatableViaApex; Loading
data/etc/android.hardware.location.gps.xml +0 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,5 @@ <!-- These are the location-related features for devices that include GPS. --> <permissions> <feature name="android.hardware.location" /> <feature name="android.hardware.location.network" /> <feature name="android.hardware.location.gps" /> </permissions>
data/etc/car_core_hardware.xml +0 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ <feature name="android.hardware.audio.output" /> <feature name="android.hardware.location" /> <feature name="android.hardware.location.network" /> <feature name="android.hardware.bluetooth" /> <feature name="android.hardware.touchscreen" /> <feature name="android.hardware.microphone" /> Loading
include/ftl/expected.h 0 → 100644 +65 −0 Original line number Diff line number Diff line /* * Copyright 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. */ #pragma once #include <android-base/expected.h> #include <ftl/optional.h> #include <utility> namespace android::ftl { // Superset of base::expected<T, E> with monadic operations. // // TODO: Extend std::expected<T, E> in C++23. // template <typename T, typename E> struct Expected final : base::expected<T, E> { using Base = base::expected<T, E>; using Base::expected; using Base::error; using Base::has_value; using Base::value; template <typename P> constexpr bool has_error(P predicate) const { return !has_value() && predicate(error()); } constexpr Optional<T> value_opt() const& { return has_value() ? Optional(value()) : std::nullopt; } constexpr Optional<T> value_opt() && { return has_value() ? Optional(std::move(value())) : std::nullopt; } // Delete new for this class. Its base doesn't have a virtual destructor, and // if it got deleted via base class pointer, it would cause undefined // behavior. There's not a good reason to allocate this object on the heap // anyway. static void* operator new(size_t) = delete; static void* operator new[](size_t) = delete; }; template <typename E> constexpr auto Unexpected(E&& error) { return base::unexpected(std::forward<E>(error)); } } // namespace android::ftl
include/input/InputTransport.h +12 −36 Original line number Diff line number Diff line Loading @@ -35,18 +35,16 @@ #include <android-base/result.h> #include <android-base/unique_fd.h> #include <android/os/InputChannelCore.h> #include <binder/IBinder.h> #include <binder/Parcelable.h> #include <input/Input.h> #include <input/InputVerifier.h> #include <sys/stat.h> #include <ui/Transform.h> #include <utils/BitSet.h> #include <utils/Errors.h> #include <utils/RefBase.h> #include <utils/Timers.h> namespace android { class Parcel; Loading Loading @@ -231,18 +229,15 @@ struct InputMessage { * input messages across processes. Each channel has a descriptive name for debugging purposes. * * Each endpoint has its own InputChannel object that specifies its file descriptor. * For parceling, this relies on android::os::InputChannelCore, defined in aidl. * * The input channel is closed when all references to it are released. */ class InputChannel : public Parcelable { class InputChannel : private android::os::InputChannelCore { public: static std::unique_ptr<InputChannel> create(const std::string& name, android::base::unique_fd fd, sp<IBinder> token); InputChannel() = default; InputChannel(const InputChannel& other) : mName(other.mName), mFd(other.dupFd()), mToken(other.mToken){}; InputChannel(const std::string name, android::base::unique_fd fd, sp<IBinder> token); ~InputChannel() override; static std::unique_ptr<InputChannel> create(android::os::InputChannelCore&& parceledChannel); ~InputChannel(); /** * Create a pair of input channels. * The two returned input channels are equivalent, and are labeled as "server" and "client" Loading @@ -254,9 +249,8 @@ public: std::unique_ptr<InputChannel>& outServerChannel, std::unique_ptr<InputChannel>& outClientChannel); inline std::string getName() const { return mName; } inline const android::base::unique_fd& getFd() const { return mFd; } inline sp<IBinder> getToken() const { return mToken; } inline std::string getName() const { return name; } inline int getFd() const { return fd.get(); } /* Send a message to the other endpoint. * Loading Loading @@ -304,10 +298,7 @@ public: /* Return a new object that has a duplicate of this channel's fd. */ std::unique_ptr<InputChannel> dup() const; void copyTo(InputChannel& outChannel) const; status_t readFromParcel(const android::Parcel* parcel) override; status_t writeToParcel(android::Parcel* parcel) const override; void copyTo(android::os::InputChannelCore& outChannel) const; /** * The connection token is used to identify the input connection, i.e. Loading @@ -323,26 +314,11 @@ public: */ sp<IBinder> getConnectionToken() const; bool operator==(const InputChannel& inputChannel) const { struct stat lhs, rhs; if (fstat(mFd.get(), &lhs) != 0) { return false; } if (fstat(inputChannel.getFd().get(), &rhs) != 0) { return false; } // If file descriptors are pointing to same inode they are duplicated fds. return inputChannel.getName() == getName() && inputChannel.getConnectionToken() == mToken && lhs.st_ino == rhs.st_ino; } private: base::unique_fd dupFd() const; std::string mName; base::unique_fd mFd; static std::unique_ptr<InputChannel> create(const std::string& name, android::base::unique_fd fd, sp<IBinder> token); sp<IBinder> mToken; InputChannel(const std::string name, android::base::unique_fd fd, sp<IBinder> token); }; /* Loading