• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 <unordered_map>
17 
18 #include "background_mode.h"
19 #include "continuous_task_suspend_reason.h"
20 
21 namespace OHOS {
22 namespace BackgroundTaskMgr {
23 const std::unordered_map<uint32_t, uint32_t> PARAM_SUSPEND_REASON = {
24     {BackgroundMode::DATA_TRANSFER, ContinuousTaskSuspendReason::SYSTEM_SUSPEND_DATA_TRANSFER_LOW_SPEED},
25     {BackgroundMode::AUDIO_PLAYBACK, ContinuousTaskSuspendReason::SYSTEM_SUSPEND_AUDIO_PLAYBACK_NOT_RUNNING},
26     {BackgroundMode::AUDIO_RECORDING, ContinuousTaskSuspendReason::SYSTEM_SUSPEND_AUDIO_RECORDING_NOT_RUNNING},
27     {BackgroundMode::LOCATION, ContinuousTaskSuspendReason::SYSTEM_SUSPEND_LOCATION_NOT_USED},
28     {BackgroundMode::BLUETOOTH_INTERACTION, ContinuousTaskSuspendReason::SYSTEM_SUSPEND_BLUETOOTH_NOT_USED},
29     {BackgroundMode::MULTI_DEVICE_CONNECTION, ContinuousTaskSuspendReason::SYSTEM_SUSPEND_MULTI_DEVICE_NOT_USED}
30 };
31 
GetSuspendReasonValue(const uint32_t mode)32 uint32_t ContinuousTaskSuspendReason::GetSuspendReasonValue(const uint32_t mode)
33 {
34     auto iter = PARAM_SUSPEND_REASON.find(mode);
35     if (iter != PARAM_SUSPEND_REASON.end()) {
36         return iter->second;
37     }
38     return 0;
39 }
40 }  // namespace BackgroundTaskMgr
41 }  // namespace OHOS