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 #ifndef AUDIO_SAFE_VOLUME_NOTIFICATION_IMPL_H 17 #define AUDIO_SAFE_VOLUME_NOTIFICATION_IMPL_H 18 19 #include "audio_safe_volume_notification.h" 20 #include <mutex> 21 #include <string> 22 #include "image_source.h" 23 #include "pixel_map.h" 24 #include "resource_manager.h" 25 #include "res_config.h" 26 #include "notification_content.h" 27 #include "notification_normal_content.h" 28 #include "string_wrapper.h" 29 30 namespace OHOS { 31 namespace AudioStandard { 32 33 class AudioSafeVolumeNotificationImpl : public AudioSafeVolumeNotification { 34 public: 35 AudioSafeVolumeNotificationImpl() = default; 36 virtual ~AudioSafeVolumeNotificationImpl() = default; 37 38 void PublishSafeVolumeNotification(int32_t notificationId) override; 39 void CancelSafeVolumeNotification(int32_t notificationId) override; 40 private: 41 std::string GetSystemStringByName(std::string name); 42 bool SetTitleAndText(int32_t notificationId, std::shared_ptr<Notification::NotificationNormalContent> content); 43 std::string GetButtonName(uint32_t notificationId); 44 bool GetPixelMap(); 45 Global::Resource::RState GetMediaDataByName(const std::string& name, size_t& len, 46 std::unique_ptr<uint8_t[]>& outValue, uint32_t density = 0); 47 48 std::string title_ {}; 49 std::string text_ {}; 50 std::string buttonName_ {}; 51 std::string iconPath_ {}; 52 53 std::mutex mutex_ {}; 54 std::shared_ptr<Media::PixelMap> iconPixelMap_ {}; 55 }; 56 CreateSafeVolumeNotificationImpl()57extern "C" AudioSafeVolumeNotification *CreateSafeVolumeNotificationImpl() 58 { 59 return new AudioSafeVolumeNotificationImpl; 60 } 61 } // namespace AudioStandard 62 } // namespace OHOS 63 #endif // AUDIO_SAFE_VOLUME_NOTIFICATION_IMPL_H 64