1 /* 2 * Copyright 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <PointerControllerInterface.h> 20 #include <input/DisplayViewport.h> 21 #include <input/Input.h> 22 #include <utils/BitSet.h> 23 #include <unordered_set> 24 25 namespace android { 26 27 struct SpriteIcon { 28 PointerIconStyle style; 29 }; 30 31 class FakePointerController : public PointerControllerInterface { 32 public: FakePointerController()33 FakePointerController() : FakePointerController(/*enabled=*/true) {} FakePointerController(bool enabled)34 FakePointerController(bool enabled) : mEnabled(enabled) {} 35 ~FakePointerController()36 virtual ~FakePointerController() {} 37 38 void setBounds(float minX, float minY, float maxX, float maxY); 39 void clearBounds(); 40 const std::map<ui::LogicalDisplayId, std::vector<int32_t>>& getSpots(); 41 42 void setPosition(float x, float y) override; 43 FloatPoint getPosition() const override; 44 ui::LogicalDisplayId getDisplayId() const override; 45 void setDisplayViewport(const DisplayViewport& viewport) override; 46 void updatePointerIcon(PointerIconStyle iconId) override; 47 void setCustomPointerIcon(const SpriteIcon& icon) override; 48 void setSkipScreenshotFlagForDisplay(ui::LogicalDisplayId displayId) override; 49 void clearSkipScreenshotFlags() override; 50 void fade(Transition) override; 51 52 void assertViewportSet(ui::LogicalDisplayId displayId); 53 void assertViewportNotSet(); 54 void assertPosition(float x, float y); 55 void assertSpotCount(ui::LogicalDisplayId displayId, int32_t count); 56 void assertPointerIconSet(PointerIconStyle iconId); 57 void assertPointerIconNotSet(); 58 void assertCustomPointerIconSet(PointerIconStyle iconId); 59 void assertCustomPointerIconNotSet(); 60 void assertIsSkipScreenshotFlagSet(ui::LogicalDisplayId displayId); 61 void assertIsSkipScreenshotFlagNotSet(ui::LogicalDisplayId displayId); 62 void assertSkipScreenshotFlagChanged(); 63 void assertSkipScreenshotFlagNotChanged(); 64 bool isPointerShown(); 65 66 private: dump()67 std::string dump() override { return ""; } 68 std::optional<FloatRect> getBounds() const override; 69 void move(float deltaX, float deltaY) override; 70 void unfade(Transition) override; setPresentation(Presentation)71 void setPresentation(Presentation) override {} 72 void setSpots(const PointerCoords*, const uint32_t*, BitSet32 spotIdBits, 73 ui::LogicalDisplayId displayId) override; 74 void clearSpots() override; 75 76 const bool mEnabled; 77 bool mHaveBounds{false}; 78 float mMinX{0}, mMinY{0}, mMaxX{0}, mMaxY{0}; 79 float mX{0}, mY{0}; 80 std::optional<ui::LogicalDisplayId> mDisplayId; 81 bool mIsPointerShown{false}; 82 std::optional<PointerIconStyle> mIconStyle; 83 std::optional<PointerIconStyle> mCustomIconStyle; 84 85 std::map<ui::LogicalDisplayId, std::vector<int32_t>> mSpotsByDisplay; 86 std::unordered_set<ui::LogicalDisplayId> mDisplaysToSkipScreenshot; 87 bool mDisplaysToSkipScreenshotFlagChanged{false}; 88 }; 89 90 } // namespace android 91