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

Commit 95e4fe64 authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

Move UUID conversions into their own class

Mechanical extraction of HidlUtils::uuidFrom/ToHal into
a dedicated class UuidUtils.

Bug: 142480271
Test: m
Change-Id: Ic5333ba32dc293f32c5562d0ef05bde8e5f9b302
parent ba59ee15
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ cc_defaults {
    vendor_available: true,
    srcs: [
        "HidlUtils.cpp",
        "UuidUtils.cpp",
    ],

    export_include_dirs: ["."],
+0 −16
Original line number Diff line number Diff line
@@ -358,22 +358,6 @@ void HidlUtils::audioPortToHal(const AudioPort& port, struct audio_port* halPort
    }
}

void HidlUtils::uuidFromHal(const audio_uuid_t& halUuid, Uuid* uuid) {
    uuid->timeLow = halUuid.timeLow;
    uuid->timeMid = halUuid.timeMid;
    uuid->versionAndTimeHigh = halUuid.timeHiAndVersion;
    uuid->variantAndClockSeqHigh = halUuid.clockSeq;
    memcpy(uuid->node.data(), halUuid.node, uuid->node.size());
}

void HidlUtils::uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid) {
    halUuid->timeLow = uuid.timeLow;
    halUuid->timeMid = uuid.timeMid;
    halUuid->timeHiAndVersion = uuid.versionAndTimeHigh;
    halUuid->clockSeq = uuid.variantAndClockSeqHigh;
    memcpy(halUuid->node, uuid.node.data(), uuid.node.size());
}

}  // namespace implementation
}  // namespace CPP_VERSION
}  // namespace common
+0 −2
Original line number Diff line number Diff line
@@ -66,8 +66,6 @@ class HidlUtils {
            const hidl_vec<AudioPortConfig>& configs);
    static void audioPortFromHal(const struct audio_port& halPort, AudioPort* port);
    static void audioPortToHal(const AudioPort& port, struct audio_port* halPort);
    static void uuidFromHal(const audio_uuid_t& halUuid, Uuid* uuid);
    static void uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid);
};

}  // namespace implementation
+50 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 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 "UuidUtils.h"

#include <common/all-versions/VersionUtils.h>
#include <string.h>

namespace android {
namespace hardware {
namespace audio {
namespace common {
namespace CPP_VERSION {
namespace implementation {

void UuidUtils::uuidFromHal(const audio_uuid_t& halUuid, Uuid* uuid) {
    uuid->timeLow = halUuid.timeLow;
    uuid->timeMid = halUuid.timeMid;
    uuid->versionAndTimeHigh = halUuid.timeHiAndVersion;
    uuid->variantAndClockSeqHigh = halUuid.clockSeq;
    memcpy(uuid->node.data(), halUuid.node, uuid->node.size());
}

void UuidUtils::uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid) {
    halUuid->timeLow = uuid.timeLow;
    halUuid->timeMid = uuid.timeMid;
    halUuid->timeHiAndVersion = uuid.versionAndTimeHigh;
    halUuid->clockSeq = uuid.variantAndClockSeqHigh;
    memcpy(halUuid->node, uuid.node.data(), uuid.node.size());
}

}  // namespace implementation
}  // namespace CPP_VERSION
}  // namespace common
}  // namespace audio
}  // namespace hardware
}  // namespace android
+50 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 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.
 */

#ifndef android_hardware_audio_Uuid_Utils_H_
#define android_hardware_audio_Uuid_Utils_H_

// clang-format off
#include PATH(android/hardware/audio/common/FILE_VERSION/types.h)
// clang-format on

#include <system/audio.h>

using ::android::hardware::hidl_vec;

namespace android {
namespace hardware {
namespace audio {
namespace common {
namespace CPP_VERSION {
namespace implementation {

using namespace ::android::hardware::audio::common::CPP_VERSION;

class UuidUtils {
  public:
    static void uuidFromHal(const audio_uuid_t& halUuid, Uuid* uuid);
    static void uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid);
};

}  // namespace implementation
}  // namespace CPP_VERSION
}  // namespace common
}  // namespace audio
}  // namespace hardware
}  // namespace android

#endif  // android_hardware_audio_Uuid_Utils_H_
Loading