• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 OHOS_ABILITY_RUNTIME_MULTI_USER_CONFIG_MGR_H
17 #define OHOS_ABILITY_RUNTIME_MULTI_USER_CONFIG_MGR_H
18 
19 #include <map>
20 #include <mutex>
21 #include <memory>
22 
23 #include "configuration.h"
24 
25 namespace OHOS {
26 namespace AppExecFwk {
27 
28 class MultiUserConfigurationMgr {
29 public:
30     MultiUserConfigurationMgr();
31     std::shared_ptr<AppExecFwk::Configuration> GetConfigurationByUserId(const int32_t userId);
32     void InitConfiguration(std::shared_ptr<AppExecFwk::Configuration> config);
33     void HandleConfiguration(const int32_t userId, const Configuration& config, std::vector<std::string>& changeKeyV,
34         bool &isNotifyUser0);
35 
36 private:
37     void UpdateMultiUserConfiguration(const Configuration& config);
38     void UpdateMultiUserConfigurationForGlobal(const Configuration& globalConfig);
39     void SetOrUpdateConfigByUserId(const int32_t userId, const Configuration& config,
40         std::vector<std::string>& changeKeyV);
41 
42     std::map<int32_t, Configuration> multiUserConfiguration_;
43     std::mutex multiUserConfigurationMutex_;
44     std::shared_ptr<AppExecFwk::Configuration> globalConfiguration_;
45     static int32_t GetForegroundOsAccountLocalId();
46 };
47 } // namespace AppExecFwk
48 } // namespace OHOS
49 #endif  // OHOS_ABILITY_RUNTIME_MULTI_USER_CONFIG_MGR_H
50