1/* 2 * Copyright (c) 2023 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 SCREEN_BRIGHTNESS_MANAGER 17#define SCREEN_BRIGHTNESS_MANAGER 18 19#include <map> 20#include <mutex> 21 22#include "nocopyable.h" 23 24#include "face_auth_all_in_one_executor_hdi.h" 25#include "face_auth_hdi.h" 26#include "isa_command_processor.h" 27#include "iscreen_brightness_task.h" 28 29namespace OHOS { 30namespace UserIam { 31namespace FaceAuth { 32namespace UserAuth = OHOS::UserIam::UserAuth; 33class ScreenBrightnessManager : public std::enable_shared_from_this<ScreenBrightnessManager>, 34 public ISaCommandProcessor, 35 public NoCopyable { 36public: 37 ScreenBrightnessManager() = default; 38 ~ScreenBrightnessManager() override = default; 39 static std::shared_ptr<ScreenBrightnessManager> GetInstance(); 40 41 UserAuth::ResultCode ProcessSaCommand(std::shared_ptr<FaceAuthAllInOneExecutorHdi> executor, 42 const SaCommand &command) override; 43 void OnHdiDisconnect(std::shared_ptr<FaceAuthAllInOneExecutorHdi> executor) override; 44 45 std::shared_ptr<IScreenBrightnessTask> GetCurrentTask(); 46 47private: 48 UserAuth::ResultCode ProcessScreenBrightnessIncreaseBegin(std::shared_ptr<FaceAuthAllInOneExecutorHdi> executor, 49 const SaCommandParam param); 50 UserAuth::ResultCode ProcessScreenBrightnessIncreaseEnd(std::shared_ptr<FaceAuthAllInOneExecutorHdi> executor, 51 const SaCommandParam param); 52 53 std::shared_ptr<FaceAuthAllInOneExecutorHdi> executorInProc_ = nullptr; 54 std::shared_ptr<IScreenBrightnessTask> taskInProc_ = nullptr; 55 std::mutex mutex_; 56}; 57} // namespace FaceAuth 58} // namespace UserIam 59} // namespace OHOS 60 61#endif // SCREEN_BRIGHTNESS_MANAGER