• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 AAMS_ST_ABILITY_A1
17 #define AAMS_ST_ABILITY_A1
18 
19 #include <memory>
20 #include <string>
21 #include "ability_loader.h"
22 #include "accessible_ability.h"
23 #include "accessibility_event_info.h"
24 #include "hilog_wrapper.h"
25 #include "key_event.h"
26 
27 namespace OHOS {
28 namespace AppExecFwk {
29 class AccessibleAbilityListenerTest;
30 
31 class AamsStAbilityA1 : public Ability {
32 public:
AamsStAbilityA1()33     AamsStAbilityA1() {}
~AamsStAbilityA1()34     ~AamsStAbilityA1() {}
35     void DisableAbility();
36     void GetFocusElementInfo();
37     void GestureSimulate();
38     void GetDisplayResizeController();
39     void GetRootElementInfo();
40     void GetWindows();
41     void PerformCommonAction();
42     void GetFingerprintController();
43 
44 protected:
45     virtual void OnStart(const Want &want) override;
46     virtual void OnStop() override;
47     virtual void OnActive() override;
48     virtual void OnInactive() override;
49     virtual void OnBackground() override;
50     virtual void OnForeground(const Want &want) override;
51     virtual void OnNewWant(const Want &want) override;
52 
53 private:
54     void Clear();
55     void GetWantInfo(const Want &want);
56 
57     void RegisterListenerToAA();
58     void ConnectToAAMS();
59 
60     std::string shouldReturn;
61     std::string targetBundle;
62     std::string targetAbility;
63 
64     std::shared_ptr<AccessibleAbilityListenerTest> listener_ = nullptr;
65 };
66 
67 class AccessibleAbilityListenerTest : public Accessibility::AccessibleAbilityListener {
68 public:
AccessibleAbilityListenerTest()69     AccessibleAbilityListenerTest() {}
~AccessibleAbilityListenerTest()70     ~AccessibleAbilityListenerTest() {}
71 
72     void OnAbilityConnected() override;
73     void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& eventInfo) override;
74     void OnGesture(uint32_t gestureId) override;
75     void OnInterrupt() override;
76     bool OnKeyPressEvent(const MMI::KeyEvent& keyEvent) override;
77 
78 private:
79     std::shared_ptr<AamsStAbilityA1> aamsStAbilityA1_ = std::make_shared<AamsStAbilityA1>();
80 };
81 } // namespace AppExecFwk
82 } // namespace OHOS
83 #endif  // AAMS_ST_ABILITY_A1