1 /* 2 * Copyright 2023 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 <android-base/properties.h> 20 #include <android/os/IInputConstants.h> 21 #include <gui/InputApplication.h> 22 23 namespace android { 24 25 namespace inputdispatcher { 26 27 class FakeApplicationHandle : public InputApplicationHandle { 28 public: FakeApplicationHandle()29 FakeApplicationHandle() { 30 static const std::chrono::duration DISPATCHING_TIMEOUT = std::chrono::milliseconds( 31 android::os::IInputConstants::UNMULTIPLIED_DEFAULT_DISPATCHING_TIMEOUT_MILLIS * 32 android::base::HwTimeoutMultiplier()); 33 mInfo.name = "Fake Application"; 34 mInfo.token = sp<BBinder>::make(); 35 mInfo.dispatchingTimeoutMillis = 36 std::chrono::duration_cast<std::chrono::milliseconds>(DISPATCHING_TIMEOUT).count(); 37 } ~FakeApplicationHandle()38 virtual ~FakeApplicationHandle() {} 39 updateInfo()40 bool updateInfo() override { return true; } 41 setDispatchingTimeout(std::chrono::milliseconds timeout)42 void setDispatchingTimeout(std::chrono::milliseconds timeout) { 43 mInfo.dispatchingTimeoutMillis = timeout.count(); 44 } 45 }; 46 47 } // namespace inputdispatcher 48 } // namespace android 49