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 <iostream> 17 #include <refbase.h> 18 #include "virtual_screen_group_change_listener_future.h" 19 20 using namespace OHOS; 21 using namespace OHOS::Rosen; 22 main(int argc,char * argv[])23int main(int argc, char *argv[]) 24 { 25 std::cout << "===========================Start===========================" << std::endl; 26 std::cout << "Please do screen mirror in 20s..." << std::endl; 27 28 sptr<VirtualScreenGroupChangeListenerFuture> listener = new VirtualScreenGroupChangeListenerFuture(); 29 auto& sm = ScreenManager::GetInstance(); 30 sm.RegisterVirtualScreenGroupListener(listener); 31 auto info = listener->mirrorChangeFuture_.GetResult(20000); 32 33 std::cout << "mirror event=" << std::to_string(static_cast<int>(info.event)) 34 << ", trigger=" << info.trigger << std::endl; 35 std::cout << "ids.size=" << std::to_string(info.ids.size()) << ", "; 36 for (size_t i = 0; i < info.ids.size(); i++) { 37 std::cout << "ids[" << std::to_string(i) << "]=" << std::to_string(info.ids[i]); 38 } 39 std::cout << std::endl; 40 41 sm.UnregisterVirtualScreenGroupListener(listener); 42 43 std::cout << "============================End============================" << std::endl; 44 return 0; 45 }