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 ACCESSIBILITY_SHORT_KEY_DIALOG_H 17 #define ACCESSIBILITY_SHORT_KEY_DIALOG_H 18 19 #include "ability_connection.h" 20 #include "ability_connect_callback_interface.h" 21 #include "ability_connect_callback_stub.h" 22 #include "iremote_object.h" 23 #include "iremote_proxy.h" 24 #include "message_parcel.h" 25 #include "nocopyable.h" 26 #include <cstdint> 27 28 namespace OHOS { 29 namespace Accessibility { 30 31 class ShortkeyAbilityConnection : public AAFwk::AbilityConnectionStub { 32 public: ShortkeyAbilityConnection(const std::string commandStr)33 explicit ShortkeyAbilityConnection(const std::string commandStr) 34 { 35 commandStr_ = commandStr; 36 } 37 38 virtual ~ShortkeyAbilityConnection() = default; 39 40 void OnAbilityConnectDone(const AppExecFwk::ElementName &element, 41 const sptr<IRemoteObject> &remoteObject, int32_t resultCode) override; 42 void OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int32_t resultCode) override; 43 std::string GetCommandString(); 44 45 private: 46 std::string commandStr_; 47 }; 48 49 class AccessibilityShortkeyDialog { 50 public: 51 AccessibilityShortkeyDialog(); 52 ~AccessibilityShortkeyDialog(); 53 bool ConnectDialog(); 54 55 private: 56 bool ConnectExtension(); 57 bool ConnectExtensionAbility(const AAFwk::Want &want, const std::string commandStr); 58 bool DisconnectExtension() const; 59 std::string BuildStartCommand(); 60 61 private: 62 sptr<ShortkeyAbilityConnection> connection_ {nullptr}; 63 }; 64 65 } // namespace Accessibility 66 } // namespace OHOS 67 #endif // ACCESSIBILITY_SHORT_KEY_DIALOG_H