• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 <iostream>
17 
18 #include "dm_common.h"
19 #include "screen_manager.h"
20 #include "setresolution_utils.h"
21 
22 using namespace OHOS;
23 using namespace OHOS::Rosen;
24 
main(int argc,char * argv[])25 int main(int argc, char *argv[])
26 {
27     CmdArgments cmdArgments;
28 
29     if (!SetResolutionUtils::ProcessArgs(argc, argv, cmdArgments)) {
30         return 0;
31     }
32     if (!cmdArgments.isWidthSet || !cmdArgments.isHeightSet || !cmdArgments.isDpiSet) {
33         std::cout << "Error! Must set width, height and dpi." << std::endl;
34         return 0;
35     }
36     std::cout << "width: " << cmdArgments.width << " height: " << cmdArgments.height <<
37         " dpi: " << cmdArgments.dpi << std::endl;
38 
39     std::vector<sptr<Rosen::Screen>> screens;
40     Rosen::ScreenManager::GetInstance().GetAllScreens(screens);
41     if (screens.size() == 0) {
42         return 0;
43     }
44     DMError ret = screens[0]->SetResolution(cmdArgments.width, cmdArgments.height, cmdArgments.dpi);
45     if (ret != DMError::DM_OK) {
46         std::cout<< "Error! SetResolution failed!" << std::endl;
47         return 0;
48     }
49     std::cout<< "SetResolution successful!" << std::endl;
50     return 0;
51 }