1 /* 2 * Copyright (c) 2021-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 #ifndef FOUNDATION_ACE_FRAMEWORKS_BRIDGE_CARD_FRONTEND_MEDIA_QUERYER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_BRIDGE_CARD_FRONTEND_MEDIA_QUERYER_H 18 19 #include <string> 20 #include <unordered_map> 21 22 #include "base/json/json_util.h" 23 #include "base/utils/resource_configuration.h" 24 25 namespace OHOS::Ace::Framework { 26 27 using MediaFeature = std::unique_ptr<JsonValue>; 28 29 class ACE_FORCE_EXPORT MediaQueryer { 30 public: 31 bool MatchCondition(const std::string& condition, const MediaFeature& mediaFeature); 32 std::unique_ptr<JsonValue> GetMediaFeature() const; SetColorMode(ColorMode colorMode)33 void SetColorMode(ColorMode colorMode) 34 { 35 colorMode_ = colorMode; 36 } 37 SetSurfaceSize(int32_t width,int32_t height)38 void SetSurfaceSize(int32_t width, int32_t height) 39 { 40 width_ = width; 41 height_ = height; 42 } 43 44 private: 45 struct QueryHistory { 46 std::string mediaFeatureValue; 47 bool result = false; 48 }; 49 std::unordered_map<std::string, QueryHistory> queryHistories; 50 int32_t width_ = 0; 51 int32_t height_ = 0; 52 ColorMode colorMode_ = ColorMode::LIGHT; 53 54 }; 55 56 } // namespace OHOS::Ace::Framework 57 58 #endif // FOUNDATION_ACE_FRAMEWORKS_BRIDGE_CARD_FRONTEND_MEDIA_QUERYER_H 59