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 #define MLOG_TAG "MediaLibraryCommonEventUtils" 17 18 #include "common_event_utils.h" 19 20 #include "media_log.h" 21 #include "medialibrary_errno.h" 22 #include "thermal_mgr_client.h" 23 #include "wifi_device.h" 24 25 using namespace std; 26 27 namespace OHOS { 28 namespace Media { GetThermalLevel()29int32_t CommonEventUtils::GetThermalLevel() 30 { 31 auto& thermalMgrClient = PowerMgr::ThermalMgrClient::GetInstance(); 32 return static_cast<int32_t>(thermalMgrClient.GetThermalLevel()); 33 } 34 IsWifiConnected()35bool CommonEventUtils::IsWifiConnected() 36 { 37 auto wifiDevicePtr = Wifi::WifiDevice::GetInstance(WIFI_DEVICE_ABILITY_ID); 38 if (wifiDevicePtr == nullptr) { 39 MEDIA_ERR_LOG("wifiDevicePtr is null"); 40 return false; 41 } 42 bool isWifiConnected = false; 43 int32_t ret = wifiDevicePtr->IsConnected(isWifiConnected); 44 if (ret != Wifi::WIFI_OPT_SUCCESS) { 45 MEDIA_ERR_LOG("Failed to get connected, ret: %{public}d", ret); 46 return false; 47 } 48 if (!isWifiConnected) { 49 MEDIA_WARN_LOG("Wifi is not connected, isWifiConnected: %{public}d", isWifiConnected); 50 } 51 return isWifiConnected; 52 } 53 } // namespace Media 54 } // namespace OHOS