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
20 namespace OHOS {
21 namespace BackgroundTaskMgr {
22 const std::unordered_map<uint32_t, std::string> PARAM_BACKGROUND_MODE_STR_MAP = {
23 {BackgroundMode::DATA_TRANSFER, "dataTransfer"},
24 {BackgroundMode::AUDIO_PLAYBACK, "audioPlayback"},
25 {BackgroundMode::AUDIO_RECORDING, "audioRecording"},
26 {BackgroundMode::LOCATION, "location"},
27 {BackgroundMode::BLUETOOTH_INTERACTION, "bluetoothInteraction"},
28 {BackgroundMode::MULTI_DEVICE_CONNECTION, "multiDeviceConnection"},
29 {BackgroundMode::WIFI_INTERACTION, "wifiInteraction"},
30 {BackgroundMode::VOIP, "voip"},
31 {BackgroundMode::TASK_KEEPING, "taskKeeping"},
32 {BackgroundMode::WORKOUT, "workout"},
33 {BackgroundMode::END, "end"}
34 };
35
GetBackgroundModeStr(uint32_t mode)36 std::string BackgroundMode::GetBackgroundModeStr(uint32_t mode)
37 {
38 auto iter = PARAM_BACKGROUND_MODE_STR_MAP.find(mode);
39 if (iter != PARAM_BACKGROUND_MODE_STR_MAP.end()) {
40 return iter->second.c_str();
41 }
42 return "default";
43 }
44 } // namespace BackgroundTaskMgr
45 } // namespace OHOS