• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 "reminder_agent_service_ability.h"
17 
18 namespace OHOS {
19 namespace Notification {
20 namespace {
21 constexpr int32_t REMINDER_AGENT_SERVICE_ID = 3204;
22 REGISTER_SYSTEM_ABILITY_BY_ID(ReminderAgentServiceAbility, REMINDER_AGENT_SERVICE_ID, false);
23 }
24 
25 const std::string EXTENSION_BACKUP = "backup";
26 const std::string EXTENSION_RESTORE = "restore";
27 constexpr int64_t INIT_DELAY_TIME = 60 * 1000 * 1000;
28 
ReminderAgentServiceAbility(const int32_t systemAbilityId,bool runOnCreate)29 ReminderAgentServiceAbility::ReminderAgentServiceAbility(const int32_t systemAbilityId, bool runOnCreate)
30     : SystemAbility(systemAbilityId, runOnCreate), service_(nullptr)
31 {}
32 
~ReminderAgentServiceAbility()33 ReminderAgentServiceAbility::~ReminderAgentServiceAbility()
34 {}
35 
OnStart()36 void ReminderAgentServiceAbility::OnStart()
37 {
38     if (service_ != nullptr) {
39         return;
40     }
41 
42     service_ = ReminderAgentService::GetInstance();
43     if (service_ == nullptr) {
44         return;
45     }
46     reminderDataManager_ = ReminderDataManager::InitInstance();
47     if (!Publish(service_)) {
48         return;
49     }
50     ReminderAgentService::GetInstance()->TryPostDelayUnloadTask(INIT_DELAY_TIME);
51 }
52 
OnStop()53 void ReminderAgentServiceAbility::OnStop()
54 {
55     service_ = nullptr;
56     reminderDataManager_ = nullptr;
57 }
58 
59 }  // namespace Notification
60 }  // namespace OHOS
61