1 /*
2 * Copyright (c) 2022 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 "mission/snapshot_converter.h"
17
18 #include "dtbschedmgr_log.h"
19
20 namespace OHOS {
21 namespace DistributedSchedule {
22 namespace {
23 const std::string TAG = "SnapshotConverter";
24 constexpr int32_t DMS_VERSION = 200;
25 }
26
ConvertToSnapshot(AAFwk::MissionSnapshot & missionSnapshot,Snapshot & snapshot)27 int32_t SnapshotConverter::ConvertToSnapshot(AAFwk::MissionSnapshot& missionSnapshot, Snapshot& snapshot)
28 {
29 snapshot.version_ = DMS_VERSION;
30 snapshot.orientation_ = 0;
31 std::unique_ptr<Rect> contentInsets = std::make_unique<Rect>(0, 0, 0, 0);
32 snapshot.rect_ = std::move(contentInsets);
33 snapshot.reducedResolution_ = true;
34 snapshot.scale_ = 0.0;
35 snapshot.isRealSnapshot_ = true;
36 snapshot.windowingMode_ = 0;
37 snapshot.systemUiVisibility_ = 0;
38 snapshot.isTranslucent_ = true;
39 std::unique_ptr<Rect> windowBounds = std::make_unique<Rect>(0, 0, 0, 0);
40 snapshot.windowBounds_ = std::move(windowBounds);
41 std::u16string appLabel;
42 snapshot.appLabel_ = appLabel;
43 std::u16string abilityLabel;
44 snapshot.abilityLabel_ = abilityLabel;
45 std::vector<uint8_t> icon;
46 snapshot.icon_ = icon;
47 std::u16string secAppLabel;
48 snapshot.secAppLabel_ = secAppLabel;
49 std::u16string secAbilityLabel;
50 snapshot.secAbilityLabel_ = secAbilityLabel;
51 std::vector<uint8_t> secIcon;
52 snapshot.secIcon_ = secIcon;
53 std::u16string sourceDeviceTips;
54 snapshot.sourceDeviceTips_ = sourceDeviceTips;
55 snapshot.pixelMap_ = missionSnapshot.snapshot;
56 return ERR_OK;
57 }
58
ConvertToSnapshot(AAFwk::MissionSnapshot & missionSnapshot,std::unique_ptr<Snapshot> & snapshot)59 int32_t SnapshotConverter::ConvertToSnapshot(AAFwk::MissionSnapshot& missionSnapshot,
60 std::unique_ptr<Snapshot>& snapshot)
61 {
62 snapshot->version_ = DMS_VERSION;
63 snapshot->orientation_ = 0;
64 std::unique_ptr<Rect> contentInsets = std::make_unique<Rect>(0, 0, 0, 0);
65 snapshot->rect_ = std::move(contentInsets);
66 snapshot->reducedResolution_ = true;
67 snapshot->scale_ = 0.0;
68 snapshot->isRealSnapshot_ = true;
69 snapshot->windowingMode_ = 0;
70 snapshot->systemUiVisibility_ = 0;
71 snapshot->isTranslucent_ = true;
72 std::unique_ptr<Rect> windowBounds = std::make_unique<Rect>(0, 0, 0, 0);
73 snapshot->windowBounds_ = std::move(windowBounds);
74 std::u16string appLabel;
75 snapshot->appLabel_ = appLabel;
76 std::u16string abilityLabel;
77 snapshot->abilityLabel_ = abilityLabel;
78 std::vector<uint8_t> icon;
79 snapshot->icon_ = icon;
80 std::u16string secAppLabel;
81 snapshot->secAppLabel_ = secAppLabel;
82 std::u16string secAbilityLabel;
83 snapshot->secAbilityLabel_ = secAbilityLabel;
84 std::vector<uint8_t> secIcon;
85 snapshot->secIcon_ = secIcon;
86 std::u16string sourceDeviceTips;
87 snapshot->sourceDeviceTips_ = sourceDeviceTips;
88 snapshot->pixelMap_ = missionSnapshot.snapshot;
89 return ERR_OK;
90 }
91
ConvertToMissionSnapshot(Snapshot & snapshot,std::unique_ptr<AAFwk::MissionSnapshot> & missionSnapshot)92 int32_t SnapshotConverter::ConvertToMissionSnapshot(Snapshot& snapshot,
93 std::unique_ptr<AAFwk::MissionSnapshot>& missionSnapshot)
94 {
95 missionSnapshot->snapshot = snapshot.pixelMap_;
96 return ERR_OK;
97 }
98 }
99 }
100