Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 911588a8 authored by Yu Shan's avatar Yu Shan Committed by Android (Google) Code Review
Browse files

Merge "Remove full namespace in header file."

parents df8160ff d0c0bbb6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ class FakeValueGenerator {
    virtual ~FakeValueGenerator() = default;

    // Returns the next event if there is one or {@code std::nullopt} if there is none.
    virtual std::optional<::aidl::android::hardware::automotive::vehicle::VehiclePropValue>
    virtual std::optional<aidl::android::hardware::automotive::vehicle::VehiclePropValue>
    nextEvent() = 0;
};

+2 −2
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ namespace fake {
class GeneratorHub {
  public:
    using OnHalEvent = std::function<void(
            const ::aidl::android::hardware::automotive::vehicle::VehiclePropValue& event)>;
            const aidl::android::hardware::automotive::vehicle::VehiclePropValue& event)>;

    explicit GeneratorHub(OnHalEvent&& onHalEvent);
    ~GeneratorHub();
@@ -60,7 +60,7 @@ class GeneratorHub {
  private:
    struct VhalEvent {
        int32_t generatorId;
        ::aidl::android::hardware::automotive::vehicle::VehiclePropValue val;
        aidl::android::hardware::automotive::vehicle::VehiclePropValue val;
    };

    // Comparator used by priority queue to keep track of soonest event.
+4 −4
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ class JsonFakeValueGenerator : public FakeValueGenerator {
    // {@code int32Values} has less than 2 elements, number of iterations would be set to -1, which
    // means iterate indefinitely.
    explicit JsonFakeValueGenerator(
            const ::aidl::android::hardware::automotive::vehicle::VehiclePropValue& request);
            const aidl::android::hardware::automotive::vehicle::VehiclePropValue& request);
    // Create a new JSON fake value generator using the specified JSON file path. All the events
    // in the JSON file would be generated for number of {@code iteration}. If iteration is 0, no
    // value would be generated. If iteration is less than 0, it would iterate indefinitely.
@@ -48,14 +48,14 @@ class JsonFakeValueGenerator : public FakeValueGenerator {

    ~JsonFakeValueGenerator() = default;

    std::optional<::aidl::android::hardware::automotive::vehicle::VehiclePropValue> nextEvent()
    std::optional<aidl::android::hardware::automotive::vehicle::VehiclePropValue> nextEvent()
            override;
    const std::vector<::aidl::android::hardware::automotive::vehicle::VehiclePropValue>&
    const std::vector<aidl::android::hardware::automotive::vehicle::VehiclePropValue>&
    getAllEvents();

  private:
    size_t mEventIndex = 0;
    std::vector<::aidl::android::hardware::automotive::vehicle::VehiclePropValue> mEvents;
    std::vector<aidl::android::hardware::automotive::vehicle::VehiclePropValue> mEvents;
    long mLastEventTimestamp = 0;
    int32_t mNumOfIterations = 0;

+2 −2
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ class LinearFakeValueGenerator : public FakeValueGenerator {
    // int64Values[0]: interval
    // {@code propId} must be INT32 or INT64 or FLOAT type.
    explicit LinearFakeValueGenerator(
            const ::aidl::android::hardware::automotive::vehicle::VehiclePropValue& request);
            const aidl::android::hardware::automotive::vehicle::VehiclePropValue& request);
    // A linear value generator in range [middleValue - dispersion, middleValue + dispersion),
    // starts at 'currentValue' and at each 'interval', increase by 'increment' and loop back if
    // exceeds middleValue + dispersion. {@code propId} must be INT32 or INT64 or FLOAT type.
@@ -43,7 +43,7 @@ class LinearFakeValueGenerator : public FakeValueGenerator {
                                      float dispersion, float increment, int64_t interval);
    ~LinearFakeValueGenerator() = default;

    std::optional<::aidl::android::hardware::automotive::vehicle::VehiclePropValue> nextEvent()
    std::optional<aidl::android::hardware::automotive::vehicle::VehiclePropValue> nextEvent()
            override;

  private:
+30 −30
Original line number Diff line number Diff line
@@ -46,30 +46,30 @@ class FakeVehicleHardware : public IVehicleHardware {
    explicit FakeVehicleHardware(std::unique_ptr<VehiclePropValuePool> valuePool);

    // Get all the property configs.
    std::vector<::aidl::android::hardware::automotive::vehicle::VehiclePropConfig>
    std::vector<aidl::android::hardware::automotive::vehicle::VehiclePropConfig>
    getAllPropertyConfigs() const override;

    // Set property values asynchronously. Server could return before the property set requests
    // are sent to vehicle bus or before property set confirmation is received. The callback is
    // safe to be called after the function returns and is safe to be called in a different thread.
    ::aidl::android::hardware::automotive::vehicle::StatusCode setValues(
    aidl::android::hardware::automotive::vehicle::StatusCode setValues(
            std::shared_ptr<const SetValuesCallback> callback,
            const std::vector<::aidl::android::hardware::automotive::vehicle::SetValueRequest>&
            const std::vector<aidl::android::hardware::automotive::vehicle::SetValueRequest>&
                    requests) override;

    // Get property values asynchronously. Server could return before the property values are ready.
    // The callback is safe to be called after the function returns and is safe to be called in a
    // different thread.
    ::aidl::android::hardware::automotive::vehicle::StatusCode getValues(
    aidl::android::hardware::automotive::vehicle::StatusCode getValues(
            std::shared_ptr<const GetValuesCallback> callback,
            const std::vector<::aidl::android::hardware::automotive::vehicle::GetValueRequest>&
            const std::vector<aidl::android::hardware::automotive::vehicle::GetValueRequest>&
                    requests) const override;

    // Dump debug information in the server.
    DumpResult dump(const std::vector<std::string>& options) override;

    // Check whether the system is healthy, return {@code StatusCode::OK} for healthy.
    ::aidl::android::hardware::automotive::vehicle::StatusCode checkHealth() override;
    aidl::android::hardware::automotive::vehicle::StatusCode checkHealth() override;

    // Register a callback that would be called when there is a property change event from vehicle.
    void registerOnPropertyChangeEvent(
@@ -85,11 +85,11 @@ class FakeVehicleHardware : public IVehicleHardware {
    const std::shared_ptr<VehiclePropValuePool> mValuePool;
    const std::shared_ptr<VehiclePropertyStore> mServerSidePropStore;

    ::android::base::Result<VehiclePropValuePool::RecyclableType> getValue(
            const ::aidl::android::hardware::automotive::vehicle::VehiclePropValue& value) const;
    android::base::Result<VehiclePropValuePool::RecyclableType> getValue(
            const aidl::android::hardware::automotive::vehicle::VehiclePropValue& value) const;

    ::android::base::Result<void> setValue(
            const ::aidl::android::hardware::automotive::vehicle::VehiclePropValue& value);
    android::base::Result<void> setValue(
            const aidl::android::hardware::automotive::vehicle::VehiclePropValue& value);

  private:
    // Expose private methods to unit test.
@@ -108,33 +108,33 @@ class FakeVehicleHardware : public IVehicleHardware {
    void storePropInitialValue(const defaultconfig::ConfigDeclaration& config);
    // The callback that would be called when a vehicle property value change happens.
    void onValueChangeCallback(
            const ::aidl::android::hardware::automotive::vehicle::VehiclePropValue& value);
            const aidl::android::hardware::automotive::vehicle::VehiclePropValue& value);
    // If property "persist.vendor.vhal_init_value_override" is set to true, override the properties
    // using config files in 'overrideDir'.
    void maybeOverrideProperties(const char* overrideDir);
    // Override the properties using config files in 'overrideDir'.
    void overrideProperties(const char* overrideDir);

    ::android::base::Result<void> maybeSetSpecialValue(
            const ::aidl::android::hardware::automotive::vehicle::VehiclePropValue& value,
    android::base::Result<void> maybeSetSpecialValue(
            const aidl::android::hardware::automotive::vehicle::VehiclePropValue& value,
            bool* isSpecialValue);
    ::android::base::Result<VehiclePropValuePool::RecyclableType> maybeGetSpecialValue(
            const ::aidl::android::hardware::automotive::vehicle::VehiclePropValue& value,
    android::base::Result<VehiclePropValuePool::RecyclableType> maybeGetSpecialValue(
            const aidl::android::hardware::automotive::vehicle::VehiclePropValue& value,
            bool* isSpecialValue) const;
    ::android::base::Result<void> setApPowerStateReport(
            const ::aidl::android::hardware::automotive::vehicle::VehiclePropValue& value);
    android::base::Result<void> setApPowerStateReport(
            const aidl::android::hardware::automotive::vehicle::VehiclePropValue& value);
    VehiclePropValuePool::RecyclableType createApPowerStateReq(
            ::aidl::android::hardware::automotive::vehicle::VehicleApPowerStateReq state);
    ::android::base::Result<void> setUserHalProp(
            const ::aidl::android::hardware::automotive::vehicle::VehiclePropValue& value);
    ::android::base::Result<VehiclePropValuePool::RecyclableType> getUserHalProp(
            const ::aidl::android::hardware::automotive::vehicle::VehiclePropValue& value) const;
            aidl::android::hardware::automotive::vehicle::VehicleApPowerStateReq state);
    android::base::Result<void> setUserHalProp(
            const aidl::android::hardware::automotive::vehicle::VehiclePropValue& value);
    android::base::Result<VehiclePropValuePool::RecyclableType> getUserHalProp(
            const aidl::android::hardware::automotive::vehicle::VehiclePropValue& value) const;
    bool isHvacPropAndHvacNotAvailable(int32_t propId);

    std::string dumpAllProperties();
    std::string dumpOnePropertyByConfig(
            int rowNumber,
            const ::aidl::android::hardware::automotive::vehicle::VehiclePropConfig& config);
            const aidl::android::hardware::automotive::vehicle::VehiclePropConfig& config);
    std::string dumpOnePropertyById(int32_t propId, int32_t areaId);
    std::string dumpHelp();
    std::string dumpListProperties();
@@ -142,22 +142,22 @@ class FakeVehicleHardware : public IVehicleHardware {
    std::string dumpSetProperties(const std::vector<std::string>& options);

    template <typename T>
    ::android::base::Result<T> safelyParseInt(int index, const std::string& s) {
    android::base::Result<T> safelyParseInt(int index, const std::string& s) {
        T out;
        if (!::android::base::ParseInt(s, &out)) {
            return ::android::base::Error() << ::android::base::StringPrintf(
            return android::base::Error() << android::base::StringPrintf(
                           "non-integer argument at index %d: %s\n", index, s.c_str());
        }
        return out;
    }
    ::android::base::Result<float> safelyParseFloat(int index, const std::string& s);
    android::base::Result<float> safelyParseFloat(int index, const std::string& s);
    std::vector<std::string> getOptionValues(const std::vector<std::string>& options,
                                             size_t* index);
    ::android::base::Result<::aidl::android::hardware::automotive::vehicle::VehiclePropValue>
    android::base::Result<aidl::android::hardware::automotive::vehicle::VehiclePropValue>
    parseSetPropOptions(const std::vector<std::string>& options);
    ::android::base::Result<std::vector<uint8_t>> parseHexString(const std::string& s);
    android::base::Result<std::vector<uint8_t>> parseHexString(const std::string& s);

    ::android::base::Result<void> checkArgumentsSize(const std::vector<std::string>& options,
    android::base::Result<void> checkArgumentsSize(const std::vector<std::string>& options,
                                                   size_t minSize);
};

Loading