• 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 #include "location_sa_load_manager.h"
17 
18 #include "common_utils.h"
19 #include "common_hisysevent.h"
20 #include "location_log_event_ids.h"
21 
22 namespace OHOS {
23 namespace Location {
24 
SaLoadWithStatistic()25 SaLoadWithStatistic::SaLoadWithStatistic()
26 {
27 }
28 
~SaLoadWithStatistic()29 SaLoadWithStatistic::~SaLoadWithStatistic()
30 {
31 }
32 
InitLocationSa(int32_t systemAbilityId)33 bool SaLoadWithStatistic::InitLocationSa(int32_t systemAbilityId)
34 {
35     if (LocationSaLoadManager::CheckIfSystemAbilityAvailable(systemAbilityId)) {
36         LBSLOGD(COMMON_UTILS, "sa has been loaded");
37         return true;
38     }
39     auto startTime = CommonUtils::GetCurrentTimeStamp();
40     bool ret = LocationSaLoadManager::InitLocationSa(systemAbilityId);
41     auto endTime = CommonUtils::GetCurrentTimeStamp();
42     WriteLocationInnerEvent(SA_LOAD, {"saId", std::to_string(systemAbilityId), "type", "load",
43         "ret", std::to_string(ret), "startTime", std::to_string(startTime), "endTime", std::to_string(endTime)});
44     return ret;
45 }
46 
UnInitLocationSa(int32_t systemAbilityId)47 bool SaLoadWithStatistic::UnInitLocationSa(int32_t systemAbilityId)
48 {
49     if (!LocationSaLoadManager::CheckIfSystemAbilityAvailable(systemAbilityId)) {
50         LBSLOGD(LOCATOR, "sa has been unloaded");
51         return true;
52     }
53     auto startTime = CommonUtils::GetCurrentTimeStamp();
54     bool ret = LocationSaLoadManager::UnInitLocationSa(systemAbilityId);
55     auto endTime = CommonUtils::GetCurrentTimeStamp();
56     WriteLocationInnerEvent(SA_LOAD, {"saId", std::to_string(systemAbilityId), "type", "unload",
57         "ret", std::to_string(ret), "startTime", std::to_string(startTime), "endTime", std::to_string(endTime)});
58     return ret;
59 }
60 }; // namespace Location
61 }; // namespace OHOS
62