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 STORAGE_DAEMON_CRYPTO_DELAY_HANDLER_H 17 #define STORAGE_DAEMON_CRYPTO_DELAY_HANDLER_H 18 19 #include <thread> 20 21 #include "base_key.h" 22 #include "event_handler.h" 23 #include "libfscrypt/key_control.h" 24 25 namespace OHOS { 26 namespace StorageDaemon { 27 class DelayHandler { 28 // static const uint8_t CANCEL_CLEAR_ECE_SECE_TASK = 0; 29 // static const uint8_t START_CLEAR_ECE_SECE_TASK = 1; 30 public: 31 DelayHandler(uint32_t userId); 32 ~DelayHandler(); 33 void StartDelayTask(std::shared_ptr<BaseKey> &el4Key); 34 void CancelDelayTask(); 35 36 private: 37 void StartDelayHandler(); 38 void DeactiveEl3El4El5(); 39 40 std::mutex eventMutex_; 41 std::thread eventThread_; 42 std::condition_variable eventCon_; 43 std::shared_ptr<AppExecFwk::EventHandler> eventHandler_ = nullptr; 44 std::shared_ptr<BaseKey> el4Key_; 45 uint32_t userId_; 46 }; 47 } // StorageDaemon 48 } // OHOS 49 50 #endif // STORAGE_DAEMON_CRYPTO_DELAY_HANDLER_H 51