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 "slite_ability.h" 17 #include "slite_ability_state.h" 18 #include "abilityms_slite_client.h" 19 #include "utils.h" 20 21 namespace OHOS { 22 namespace AbilitySlite { SliteAbility(const char * bundleName)23SliteAbility::SliteAbility(const char *bundleName) 24 { 25 bundleName_= OHOS::Utils::Strdup(bundleName); 26 } 27 ~SliteAbility()28SliteAbility::~SliteAbility() 29 { 30 AdapterFree(bundleName_); 31 } 32 OnCreate(const Want & want)33void SliteAbility::OnCreate(const Want &want) 34 { 35 abilityState_ = SLITE_STATE_INITIAL; 36 (void)AbilityMsClient::GetInstance().SchedulerLifecycleDone(token_, SLITE_STATE_INITIAL); 37 } 38 OnRestoreData(AbilitySavedData * data)39void SliteAbility::OnRestoreData(AbilitySavedData *data) 40 { 41 if (data == nullptr) { 42 return; 43 } 44 data->Reset(); 45 } 46 OnForeground(const Want & want)47void SliteAbility::OnForeground(const Want &want) 48 { 49 abilityState_ = SLITE_STATE_FOREGROUND; 50 (void)AbilityMsClient::GetInstance().SchedulerLifecycleDone(token_, SLITE_STATE_FOREGROUND); 51 } 52 OnBackground()53void SliteAbility::OnBackground() 54 { 55 abilityState_ = SLITE_STATE_BACKGROUND; 56 (void)AbilityMsClient::GetInstance().SchedulerLifecycleDone(token_, SLITE_STATE_BACKGROUND); 57 } 58 OnSaveData(AbilitySavedData * data)59void SliteAbility::OnSaveData(AbilitySavedData *data) 60 { 61 } 62 OnDestroy()63void SliteAbility::OnDestroy() 64 { 65 abilityState_ = SLITE_STATE_UNINITIALIZED; 66 (void)AbilityMsClient::GetInstance().SchedulerLifecycleDone(token_, SLITE_STATE_UNINITIALIZED); 67 } 68 HandleExtraMessage(const SliteAbilityInnerMsg & innerMsg)69void SliteAbility::HandleExtraMessage(const SliteAbilityInnerMsg &innerMsg) 70 { 71 } 72 GetState() const73int32_t SliteAbility::GetState() const 74 { 75 return abilityState_; 76 } 77 } // namespace AbilitySlite 78 } // namespace OHOS 79