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 #ifndef FOUNDATION_BUNDLEMANAGER_BUNDLE_FRAMEWORK_SERVICES_BUNDLEMGR_BUNDLE_RESOURCE_CALLBACK_H 17 #define FOUNDATION_BUNDLEMANAGER_BUNDLE_FRAMEWORK_SERVICES_BUNDLEMGR_BUNDLE_RESOURCE_CALLBACK_H 18 19 #include <mutex> 20 #include <string> 21 22 #include "bundle_resource_change_type.h" 23 24 namespace OHOS { 25 namespace AppExecFwk { 26 class BundleResourceCallback { 27 public: 28 BundleResourceCallback() = default; 29 30 ~BundleResourceCallback() = default; 31 32 // for userId switched 33 bool OnUserIdSwitched(const int32_t oldUserId, const int32_t newUserId, 34 const uint32_t type = static_cast<uint32_t>(BundleResourceChangeType::SYSTEM_USER_ID_CHANGE)); 35 36 // for colorMode changed 37 bool OnSystemColorModeChanged(const std::string &colorMode, 38 const uint32_t type = static_cast<uint32_t>(BundleResourceChangeType::SYSTEM_COLOR_MODE_CHANGE)); 39 40 // for system language changed 41 bool OnSystemLanguageChange(const std::string &language, 42 const uint32_t type = static_cast<uint32_t>(BundleResourceChangeType::SYSTEM_LANGUE_CHANGE)); 43 44 // for application theme changed 45 bool OnApplicationThemeChanged(const std::string &theme, const int32_t themeId = 0, const int32_t themeIcon = 0, 46 const uint32_t type = static_cast<uint32_t>(BundleResourceChangeType::SYSTEM_THEME_CHANGE)); 47 48 // for overlay 49 bool OnOverlayStatusChanged(const std::string &bundleName, bool isEnabled, int32_t userId); 50 51 private: 52 bool SetThemeParamForThemeChanged(const int32_t themeId, const int32_t themeIcon); 53 54 void SetUserId(const int32_t userId); 55 56 void SetConfigInFile(const std::string &language, const std::string &theme, 57 const int32_t id, const int32_t themeIcon, const uint32_t type, const int32_t userId); 58 59 void DeleteConfigInFile(const int32_t userId, const uint32_t type); 60 61 static std::mutex userFileMutex_; 62 }; 63 } // AppExecFwk 64 } // OHOS 65 #endif // FOUNDATION_BUNDLEMANAGER_BUNDLE_FRAMEWORK_SERVICES_BUNDLEMGR_BUNDLE_RESOURCE_CALLBACK_H 66