blob: 196f51b7fd5a462b551862fba79791d5515b1f6d [file] [log] [blame]
Jason Macnakb53b7902022-01-12 15:59:56 -08001/*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_HWC_DEVICE_H
18#define ANDROID_HWC_DEVICE_H
19
20#include <utils/Singleton.h>
21
22#include <memory>
23#include <thread>
24
25#include "Common.h"
26
27namespace aidl::android::hardware::graphics::composer3::impl {
28
29class FrameComposer;
30
31// Provides resources that are stable for the duration of the virtual
32// device.
33class Device : public ::android::Singleton<Device> {
Kaiyi Li32fc2c72024-01-24 09:17:13 -080034 public:
35 virtual ~Device() = default;
Jason Macnakb53b7902022-01-12 15:59:56 -080036
Kaiyi Li32fc2c72024-01-24 09:17:13 -080037 HWC3::Error getComposer(FrameComposer** outComposer);
Jason Macnakb53b7902022-01-12 15:59:56 -080038
Kaiyi Li7d3a6602024-01-23 16:24:23 -080039 bool persistentKeyValueEnabled() const;
40
Kaiyi Li32fc2c72024-01-24 09:17:13 -080041 HWC3::Error getPersistentKeyValue(const std::string& key, const std::string& defaultVal,
42 std::string* outValue);
Jason Macnakb53b7902022-01-12 15:59:56 -080043
Kaiyi Li32fc2c72024-01-24 09:17:13 -080044 HWC3::Error setPersistentKeyValue(const std::string& key, const std::string& outValue);
Jason Macnakb53b7902022-01-12 15:59:56 -080045
Kaiyi Li32fc2c72024-01-24 09:17:13 -080046 private:
47 friend class Singleton<Device>;
48 Device() = default;
Jason Macnakb53b7902022-01-12 15:59:56 -080049
Kaiyi Li32fc2c72024-01-24 09:17:13 -080050 std::mutex mMutex;
51 std::unique_ptr<FrameComposer> mComposer;
Jason Macnakb53b7902022-01-12 15:59:56 -080052};
53
54} // namespace aidl::android::hardware::graphics::composer3::impl
55
56#endif