1 /* 2 * Copyright (c) 2024-2025 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 OHOS_ABILITY_RUNTIME_MODAL_SYSTEM_APP_FREEZE_UIEXTENSION_H 17 #define OHOS_ABILITY_RUNTIME_MODAL_SYSTEM_APP_FREEZE_UIEXTENSION_H 18 19 #ifdef APP_NO_RESPONSE_DIALOG 20 21 #include <iremote_broker.h> 22 #include <semaphore.h> 23 #include <functional> 24 #include <stdint.h> 25 26 #include "ability_connect_callback_stub.h" 27 #include "ability_manager_client.h" 28 #include "ability_state.h" 29 #include "fault_data.h" 30 #include "iremote_stub.h" 31 #include "task_handler_wrap.h" 32 #include "want.h" 33 34 namespace OHOS { 35 namespace AppExecFwk { 36 37 constexpr const char *APP_NO_RESPONSE_ABILITY = "AlertDialogAbility"; 38 39 class ModalSystemAppFreezeUIExtension { 40 public: 41 static ModalSystemAppFreezeUIExtension &GetInstance(); 42 ModalSystemAppFreezeUIExtension() = default; 43 virtual ~ModalSystemAppFreezeUIExtension(); 44 45 void ProcessAppFreeze(bool focusFlag, const FaultData &faultData, std::string pid, std::string bundleName, 46 std::function<void()> callback, bool isDialogExist); 47 48 private: 49 bool CreateModalUIExtension(std::string &pid, std::string &bundleName); 50 bool CreateSystemDialogWant( 51 std::string &pid, std::string &bundleName, sptr<IRemoteObject> token, AAFwk::Want &want); 52 53 private: 54 bool lastFocusStatus = false; 55 uint64_t lastFreezeTime = 0; 56 std::mutex appFreezeResultMutex_; 57 std::string lastFreezePid; 58 }; 59 } // namespace AppExecFwk 60 } // namespace OHOS 61 #endif // APP_NO_RESPONSE_DIALOG 62 #endif // OHOS_ABILITY_RUNTIME_MODAL_SYSTEM_APP_FREEZE_UIEXTENSION_H