1686862fbSopenharmony_ci/*
2686862fbSopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
3686862fbSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4686862fbSopenharmony_ci * you may not use this file except in compliance with the License.
5686862fbSopenharmony_ci * You may obtain a copy of the License at
6686862fbSopenharmony_ci *
7686862fbSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8686862fbSopenharmony_ci *
9686862fbSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10686862fbSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11686862fbSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12686862fbSopenharmony_ci * See the License for the specific language governing permissions and
13686862fbSopenharmony_ci * limitations under the License.
14686862fbSopenharmony_ci */
15686862fbSopenharmony_ci
16686862fbSopenharmony_ci#include "mission/snapshot_converter.h"
17686862fbSopenharmony_ci
18686862fbSopenharmony_ci#include "dtbschedmgr_log.h"
19686862fbSopenharmony_ci
20686862fbSopenharmony_cinamespace OHOS {
21686862fbSopenharmony_cinamespace DistributedSchedule {
22686862fbSopenharmony_cinamespace {
23686862fbSopenharmony_ciconst std::string TAG = "SnapshotConverter";
24686862fbSopenharmony_ciconstexpr int32_t DMS_VERSION = 200;
25686862fbSopenharmony_ci}
26686862fbSopenharmony_ci
27686862fbSopenharmony_ciint32_t SnapshotConverter::ConvertToSnapshot(AAFwk::MissionSnapshot& missionSnapshot, Snapshot& snapshot)
28686862fbSopenharmony_ci{
29686862fbSopenharmony_ci    snapshot.version_ = DMS_VERSION;
30686862fbSopenharmony_ci    snapshot.orientation_ = 0;
31686862fbSopenharmony_ci    std::unique_ptr<Rect> contentInsets = std::make_unique<Rect>(0, 0, 0, 0);
32686862fbSopenharmony_ci    snapshot.rect_ = std::move(contentInsets);
33686862fbSopenharmony_ci    snapshot.reducedResolution_ = true;
34686862fbSopenharmony_ci    snapshot.scale_ = 0.0;
35686862fbSopenharmony_ci    snapshot.isRealSnapshot_ = true;
36686862fbSopenharmony_ci    snapshot.windowingMode_ = 0;
37686862fbSopenharmony_ci    snapshot.systemUiVisibility_ = 0;
38686862fbSopenharmony_ci    snapshot.isTranslucent_ = true;
39686862fbSopenharmony_ci    std::unique_ptr<Rect> windowBounds = std::make_unique<Rect>(0, 0, 0, 0);
40686862fbSopenharmony_ci    snapshot.windowBounds_ = std::move(windowBounds);
41686862fbSopenharmony_ci    std::u16string appLabel;
42686862fbSopenharmony_ci    snapshot.appLabel_ = appLabel;
43686862fbSopenharmony_ci    std::u16string abilityLabel;
44686862fbSopenharmony_ci    snapshot.abilityLabel_ = abilityLabel;
45686862fbSopenharmony_ci    std::vector<uint8_t> icon;
46686862fbSopenharmony_ci    snapshot.icon_ = icon;
47686862fbSopenharmony_ci    std::u16string secAppLabel;
48686862fbSopenharmony_ci    snapshot.secAppLabel_ = secAppLabel;
49686862fbSopenharmony_ci    std::u16string secAbilityLabel;
50686862fbSopenharmony_ci    snapshot.secAbilityLabel_ = secAbilityLabel;
51686862fbSopenharmony_ci    std::vector<uint8_t> secIcon;
52686862fbSopenharmony_ci    snapshot.secIcon_ = secIcon;
53686862fbSopenharmony_ci    std::u16string sourceDeviceTips;
54686862fbSopenharmony_ci    snapshot.sourceDeviceTips_ = sourceDeviceTips;
55686862fbSopenharmony_ci    snapshot.pixelMap_ = missionSnapshot.snapshot;
56686862fbSopenharmony_ci    return ERR_OK;
57686862fbSopenharmony_ci}
58686862fbSopenharmony_ci
59686862fbSopenharmony_ciint32_t SnapshotConverter::ConvertToSnapshot(AAFwk::MissionSnapshot& missionSnapshot,
60686862fbSopenharmony_ci    std::unique_ptr<Snapshot>& snapshot)
61686862fbSopenharmony_ci{
62686862fbSopenharmony_ci    if (snapshot == nullptr) {
63686862fbSopenharmony_ci        return INVALID_PARAMETERS_ERR;
64686862fbSopenharmony_ci    }
65686862fbSopenharmony_ci    snapshot->version_ = DMS_VERSION;
66686862fbSopenharmony_ci    snapshot->orientation_ = 0;
67686862fbSopenharmony_ci    std::unique_ptr<Rect> contentInsets = std::make_unique<Rect>(0, 0, 0, 0);
68686862fbSopenharmony_ci    snapshot->rect_ = std::move(contentInsets);
69686862fbSopenharmony_ci    snapshot->reducedResolution_ = true;
70686862fbSopenharmony_ci    snapshot->scale_ = 0.0;
71686862fbSopenharmony_ci    snapshot->isRealSnapshot_ = true;
72686862fbSopenharmony_ci    snapshot->windowingMode_ = 0;
73686862fbSopenharmony_ci    snapshot->systemUiVisibility_ = 0;
74686862fbSopenharmony_ci    snapshot->isTranslucent_ = true;
75686862fbSopenharmony_ci    std::unique_ptr<Rect> windowBounds = std::make_unique<Rect>(0, 0, 0, 0);
76686862fbSopenharmony_ci    snapshot->windowBounds_ = std::move(windowBounds);
77686862fbSopenharmony_ci    std::u16string appLabel;
78686862fbSopenharmony_ci    snapshot->appLabel_ = appLabel;
79686862fbSopenharmony_ci    std::u16string abilityLabel;
80686862fbSopenharmony_ci    snapshot->abilityLabel_ = abilityLabel;
81686862fbSopenharmony_ci    std::vector<uint8_t> icon;
82686862fbSopenharmony_ci    snapshot->icon_ = icon;
83686862fbSopenharmony_ci    std::u16string secAppLabel;
84686862fbSopenharmony_ci    snapshot->secAppLabel_ = secAppLabel;
85686862fbSopenharmony_ci    std::u16string secAbilityLabel;
86686862fbSopenharmony_ci    snapshot->secAbilityLabel_ = secAbilityLabel;
87686862fbSopenharmony_ci    std::vector<uint8_t> secIcon;
88686862fbSopenharmony_ci    snapshot->secIcon_ = secIcon;
89686862fbSopenharmony_ci    std::u16string sourceDeviceTips;
90686862fbSopenharmony_ci    snapshot->sourceDeviceTips_ = sourceDeviceTips;
91686862fbSopenharmony_ci    snapshot->pixelMap_ = missionSnapshot.snapshot;
92686862fbSopenharmony_ci    return ERR_OK;
93686862fbSopenharmony_ci}
94686862fbSopenharmony_ci
95686862fbSopenharmony_ciint32_t SnapshotConverter::ConvertToMissionSnapshot(Snapshot& snapshot,
96686862fbSopenharmony_ci    std::unique_ptr<AAFwk::MissionSnapshot>& missionSnapshot)
97686862fbSopenharmony_ci{
98686862fbSopenharmony_ci    if (missionSnapshot != nullptr) {
99686862fbSopenharmony_ci        missionSnapshot->snapshot = snapshot.pixelMap_;
100686862fbSopenharmony_ci    }
101686862fbSopenharmony_ci    return ERR_OK;
102686862fbSopenharmony_ci}
103686862fbSopenharmony_ci} // namespace DistributedSchedule
104686862fbSopenharmony_ci} // namespace OHOS
105