1 /*
2 * Copyright 2020, 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 #include <device_parameters.h>
18 #include <optional>
19
20 namespace devices {
21
22 using namespace teeui;
23
getDisplayCount()24 int getDisplayCount() {
25 return 1;
26 }
27
getDisplayContext(int display_index,bool magnified)28 std::optional<context<ConUIParameters>> getDisplayContext(int display_index,
29 bool magnified) {
30 if (display_index != 0) {
31 return std::nullopt;
32 }
33
34 context<ConUIParameters> ctx(6.45211, 400.0 / 412.0);
35
36 ctx.setParam<RightEdgeOfScreen>(400_px);
37 ctx.setParam<BottomOfScreen>(800_px);
38 ctx.setParam<PowerButtonTop>(20.26_mm);
39 ctx.setParam<PowerButtonBottom>(30.26_mm);
40 ctx.setParam<VolUpButtonTop>(40.26_mm);
41 ctx.setParam<VolUpButtonBottom>(50.26_mm);
42
43 if (magnified) {
44 ctx.setParam<DefaultFontSize>(18_dp);
45 ctx.setParam<BodyFontSize>(20_dp);
46 } else {
47 ctx.setParam<DefaultFontSize>(14_dp);
48 ctx.setParam<BodyFontSize>(16_dp);
49 }
50
51 return ctx;
52 }
53
getDisplayLayout(int display_index,bool inverted,const context<ConUIParameters> & ctx)54 std::optional<std::unique_ptr<layouts::ILayout>> getDisplayLayout(
55 int display_index,
56 bool inverted,
57 const context<ConUIParameters>& ctx) {
58 if (display_index != 0) {
59 return std::nullopt;
60 }
61
62 return std::make_unique<teeui::layouts::DisplayLayout>(inverted, ctx);
63 }
64
65 } // namespace devices
66