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 SENSOR_ILLUMINATION_MANAGER 17 #define SENSOR_ILLUMINATION_MANAGER 18 19 #include <map> 20 #include <mutex> 21 22 #include "nocopyable.h" 23 24 #include "fingerprint_auth_all_in_one_executor_hdi.h" 25 #include "isa_command_processor.h" 26 #include "isensor_illumination_task.h" 27 28 namespace OHOS { 29 namespace UserIam { 30 namespace FingerprintAuth { 31 namespace UserAuth = OHOS::UserIam::UserAuth; 32 class SensorIlluminationManager : public std::enable_shared_from_this<SensorIlluminationManager>, 33 public ISaCommandProcessor, 34 public NoCopyable { 35 public: SensorIlluminationManager()36 SensorIlluminationManager() {}; 37 ~SensorIlluminationManager() = default; 38 static std::shared_ptr<SensorIlluminationManager> GetInstance(); 39 40 UserAuth::ResultCode ProcessSaCommand(std::shared_ptr<FingerprintAllInOneExecutorHdi> executor, 41 const SaCommand &command) override; 42 void OnHdiDisconnect(std::shared_ptr<FingerprintAllInOneExecutorHdi> executor) override; 43 44 private: 45 UserAuth::ResultCode EnableSensorIllumination(std::shared_ptr<FingerprintAllInOneExecutorHdi> executor, 46 const SaCommandParam param); 47 UserAuth::ResultCode DisableSensorIllumination(std::shared_ptr<FingerprintAllInOneExecutorHdi> executor, 48 const SaCommandParam param); 49 UserAuth::ResultCode TurnOnSensorIllumination(std::shared_ptr<FingerprintAllInOneExecutorHdi> executor, 50 const SaCommandParam param); 51 UserAuth::ResultCode TurnOffSensorIllumination(std::shared_ptr<FingerprintAllInOneExecutorHdi> executor, 52 const SaCommandParam param); 53 54 std::shared_ptr<FingerprintAllInOneExecutorHdi> executorInProc_ = nullptr; 55 std::shared_ptr<ISensorIlluminationTask> taskInProc_ = nullptr; 56 std::mutex mutex_; 57 }; 58 } // namespace FingerprintAuth 59 } // namespace UserIam 60 } // namespace OHOS 61 62 #endif // SENSOR_ILLUMINATION_MANAGER