1/*
2 * Copyright (C) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#include "stub.h"
17
18#include <cstddef>
19#include <cstdint>
20#include "iosfwd"
21#include "string"
22#include "stub/a2dp_data_service.h"
23#include "stub/map_service.h"
24#include "stub/media_service.h"
25#include "stub/message_digest.h"
26#include "stub/telephone_client_service.h"
27#include "stub/telephone_service.h"
28#include "vector"
29
30namespace stub {
31class MD5 : public MessageDigest {
32public:
33    static constexpr size_t MD5_LENGTH = 16;
34
35    static MD5 &GetInstance();
36    virtual std::vector<uint8_t> Digest(const uint8_t *input, const size_t length) override;
37
38private:
39    MD5() = default;
40    ~MD5() = default;
41};
42
43MD5 &MD5::GetInstance()
44{
45    static MD5 instance;
46    return instance;
47}
48
49std::vector<uint8_t> MD5::Digest(const uint8_t *input, const size_t length)
50{
51    std::vector<uint8_t> digest(MD5_LENGTH, 0);
52    return digest;
53}
54
55MessageDigest *MessageDigestFactory::GetInstance(const std::string &type)
56{
57    if (type.compare(DIGEST_TYPE_MD5) == 0) {
58        return &MD5::GetInstance();
59    } else {
60        return nullptr;
61    }
62}
63
64MapService *MapService::GetInstance()
65{
66    static MapService instance;
67    return &instance;
68}
69
70MediaService *MediaService::GetInstance()
71{
72    static MediaService instance;
73    return &instance;
74}
75
76TelePhoneClientService &TelePhoneClientService::GetInstance()
77{
78    static TelePhoneClientService instance;
79    return instance;
80}
81
82TelephoneService *TelephoneService::GetInstance()
83{
84    static TelephoneService instance;
85    return &instance;
86}
87
88A2dpService *A2dpService::GetInstance()
89{
90    static A2dpService instance;
91    return &instance;
92}
93} // namespace stub