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

Commit 55ef412b authored by Kevin DuBois's avatar Kevin DuBois Committed by Android (Google) Code Review
Browse files

Merge changes Ie8fe724d,Ifd42f31d

* changes:
  SF: clean up casting around histogram reporting
  binder: add read/writeUint64Vector functions
parents d7cec95b 1d4c6a66
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -878,6 +878,16 @@ status_t Parcel::writeInt64Vector(const std::unique_ptr<std::vector<int64_t>>& v
    return writeNullableTypedVector(val, &Parcel::writeInt64);
}

status_t Parcel::writeUint64Vector(const std::vector<uint64_t>& val)
{
    return writeTypedVector(val, &Parcel::writeUint64);
}

status_t Parcel::writeUint64Vector(const std::unique_ptr<std::vector<uint64_t>>& val)
{
    return writeNullableTypedVector(val, &Parcel::writeUint64);
}

status_t Parcel::writeFloatVector(const std::vector<float>& val)
{
    return writeTypedVector(val, &Parcel::writeFloat);
@@ -1739,6 +1749,14 @@ status_t Parcel::readInt64Vector(std::vector<int64_t>* val) const {
    return readTypedVector(val, &Parcel::readInt64);
}

status_t Parcel::readUint64Vector(std::unique_ptr<std::vector<uint64_t>>* val) const {
    return readNullableTypedVector(val, &Parcel::readUint64);
}

status_t Parcel::readUint64Vector(std::vector<uint64_t>* val) const {
    return readTypedVector(val, &Parcel::readUint64);
}

status_t Parcel::readFloatVector(std::unique_ptr<std::vector<float>>* val) const {
    return readNullableTypedVector(val, &Parcel::readFloat);
}
+4 −0
Original line number Diff line number Diff line
@@ -139,6 +139,8 @@ public:
    status_t            writeInt32Vector(const std::vector<int32_t>& val);
    status_t            writeInt64Vector(const std::unique_ptr<std::vector<int64_t>>& val);
    status_t            writeInt64Vector(const std::vector<int64_t>& val);
    status_t            writeUint64Vector(const std::unique_ptr<std::vector<uint64_t>>& val);
    status_t            writeUint64Vector(const std::vector<uint64_t>& val);
    status_t            writeFloatVector(const std::unique_ptr<std::vector<float>>& val);
    status_t            writeFloatVector(const std::vector<float>& val);
    status_t            writeDoubleVector(const std::unique_ptr<std::vector<double>>& val);
@@ -313,6 +315,8 @@ public:
    status_t            readInt32Vector(std::vector<int32_t>* val) const;
    status_t            readInt64Vector(std::unique_ptr<std::vector<int64_t>>* val) const;
    status_t            readInt64Vector(std::vector<int64_t>* val) const;
    status_t            readUint64Vector(std::unique_ptr<std::vector<uint64_t>>* val) const;
    status_t            readUint64Vector(std::vector<uint64_t>* val) const;
    status_t            readFloatVector(std::unique_ptr<std::vector<float>>* val) const;
    status_t            readFloatVector(std::vector<float>* val) const;
    status_t            readDoubleVector(std::unique_ptr<std::vector<double>>* val) const;
+24 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ enum BinderLibTestTranscationCode {
    BINDER_LIB_TEST_GET_PTR_SIZE_TRANSACTION,
    BINDER_LIB_TEST_CREATE_BINDER_TRANSACTION,
    BINDER_LIB_TEST_GET_WORK_SOURCE_TRANSACTION,
    BINDER_LIB_TEST_ECHO_VECTOR,
};

pid_t start_server_process(int arg2, bool usePoll = false)
@@ -1060,6 +1061,21 @@ TEST_F(BinderLibTest, WorkSourcePropagatedForAllFollowingBinderCalls)
    EXPECT_EQ(NO_ERROR, ret2);
}

TEST_F(BinderLibTest, VectorSent) {
    Parcel data, reply;
    sp<IBinder> server = addServer();
    ASSERT_TRUE(server != nullptr);

    std::vector<uint64_t> const testValue = { std::numeric_limits<uint64_t>::max(), 0, 200 };
    data.writeUint64Vector(testValue);

    status_t ret = server->transact(BINDER_LIB_TEST_ECHO_VECTOR, data, &reply);
    EXPECT_EQ(NO_ERROR, ret);
    std::vector<uint64_t> readValue;
    ret = reply.readUint64Vector(&readValue);
    EXPECT_EQ(readValue, testValue);
}

class BinderLibTestService : public BBinder
{
    public:
@@ -1363,6 +1379,14 @@ class BinderLibTestService : public BBinder
                reply->writeInt32(IPCThreadState::self()->getCallingWorkSourceUid());
                return NO_ERROR;
            }
            case BINDER_LIB_TEST_ECHO_VECTOR: {
                std::vector<uint64_t> vector;
                auto err = data.readUint64Vector(&vector);
                if (err != NO_ERROR)
                    return err;
                reply->writeUint64Vector(vector);
                return NO_ERROR;
            }
            default:
                return UNKNOWN_TRANSACTION;
            };
+8 −16
Original line number Diff line number Diff line
@@ -675,23 +675,19 @@ public:
            return result;
        }

        result = reply.readInt64Vector(
                reinterpret_cast<std::vector<int64_t>*>(&outStats->component_0_sample));
        result = reply.readUint64Vector(&outStats->component_0_sample);
        if (result != NO_ERROR) {
            return result;
        }
        result = reply.readInt64Vector(
                reinterpret_cast<std::vector<int64_t>*>(&outStats->component_1_sample));
        result = reply.readUint64Vector(&outStats->component_1_sample);
        if (result != NO_ERROR) {
            return result;
        }
        result = reply.readInt64Vector(
                reinterpret_cast<std::vector<int64_t>*>(&outStats->component_2_sample));
        result = reply.readUint64Vector(&outStats->component_2_sample);
        if (result != NO_ERROR) {
            return result;
        }
        result = reply.readInt64Vector(
                reinterpret_cast<std::vector<int64_t>*>(&outStats->component_3_sample));
        result = reply.readUint64Vector(&outStats->component_3_sample);
        return result;
    }
};
@@ -1121,14 +1117,10 @@ status_t BnSurfaceComposer::onTransact(
            result = getDisplayedContentSample(display, maxFrames, timestamp, &stats);
            if (result == NO_ERROR) {
                reply->writeUint64(stats.numFrames);
                reply->writeInt64Vector(
                        *reinterpret_cast<std::vector<int64_t>*>(&stats.component_0_sample));
                reply->writeInt64Vector(
                        *reinterpret_cast<std::vector<int64_t>*>(&stats.component_1_sample));
                reply->writeInt64Vector(
                        *reinterpret_cast<std::vector<int64_t>*>(&stats.component_2_sample));
                reply->writeInt64Vector(
                        *reinterpret_cast<std::vector<int64_t>*>(&stats.component_3_sample));
                reply->writeUint64Vector(stats.component_0_sample);
                reply->writeUint64Vector(stats.component_1_sample);
                reply->writeUint64Vector(stats.component_2_sample);
                reply->writeUint64Vector(stats.component_3_sample);
            }
            return result;
        }