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

Commit 73dcda7e authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes from topic "istats_repeated"

* changes:
  StatsAidl implementation for new repeated and nested field types
  IStats HAL: Updated AIDL to version 2
parents 483b58ef 5f5f5792
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -13,10 +13,13 @@ cc_library_shared {
        "StatsAidl.cpp",
        "StatsHal.cpp",
    ],
    cflags: ["-Wall", "-Werror"],
    cflags: [
        "-Wall",
        "-Werror",
    ],
    shared_libs: [
        "android.frameworks.stats@1.0",
        "android.frameworks.stats-V1-ndk",
        "android.frameworks.stats-V2-ndk",
        "libbinder_ndk",
        "libhidlbase",
        "liblog",
@@ -29,10 +32,12 @@ cc_library_shared {
    ],
    export_shared_lib_headers: [
        "android.frameworks.stats@1.0",
        "android.frameworks.stats-V1-ndk",
        "android.frameworks.stats-V2-ndk",
    ],
    local_include_dirs: [
        "include/stats",
    ],
    vintf_fragments: ["android.frameworks.stats@1.0-service.xml"]
    vintf_fragments: [
        "android.frameworks.stats-service.xml",
    ],
}
+59 −0
Original line number Diff line number Diff line
@@ -62,6 +62,65 @@ ndk::ScopedAStatus StatsHal::reportVendorAtom(const VendorAtom& vendorAtom) {
                AStatsEvent_writeString(event,
                    atomValue.get<VendorAtomValue::stringValue>().c_str());
                break;
            case VendorAtomValue::boolValue:
                AStatsEvent_writeBool(event,
                    atomValue.get<VendorAtomValue::boolValue>());
                break;
            case VendorAtomValue::repeatedIntValue: {
                const std::optional<std::vector<int>>& repeatedIntValue =
                        atomValue.get<VendorAtomValue::repeatedIntValue>();
                AStatsEvent_writeInt32Array(event, repeatedIntValue->data(),
                                            repeatedIntValue->size());
                break;
            }
            case VendorAtomValue::repeatedLongValue: {
                const std::optional<std::vector<int64_t>>& repeatedLongValue =
                        atomValue.get<VendorAtomValue::repeatedLongValue>();
                AStatsEvent_writeInt64Array(event, repeatedLongValue->data(),
                                            repeatedLongValue->size());
                break;
            }
            case VendorAtomValue::repeatedFloatValue: {
                const std::optional<std::vector<float>>& repeatedFloatValue =
                        atomValue.get<VendorAtomValue::repeatedFloatValue>();
                AStatsEvent_writeFloatArray(event, repeatedFloatValue->data(),
                                            repeatedFloatValue->size());
                break;
            }
            case VendorAtomValue::repeatedStringValue: {
                const std::optional<std::vector<std::optional<std::string>>>& repeatedStringValue =
                        atomValue.get<VendorAtomValue::repeatedStringValue>();
                const std::vector<std::optional<std::string>>& repeatedStringVector =
                        *repeatedStringValue;
                const char* cStringArray[repeatedStringVector.size()];

                for (int i = 0; i < repeatedStringVector.size(); ++i) {
                    cStringArray[i] = repeatedStringVector[i]->c_str();
                }

                AStatsEvent_writeStringArray(event, cStringArray, repeatedStringVector.size());
                break;
            }
            case VendorAtomValue::repeatedBoolValue: {
                const std::optional<std::vector<bool>>& repeatedBoolValue =
                        atomValue.get<VendorAtomValue::repeatedBoolValue>();
                const std::vector<bool>& repeatedBoolVector = *repeatedBoolValue;
                bool boolArray[repeatedBoolValue->size()];

                for (int i = 0; i < repeatedBoolVector.size(); ++i) {
                    boolArray[i] = repeatedBoolVector[i];
                }

                AStatsEvent_writeBoolArray(event, boolArray, repeatedBoolVector.size());
                break;
            }
            case VendorAtomValue::byteArrayValue: {
                const std::optional<std::vector<uint8_t>>& byteArrayValue =
                        atomValue.get<VendorAtomValue::byteArrayValue>();

                AStatsEvent_writeByteArray(event, byteArrayValue->data(), byteArrayValue->size());
                break;
            }
        }
    }
    AStatsEvent_build(event);
+1 −1
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@

    <hal format="aidl">
        <name>android.frameworks.stats</name>
        <version>1</version>
        <version>2</version>
        <fqname>IStats/default</fqname>
    </hal>
</manifest>