blob: f3f15df15179d1bb0406424e5c1e8cedb84191e2 [file] [log] [blame]
Prabir Pradhanbaa5c822019-08-30 15:27:05 -07001/*
2 * Copyright (C) 2019 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#include "Macros.h"
18
19#include "InputDevice.h"
20
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -080021#include <algorithm>
22
Harry Cutts89844622022-12-02 15:02:26 +000023#include <android/sysprop/InputProperties.sysprop.h>
Dominik Laskowski2f01d772022-03-23 16:01:29 -070024#include <ftl/flags.h>
25
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -080026#include "CursorInputMapper.h"
27#include "ExternalStylusInputMapper.h"
28#include "InputReaderContext.h"
29#include "JoystickInputMapper.h"
30#include "KeyboardInputMapper.h"
31#include "MultiTouchInputMapper.h"
Chris Ye1dd2e5c2021-04-04 23:12:41 -070032#include "PeripheralController.h"
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -080033#include "RotaryEncoderInputMapper.h"
Chris Yef59a2f42020-10-16 12:55:26 -070034#include "SensorInputMapper.h"
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -080035#include "SingleTouchInputMapper.h"
36#include "SwitchInputMapper.h"
Harry Cutts79cc9fa2022-10-28 15:32:39 +000037#include "TouchpadInputMapper.h"
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -080038#include "VibratorInputMapper.h"
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070039
40namespace android {
41
42InputDevice::InputDevice(InputReaderContext* context, int32_t id, int32_t generation,
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -080043 const InputDeviceIdentifier& identifier)
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070044 : mContext(context),
45 mId(id),
46 mGeneration(generation),
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -080047 mControllerNumber(0),
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070048 mIdentifier(identifier),
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -080049 mClasses(0),
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070050 mSources(0),
Yeabkal Wubshite03e8b12023-06-27 16:23:12 -070051 mIsWaking(false),
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070052 mIsExternal(false),
53 mHasMic(false),
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -080054 mDropUntilNextSync(false) {}
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070055
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -080056InputDevice::~InputDevice() {}
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070057
58bool InputDevice::isEnabled() {
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -080059 if (!hasEventHubDevices()) {
60 return false;
61 }
Chris Yee14523a2020-12-19 13:46:00 -080062 // An input device composed of sub devices can be individually enabled or disabled.
63 // If any of the sub device is enabled then the input device is considered as enabled.
64 bool enabled = false;
65 for_each_subdevice([&enabled](auto& context) { enabled |= context.isDeviceEnabled(); });
66 return enabled;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070067}
68
Arpit Singh48189772023-05-30 14:12:49 +000069std::list<NotifyArgs> InputDevice::updateEnableState(nsecs_t when,
Arpit Singh82f29a12023-06-13 15:05:53 +000070 const InputReaderConfiguration& readerConfig,
71 bool forceEnable) {
72 bool enable = forceEnable;
73 if (!forceEnable) {
74 // If the device was explicitly disabled by the user, it would be present in the
75 // "disabledDevices" list. This device should be disabled.
76 enable = readerConfig.disabledDevices.find(mId) == readerConfig.disabledDevices.end();
Arpit Singh48189772023-05-30 14:12:49 +000077
Arpit Singh82f29a12023-06-13 15:05:53 +000078 // If a device is associated with a specific display but there is no
79 // associated DisplayViewport, don't enable the device.
80 if (enable && (mAssociatedDisplayPort || mAssociatedDisplayUniqueId) &&
81 !mAssociatedViewport) {
82 const std::string desc = mAssociatedDisplayPort
83 ? "port " + std::to_string(*mAssociatedDisplayPort)
84 : "uniqueId " + *mAssociatedDisplayUniqueId;
85 ALOGW("Cannot enable input device %s because it is associated "
86 "with %s, but the corresponding viewport is not found",
87 getName().c_str(), desc.c_str());
88 enable = false;
89 }
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070090 }
91
Arpit Singh48189772023-05-30 14:12:49 +000092 std::list<NotifyArgs> out;
93 if (isEnabled() == enable) {
Siarhei Vishniakou2935db72022-09-22 13:35:22 -070094 return out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070095 }
96
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -080097 // When resetting some devices, the driver needs to be queried to ensure that a proper reset is
98 // performed. The querying must happen when the device is enabled, so we reset after enabling
99 // but before disabling the device. See MultiTouchMotionAccumulator::reset for more information.
Arpit Singh48189772023-05-30 14:12:49 +0000100 if (enable) {
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800101 for_each_subdevice([](auto& context) { context.enableDevice(); });
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700102 out += reset(when);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700103 } else {
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700104 out += reset(when);
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800105 for_each_subdevice([](auto& context) { context.disableDevice(); });
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700106 }
107 // Must change generation to flag this device as changed
108 bumpGeneration();
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700109 return out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700110}
111
Chris Yee7310032020-09-22 15:36:28 -0700112void InputDevice::dump(std::string& dump, const std::string& eventHubDevStr) {
Siarhei Vishniakou1983a712021-06-04 19:27:09 +0000113 InputDeviceInfo deviceInfo = getDeviceInfo();
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700114
115 dump += StringPrintf(INDENT "Device %d: %s\n", deviceInfo.getId(),
116 deviceInfo.getDisplayName().c_str());
Chris Yee7310032020-09-22 15:36:28 -0700117 dump += StringPrintf(INDENT "%s", eventHubDevStr.c_str());
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700118 dump += StringPrintf(INDENT2 "Generation: %d\n", mGeneration);
119 dump += StringPrintf(INDENT2 "IsExternal: %s\n", toString(mIsExternal));
Yeabkal Wubshite03e8b12023-06-27 16:23:12 -0700120 dump += StringPrintf(INDENT2 "IsWaking: %s\n", toString(mIsWaking));
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700121 dump += StringPrintf(INDENT2 "AssociatedDisplayPort: ");
122 if (mAssociatedDisplayPort) {
123 dump += StringPrintf("%" PRIu8 "\n", *mAssociatedDisplayPort);
124 } else {
125 dump += "<none>\n";
126 }
Christine Franks1ba71cc2021-04-07 14:37:42 -0700127 dump += StringPrintf(INDENT2 "AssociatedDisplayUniqueId: ");
128 if (mAssociatedDisplayUniqueId) {
129 dump += StringPrintf("%s\n", mAssociatedDisplayUniqueId->c_str());
130 } else {
131 dump += "<none>\n";
132 }
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700133 dump += StringPrintf(INDENT2 "HasMic: %s\n", toString(mHasMic));
Siarhei Vishniakou88151b82022-08-11 00:53:38 +0000134 dump += StringPrintf(INDENT2 "Sources: %s\n",
135 inputEventSourceToString(deviceInfo.getSources()).c_str());
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700136 dump += StringPrintf(INDENT2 "KeyboardType: %d\n", deviceInfo.getKeyboardType());
Chris Yee7310032020-09-22 15:36:28 -0700137 dump += StringPrintf(INDENT2 "ControllerNum: %d\n", deviceInfo.getControllerNumber());
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700138
139 const std::vector<InputDeviceInfo::MotionRange>& ranges = deviceInfo.getMotionRanges();
140 if (!ranges.empty()) {
141 dump += INDENT2 "Motion Ranges:\n";
142 for (size_t i = 0; i < ranges.size(); i++) {
143 const InputDeviceInfo::MotionRange& range = ranges[i];
Chris Ye4958d062020-08-20 13:21:10 -0700144 const char* label = InputEventLookup::getAxisLabel(range.axis);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700145 char name[32];
146 if (label) {
147 strncpy(name, label, sizeof(name));
148 name[sizeof(name) - 1] = '\0';
149 } else {
150 snprintf(name, sizeof(name), "%d", range.axis);
151 }
152 dump += StringPrintf(INDENT3
Siarhei Vishniakou88151b82022-08-11 00:53:38 +0000153 "%s: source=%s, "
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700154 "min=%0.3f, max=%0.3f, flat=%0.3f, fuzz=%0.3f, resolution=%0.3f\n",
Siarhei Vishniakou88151b82022-08-11 00:53:38 +0000155 name, inputEventSourceToString(range.source).c_str(), range.min,
156 range.max, range.flat, range.fuzz, range.resolution);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700157 }
158 }
159
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -0800160 for_each_mapper([&dump](InputMapper& mapper) { mapper.dump(dump); });
Chris Yee2b1e5c2021-03-10 22:45:12 -0800161 if (mController) {
162 mController->dump(dump);
163 }
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700164}
165
Arpit Singh8e6fb252023-04-06 11:49:17 +0000166void InputDevice::addEmptyEventHubDevice(int32_t eventHubId) {
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800167 if (mDevices.find(eventHubId) != mDevices.end()) {
168 return;
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -0800169 }
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800170 std::unique_ptr<InputDeviceContext> contextPtr(new InputDeviceContext(*this, eventHubId));
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000171 std::vector<std::unique_ptr<InputMapper>> mappers;
172
173 mDevices.insert({eventHubId, std::make_pair(std::move(contextPtr), std::move(mappers))});
Arpit Singh8e6fb252023-04-06 11:49:17 +0000174}
175
Arpit Singh82f29a12023-06-13 15:05:53 +0000176[[nodiscard]] std::list<NotifyArgs> InputDevice::addEventHubDevice(
177 nsecs_t when, int32_t eventHubId, const InputReaderConfiguration& readerConfig) {
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000178 if (mDevices.find(eventHubId) != mDevices.end()) {
Arpit Singh82f29a12023-06-13 15:05:53 +0000179 return {};
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000180 }
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000181
Arpit Singh82f29a12023-06-13 15:05:53 +0000182 // Add an empty device configure and keep it enabled to allow mapper population with correct
183 // configuration/context,
184 // Note: we need to ensure device is kept enabled till mappers are configured
185 // TODO: b/281852638 refactor tests to remove this flag and reliance on the empty device
186 addEmptyEventHubDevice(eventHubId);
187 std::list<NotifyArgs> out = configureInternal(when, readerConfig, {}, /*forceEnable=*/true);
188
189 DevicePair& devicePair = mDevices[eventHubId];
190 devicePair.second = createMappers(*devicePair.first, readerConfig);
191
Chris Yee7310032020-09-22 15:36:28 -0700192 // Must change generation to flag this device as changed
193 bumpGeneration();
Arpit Singh82f29a12023-06-13 15:05:53 +0000194 return out;
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800195}
196
197void InputDevice::removeEventHubDevice(int32_t eventHubId) {
Siarhei Vishniakou30feb8c2022-09-28 10:48:29 -0700198 if (mController != nullptr && mController->getEventHubId() == eventHubId) {
199 // Delete mController, since the corresponding eventhub device is going away
200 mController = nullptr;
201 }
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800202 mDevices.erase(eventHubId);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700203}
204
Arpit Singhed6c3de2023-04-05 19:24:37 +0000205std::list<NotifyArgs> InputDevice::configure(nsecs_t when,
206 const InputReaderConfiguration& readerConfig,
Arpit Singh7f1765e2023-07-07 13:12:37 +0000207 ConfigurationChanges changes) {
Arpit Singh82f29a12023-06-13 15:05:53 +0000208 return configureInternal(when, readerConfig, changes);
209}
210std::list<NotifyArgs> InputDevice::configureInternal(nsecs_t when,
211 const InputReaderConfiguration& readerConfig,
212 ConfigurationChanges changes,
213 bool forceEnable) {
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700214 std::list<NotifyArgs> out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700215 mSources = 0;
Dominik Laskowski2f01d772022-03-23 16:01:29 -0700216 mClasses = ftl::Flags<InputDeviceClass>(0);
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800217 mControllerNumber = 0;
218
219 for_each_subdevice([this](InputDeviceContext& context) {
220 mClasses |= context.getDeviceClasses();
221 int32_t controllerNumber = context.getDeviceControllerNumber();
222 if (controllerNumber > 0) {
223 if (mControllerNumber && mControllerNumber != controllerNumber) {
224 ALOGW("InputDevice::configure(): composite device contains multiple unique "
225 "controller numbers");
226 }
227 mControllerNumber = controllerNumber;
228 }
229 });
230
Chris Ye1b0c7342020-07-28 21:57:03 -0700231 mIsExternal = mClasses.test(InputDeviceClass::EXTERNAL);
232 mHasMic = mClasses.test(InputDeviceClass::MIC);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700233
Prabir Pradhan4bf6d452023-04-18 21:26:56 +0000234 using Change = InputReaderConfiguration::Change;
235
Arpit Singh56adebc2023-04-25 13:56:05 +0000236 if (!changes.any() || !isIgnored()) {
Ambrus Weisz7b6e16b2022-12-16 17:54:57 +0000237 // Full configuration should happen the first time configure is called
238 // and when the device type is changed. Changing a device type can
239 // affect various other parameters so should result in a
240 // reconfiguration.
Prabir Pradhan4bf6d452023-04-18 21:26:56 +0000241 if (!changes.any() || changes.test(Change::DEVICE_TYPE)) {
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800242 mConfiguration.clear();
243 for_each_subdevice([this](InputDeviceContext& context) {
Harry Cuttsc34f7582023-03-07 16:23:30 +0000244 std::optional<PropertyMap> configuration =
245 getEventHub()->getConfiguration(context.getEventHubId());
246 if (configuration) {
247 mConfiguration.addAll(&(*configuration));
248 }
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800249 });
Ambrus Weisz7bc23bf2022-10-04 13:13:07 +0000250
251 mAssociatedDeviceType =
Arpit Singhed6c3de2023-04-05 19:24:37 +0000252 getValueByKey(readerConfig.deviceTypeAssociations, mIdentifier.location);
Yeabkal Wubshite03e8b12023-06-27 16:23:12 -0700253 mIsWaking = mConfiguration.getBool("device.wake").value_or(false);
Yeabkal Wubshitb1b96db2024-01-24 12:47:00 -0800254 mShouldSmoothScroll = mConfiguration.getBool("device.viewBehavior_smoothScroll");
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700255 }
256
Prabir Pradhan4bf6d452023-04-18 21:26:56 +0000257 if (!changes.any() || changes.test(Change::DEVICE_ALIAS)) {
Chris Ye1b0c7342020-07-28 21:57:03 -0700258 if (!(mClasses.test(InputDeviceClass::VIRTUAL))) {
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700259 std::string alias = mContext->getPolicy()->getDeviceAlias(mIdentifier);
260 if (mAlias != alias) {
261 mAlias = alias;
262 bumpGeneration();
263 }
264 }
265 }
266
Prabir Pradhan4bf6d452023-04-18 21:26:56 +0000267 if (!changes.any() || changes.test(Change::DISPLAY_INFO)) {
Christine Franks1ba71cc2021-04-07 14:37:42 -0700268 // In most situations, no port or name will be specified.
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700269 mAssociatedDisplayPort = std::nullopt;
Christine Franks1ba71cc2021-04-07 14:37:42 -0700270 mAssociatedDisplayUniqueId = std::nullopt;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700271 mAssociatedViewport = std::nullopt;
272 // Find the display port that corresponds to the current input port.
273 const std::string& inputPort = mIdentifier.location;
274 if (!inputPort.empty()) {
Arpit Singhed6c3de2023-04-05 19:24:37 +0000275 const std::unordered_map<std::string, uint8_t>& ports =
276 readerConfig.portAssociations;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700277 const auto& displayPort = ports.find(inputPort);
278 if (displayPort != ports.end()) {
279 mAssociatedDisplayPort = std::make_optional(displayPort->second);
Christine Franks2a2293c2022-01-18 11:51:16 -0800280 } else {
281 const std::unordered_map<std::string, std::string>& displayUniqueIds =
Arpit Singhed6c3de2023-04-05 19:24:37 +0000282 readerConfig.uniqueIdAssociations;
Christine Franks2a2293c2022-01-18 11:51:16 -0800283 const auto& displayUniqueId = displayUniqueIds.find(inputPort);
284 if (displayUniqueId != displayUniqueIds.end()) {
285 mAssociatedDisplayUniqueId = displayUniqueId->second;
286 }
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700287 }
288 }
289
Arpit Singh48189772023-05-30 14:12:49 +0000290 // If it is associated with a specific display, then find the corresponding viewport
291 // which will be used to enable/disable the device.
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700292 if (mAssociatedDisplayPort) {
Arpit Singhed6c3de2023-04-05 19:24:37 +0000293 mAssociatedViewport =
294 readerConfig.getDisplayViewportByPort(*mAssociatedDisplayPort);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700295 if (!mAssociatedViewport) {
296 ALOGW("Input device %s should be associated with display on port %" PRIu8 ", "
297 "but the corresponding viewport is not found.",
298 getName().c_str(), *mAssociatedDisplayPort);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700299 }
Christine Franks1ba71cc2021-04-07 14:37:42 -0700300 } else if (mAssociatedDisplayUniqueId != std::nullopt) {
301 mAssociatedViewport =
Arpit Singhed6c3de2023-04-05 19:24:37 +0000302 readerConfig.getDisplayViewportByUniqueId(*mAssociatedDisplayUniqueId);
Christine Franks1ba71cc2021-04-07 14:37:42 -0700303 if (!mAssociatedViewport) {
304 ALOGW("Input device %s should be associated with display %s but the "
305 "corresponding viewport cannot be found",
Christine Franks2a2293c2022-01-18 11:51:16 -0800306 getName().c_str(), mAssociatedDisplayUniqueId->c_str());
Christine Franks1ba71cc2021-04-07 14:37:42 -0700307 }
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700308 }
Arpit Singh48189772023-05-30 14:12:49 +0000309 }
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700310
Arpit Singhed6c3de2023-04-05 19:24:37 +0000311 for_each_mapper([this, when, &readerConfig, changes, &out](InputMapper& mapper) {
312 out += mapper.reconfigure(when, readerConfig, changes);
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -0800313 mSources |= mapper.getSources();
314 });
Arpit Singh7f1765e2023-07-07 13:12:37 +0000315
Arpit Singh82f29a12023-06-13 15:05:53 +0000316 if (!changes.any() || changes.test(Change::ENABLED_STATE) ||
317 changes.test(Change::DISPLAY_INFO)) {
318 // Whether a device is enabled can depend on the display association,
319 // so update the enabled state when there is a change in display info.
320 out += updateEnableState(when, readerConfig, forceEnable);
Arpit Singh7f1765e2023-07-07 13:12:37 +0000321 }
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700322 }
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700323 return out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700324}
325
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700326std::list<NotifyArgs> InputDevice::reset(nsecs_t when) {
327 std::list<NotifyArgs> out;
328 for_each_mapper([&](InputMapper& mapper) { out += mapper.reset(when); });
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700329
330 mContext->updateGlobalMetaState();
331
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700332 out.push_back(notifyReset(when));
333 return out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700334}
335
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700336std::list<NotifyArgs> InputDevice::process(const RawEvent* rawEvents, size_t count) {
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700337 // Process all of the events in order for each mapper.
338 // We cannot simply ask each mapper to process them in bulk because mappers may
339 // have side-effects that must be interleaved. For example, joystick movement events and
340 // gamepad button presses are handled by different mappers but they should be dispatched
341 // in the order received.
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700342 std::list<NotifyArgs> out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700343 for (const RawEvent* rawEvent = rawEvents; count != 0; rawEvent++) {
Prabir Pradhan011ca3d2023-02-22 21:31:39 +0000344 if (debugRawEvents()) {
Prabir Pradhan1e63fc22023-02-23 19:03:03 +0000345 const auto [type, code, value] =
346 InputEventLookup::getLinuxEvdevLabel(rawEvent->type, rawEvent->code,
347 rawEvent->value);
348 ALOGD("Input event: eventHubDevice=%d type=%s code=%s value=%s when=%" PRId64,
349 rawEvent->deviceId, type.c_str(), code.c_str(), value.c_str(), rawEvent->when);
Siarhei Vishniakou465e1c02021-12-09 10:47:29 -0800350 }
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700351
352 if (mDropUntilNextSync) {
353 if (rawEvent->type == EV_SYN && rawEvent->code == SYN_REPORT) {
Arpit Singh4b4a4572023-11-24 18:19:56 +0000354 out += reset(rawEvent->when);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700355 mDropUntilNextSync = false;
Prabir Pradhan1e63fc22023-02-23 19:03:03 +0000356 ALOGD_IF(debugRawEvents(), "Recovered from input event buffer overrun.");
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700357 } else {
Prabir Pradhan1e63fc22023-02-23 19:03:03 +0000358 ALOGD_IF(debugRawEvents(),
359 "Dropped input event while waiting for next input sync.");
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700360 }
361 } else if (rawEvent->type == EV_SYN && rawEvent->code == SYN_DROPPED) {
362 ALOGI("Detected input event buffer overrun for device %s.", getName().c_str());
363 mDropUntilNextSync = true;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700364 } else {
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700365 for_each_mapper_in_subdevice(rawEvent->deviceId, [&](InputMapper& mapper) {
366 out += mapper.process(rawEvent);
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800367 });
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700368 }
369 --count;
370 }
Yeabkal Wubshite03e8b12023-06-27 16:23:12 -0700371 postProcess(out);
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700372 return out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700373}
374
Yeabkal Wubshite03e8b12023-06-27 16:23:12 -0700375void InputDevice::postProcess(std::list<NotifyArgs>& args) const {
376 if (mIsWaking) {
377 // Update policy flags to request wake for the `NotifyArgs` that come from waking devices.
378 for (auto& arg : args) {
379 if (const auto notifyMotionArgs = std::get_if<NotifyMotionArgs>(&arg)) {
380 notifyMotionArgs->policyFlags |= POLICY_FLAG_WAKE;
381 } else if (const auto notifySwitchArgs = std::get_if<NotifySwitchArgs>(&arg)) {
382 notifySwitchArgs->policyFlags |= POLICY_FLAG_WAKE;
383 } else if (const auto notifyKeyArgs = std::get_if<NotifyKeyArgs>(&arg)) {
384 notifyKeyArgs->policyFlags |= POLICY_FLAG_WAKE;
385 }
386 }
387 }
388}
389
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700390std::list<NotifyArgs> InputDevice::timeoutExpired(nsecs_t when) {
391 std::list<NotifyArgs> out;
392 for_each_mapper([&](InputMapper& mapper) { out += mapper.timeoutExpired(when); });
393 return out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700394}
395
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700396std::list<NotifyArgs> InputDevice::updateExternalStylusState(const StylusState& state) {
397 std::list<NotifyArgs> out;
398 for_each_mapper([&](InputMapper& mapper) { out += mapper.updateExternalStylusState(state); });
399 return out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700400}
401
Siarhei Vishniakou1983a712021-06-04 19:27:09 +0000402InputDeviceInfo InputDevice::getDeviceInfo() {
403 InputDeviceInfo outDeviceInfo;
404 outDeviceInfo.initialize(mId, mGeneration, mControllerNumber, mIdentifier, mAlias, mIsExternal,
Yeabkal Wubshitb1b96db2024-01-24 12:47:00 -0800405 mHasMic, getAssociatedDisplayId().value_or(ADISPLAY_ID_NONE),
406 {mShouldSmoothScroll});
Prabir Pradhane04ffaa2022-12-13 23:04:04 +0000407
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -0800408 for_each_mapper(
Harry Cuttsd02ea102023-03-17 18:21:30 +0000409 [&outDeviceInfo](InputMapper& mapper) { mapper.populateDeviceInfo(outDeviceInfo); });
Chris Yee2b1e5c2021-03-10 22:45:12 -0800410
411 if (mController) {
Siarhei Vishniakou1983a712021-06-04 19:27:09 +0000412 mController->populateDeviceInfo(&outDeviceInfo);
Chris Yee2b1e5c2021-03-10 22:45:12 -0800413 }
Siarhei Vishniakou1983a712021-06-04 19:27:09 +0000414 return outDeviceInfo;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700415}
416
417int32_t InputDevice::getKeyCodeState(uint32_t sourceMask, int32_t keyCode) {
418 return getState(sourceMask, keyCode, &InputMapper::getKeyCodeState);
419}
420
421int32_t InputDevice::getScanCodeState(uint32_t sourceMask, int32_t scanCode) {
422 return getState(sourceMask, scanCode, &InputMapper::getScanCodeState);
423}
424
425int32_t InputDevice::getSwitchState(uint32_t sourceMask, int32_t switchCode) {
426 return getState(sourceMask, switchCode, &InputMapper::getSwitchState);
427}
428
429int32_t InputDevice::getState(uint32_t sourceMask, int32_t code, GetStateFunc getStateFunc) {
430 int32_t result = AKEY_STATE_UNKNOWN;
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800431 for (auto& deviceEntry : mDevices) {
432 auto& devicePair = deviceEntry.second;
433 auto& mappers = devicePair.second;
434 for (auto& mapperPtr : mappers) {
435 InputMapper& mapper = *mapperPtr;
436 if (sourcesMatchMask(mapper.getSources(), sourceMask)) {
437 // If any mapper reports AKEY_STATE_DOWN or AKEY_STATE_VIRTUAL, return that
438 // value. Otherwise, return AKEY_STATE_UP as long as one mapper reports it.
439 int32_t currentResult = (mapper.*getStateFunc)(sourceMask, code);
440 if (currentResult >= AKEY_STATE_DOWN) {
441 return currentResult;
442 } else if (currentResult == AKEY_STATE_UP) {
443 result = currentResult;
444 }
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700445 }
446 }
447 }
448 return result;
449}
450
Arpit Singh8e6fb252023-04-06 11:49:17 +0000451std::vector<std::unique_ptr<InputMapper>> InputDevice::createMappers(
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000452 InputDeviceContext& contextPtr, const InputReaderConfiguration& readerConfig) {
453 ftl::Flags<InputDeviceClass> classes = contextPtr.getDeviceClasses();
Arpit Singh8e6fb252023-04-06 11:49:17 +0000454 std::vector<std::unique_ptr<InputMapper>> mappers;
455
456 // Switch-like devices.
457 if (classes.test(InputDeviceClass::SWITCH)) {
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000458 mappers.push_back(createInputMapper<SwitchInputMapper>(contextPtr, readerConfig));
Arpit Singh8e6fb252023-04-06 11:49:17 +0000459 }
460
461 // Scroll wheel-like devices.
462 if (classes.test(InputDeviceClass::ROTARY_ENCODER)) {
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000463 mappers.push_back(createInputMapper<RotaryEncoderInputMapper>(contextPtr, readerConfig));
Arpit Singh8e6fb252023-04-06 11:49:17 +0000464 }
465
466 // Vibrator-like devices.
467 if (classes.test(InputDeviceClass::VIBRATOR)) {
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000468 mappers.push_back(createInputMapper<VibratorInputMapper>(contextPtr, readerConfig));
Arpit Singh8e6fb252023-04-06 11:49:17 +0000469 }
470
471 // Battery-like devices or light-containing devices.
472 // PeripheralController will be created with associated EventHub device.
473 if (classes.test(InputDeviceClass::BATTERY) || classes.test(InputDeviceClass::LIGHT)) {
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000474 mController = std::make_unique<PeripheralController>(contextPtr);
Arpit Singh8e6fb252023-04-06 11:49:17 +0000475 }
476
477 // Keyboard-like devices.
478 uint32_t keyboardSource = 0;
479 int32_t keyboardType = AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC;
480 if (classes.test(InputDeviceClass::KEYBOARD)) {
481 keyboardSource |= AINPUT_SOURCE_KEYBOARD;
482 }
483 if (classes.test(InputDeviceClass::ALPHAKEY)) {
484 keyboardType = AINPUT_KEYBOARD_TYPE_ALPHABETIC;
485 }
486 if (classes.test(InputDeviceClass::DPAD)) {
487 keyboardSource |= AINPUT_SOURCE_DPAD;
488 }
489 if (classes.test(InputDeviceClass::GAMEPAD)) {
490 keyboardSource |= AINPUT_SOURCE_GAMEPAD;
491 }
492
493 if (keyboardSource != 0) {
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000494 mappers.push_back(createInputMapper<KeyboardInputMapper>(contextPtr, readerConfig,
Arpit Singh033e3ec2023-04-26 14:43:16 +0000495 keyboardSource, keyboardType));
Arpit Singh8e6fb252023-04-06 11:49:17 +0000496 }
497
498 // Cursor-like devices.
499 if (classes.test(InputDeviceClass::CURSOR)) {
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000500 mappers.push_back(createInputMapper<CursorInputMapper>(contextPtr, readerConfig));
Arpit Singh8e6fb252023-04-06 11:49:17 +0000501 }
502
503 // Touchscreens and touchpad devices.
504 static const bool ENABLE_TOUCHPAD_GESTURES_LIBRARY =
505 sysprop::InputProperties::enable_touchpad_gestures_library().value_or(true);
506 // TODO(b/272518665): Fix the new touchpad stack for Sony DualShock 4 (5c4, 9cc) touchpads, or
507 // at least load this setting from the IDC file.
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000508 const InputDeviceIdentifier identifier = contextPtr.getDeviceIdentifier();
Arpit Singh8e6fb252023-04-06 11:49:17 +0000509 const bool isSonyDualShock4Touchpad = identifier.vendor == 0x054c &&
510 (identifier.product == 0x05c4 || identifier.product == 0x09cc);
511 if (ENABLE_TOUCHPAD_GESTURES_LIBRARY && classes.test(InputDeviceClass::TOUCHPAD) &&
512 classes.test(InputDeviceClass::TOUCH_MT) && !isSonyDualShock4Touchpad) {
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000513 mappers.push_back(createInputMapper<TouchpadInputMapper>(contextPtr, readerConfig));
Arpit Singh8e6fb252023-04-06 11:49:17 +0000514 } else if (classes.test(InputDeviceClass::TOUCH_MT)) {
Arpit Singhd7053742023-05-18 16:56:41 +0000515 mappers.push_back(createInputMapper<MultiTouchInputMapper>(contextPtr, readerConfig));
Arpit Singh8e6fb252023-04-06 11:49:17 +0000516 } else if (classes.test(InputDeviceClass::TOUCH)) {
Arpit Singhd7053742023-05-18 16:56:41 +0000517 mappers.push_back(createInputMapper<SingleTouchInputMapper>(contextPtr, readerConfig));
Arpit Singh8e6fb252023-04-06 11:49:17 +0000518 }
519
520 // Joystick-like devices.
521 if (classes.test(InputDeviceClass::JOYSTICK)) {
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000522 mappers.push_back(createInputMapper<JoystickInputMapper>(contextPtr, readerConfig));
Arpit Singh8e6fb252023-04-06 11:49:17 +0000523 }
524
525 // Motion sensor enabled devices.
526 if (classes.test(InputDeviceClass::SENSOR)) {
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000527 mappers.push_back(createInputMapper<SensorInputMapper>(contextPtr, readerConfig));
Arpit Singh8e6fb252023-04-06 11:49:17 +0000528 }
529
530 // External stylus-like devices.
531 if (classes.test(InputDeviceClass::EXTERNAL_STYLUS)) {
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000532 mappers.push_back(createInputMapper<ExternalStylusInputMapper>(contextPtr, readerConfig));
Arpit Singh8e6fb252023-04-06 11:49:17 +0000533 }
534 return mappers;
535}
536
Siarhei Vishniakou74007942022-06-13 13:57:47 -0700537bool InputDevice::markSupportedKeyCodes(uint32_t sourceMask, const std::vector<int32_t>& keyCodes,
538 uint8_t* outFlags) {
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700539 bool result = false;
Siarhei Vishniakou74007942022-06-13 13:57:47 -0700540 for_each_mapper([&result, sourceMask, keyCodes, outFlags](InputMapper& mapper) {
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -0800541 if (sourcesMatchMask(mapper.getSources(), sourceMask)) {
Siarhei Vishniakou74007942022-06-13 13:57:47 -0700542 result |= mapper.markSupportedKeyCodes(sourceMask, keyCodes, outFlags);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700543 }
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -0800544 });
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700545 return result;
546}
547
Philip Junker4af3b3d2021-12-14 10:36:55 +0100548int32_t InputDevice::getKeyCodeForKeyLocation(int32_t locationKeyCode) const {
549 std::optional<int32_t> result = first_in_mappers<int32_t>(
550 [locationKeyCode](const InputMapper& mapper) -> std::optional<int32_t> const {
551 if (sourcesMatchMask(mapper.getSources(), AINPUT_SOURCE_KEYBOARD)) {
552 return std::make_optional(mapper.getKeyCodeForKeyLocation(locationKeyCode));
553 }
554 return std::nullopt;
555 });
556 if (!result) {
557 ALOGE("Failed to get key code for key location: No matching InputMapper with source mask "
558 "KEYBOARD found. The provided input device with id %d has sources %s.",
559 getId(), inputEventSourceToString(getSources()).c_str());
560 return AKEYCODE_UNKNOWN;
561 }
562 return *result;
563}
564
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700565std::list<NotifyArgs> InputDevice::vibrate(const VibrationSequence& sequence, ssize_t repeat,
566 int32_t token) {
567 std::list<NotifyArgs> out;
568 for_each_mapper([&](InputMapper& mapper) { out += mapper.vibrate(sequence, repeat, token); });
569 return out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700570}
571
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700572std::list<NotifyArgs> InputDevice::cancelVibrate(int32_t token) {
573 std::list<NotifyArgs> out;
574 for_each_mapper([&](InputMapper& mapper) { out += mapper.cancelVibrate(token); });
575 return out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700576}
577
Chris Ye87143712020-11-10 05:05:58 +0000578bool InputDevice::isVibrating() {
579 bool vibrating = false;
580 for_each_mapper([&vibrating](InputMapper& mapper) { vibrating |= mapper.isVibrating(); });
581 return vibrating;
582}
583
584/* There's no guarantee the IDs provided by the different mappers are unique, so if we have two
585 * different vibration mappers then we could have duplicate IDs.
586 * Alternatively, if we have a merged device that has multiple evdev nodes with FF_* capabilities,
587 * we would definitely have duplicate IDs.
588 */
589std::vector<int32_t> InputDevice::getVibratorIds() {
590 std::vector<int32_t> vibrators;
591 for_each_mapper([&vibrators](InputMapper& mapper) {
592 std::vector<int32_t> devVibs = mapper.getVibratorIds();
593 vibrators.reserve(vibrators.size() + devVibs.size());
594 vibrators.insert(vibrators.end(), devVibs.begin(), devVibs.end());
595 });
596 return vibrators;
597}
598
Chris Yef59a2f42020-10-16 12:55:26 -0700599bool InputDevice::enableSensor(InputDeviceSensorType sensorType,
600 std::chrono::microseconds samplingPeriod,
601 std::chrono::microseconds maxBatchReportLatency) {
602 bool success = true;
603 for_each_mapper(
604 [&success, sensorType, samplingPeriod, maxBatchReportLatency](InputMapper& mapper) {
605 success &= mapper.enableSensor(sensorType, samplingPeriod, maxBatchReportLatency);
606 });
607 return success;
608}
609
610void InputDevice::disableSensor(InputDeviceSensorType sensorType) {
611 for_each_mapper([sensorType](InputMapper& mapper) { mapper.disableSensor(sensorType); });
612}
613
614void InputDevice::flushSensor(InputDeviceSensorType sensorType) {
615 for_each_mapper([sensorType](InputMapper& mapper) { mapper.flushSensor(sensorType); });
616}
617
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700618std::list<NotifyArgs> InputDevice::cancelTouch(nsecs_t when, nsecs_t readTime) {
619 std::list<NotifyArgs> out;
620 for_each_mapper([&](InputMapper& mapper) { out += mapper.cancelTouch(when, readTime); });
621 return out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700622}
623
Chris Ye3fdbfef2021-01-06 18:45:18 -0800624bool InputDevice::setLightColor(int32_t lightId, int32_t color) {
Chris Yee2b1e5c2021-03-10 22:45:12 -0800625 return mController ? mController->setLightColor(lightId, color) : false;
Chris Ye3fdbfef2021-01-06 18:45:18 -0800626}
627
628bool InputDevice::setLightPlayerId(int32_t lightId, int32_t playerId) {
Chris Yee2b1e5c2021-03-10 22:45:12 -0800629 return mController ? mController->setLightPlayerId(lightId, playerId) : false;
Chris Ye3fdbfef2021-01-06 18:45:18 -0800630}
631
632std::optional<int32_t> InputDevice::getLightColor(int32_t lightId) {
Chris Yee2b1e5c2021-03-10 22:45:12 -0800633 return mController ? mController->getLightColor(lightId) : std::nullopt;
Chris Ye3fdbfef2021-01-06 18:45:18 -0800634}
635
636std::optional<int32_t> InputDevice::getLightPlayerId(int32_t lightId) {
Chris Yee2b1e5c2021-03-10 22:45:12 -0800637 return mController ? mController->getLightPlayerId(lightId) : std::nullopt;
Chris Ye3fdbfef2021-01-06 18:45:18 -0800638}
639
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700640int32_t InputDevice::getMetaState() {
641 int32_t result = 0;
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -0800642 for_each_mapper([&result](InputMapper& mapper) { result |= mapper.getMetaState(); });
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700643 return result;
644}
645
646void InputDevice::updateMetaState(int32_t keyCode) {
Arthur Hungcb40a002021-08-03 14:31:01 +0000647 first_in_mappers<bool>([keyCode](InputMapper& mapper) {
648 if (sourcesMatchMask(mapper.getSources(), AINPUT_SOURCE_KEYBOARD) &&
649 mapper.updateMetaState(keyCode)) {
650 return std::make_optional(true);
651 }
652 return std::optional<bool>();
653 });
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700654}
655
Vaibhav Devmuraricbba14c2022-10-10 16:54:49 +0000656void InputDevice::addKeyRemapping(int32_t fromKeyCode, int32_t toKeyCode) {
657 for_each_subdevice([fromKeyCode, toKeyCode](auto& context) {
658 context.addKeyRemapping(fromKeyCode, toKeyCode);
659 });
660}
661
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700662void InputDevice::bumpGeneration() {
663 mGeneration = mContext->bumpGeneration();
664}
665
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700666NotifyDeviceResetArgs InputDevice::notifyReset(nsecs_t when) {
667 return NotifyDeviceResetArgs(mContext->getNextId(), when, mId);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700668}
669
670std::optional<int32_t> InputDevice::getAssociatedDisplayId() {
671 // Check if we had associated to the specific display.
672 if (mAssociatedViewport) {
673 return mAssociatedViewport->displayId;
674 }
675
676 // No associated display port, check if some InputMapper is associated.
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -0800677 return first_in_mappers<int32_t>(
678 [](InputMapper& mapper) { return mapper.getAssociatedDisplayId(); });
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700679}
680
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800681// returns the number of mappers associated with the device
682size_t InputDevice::getMapperCount() {
683 size_t count = 0;
684 for (auto& deviceEntry : mDevices) {
685 auto& devicePair = deviceEntry.second;
686 auto& mappers = devicePair.second;
687 count += mappers.size();
688 }
689 return count;
690}
691
arthurhungc903df12020-08-11 15:08:42 +0800692void InputDevice::updateLedState(bool reset) {
693 for_each_mapper([reset](InputMapper& mapper) { mapper.updateLedState(reset); });
694}
695
Andy Chenf9f1a022022-08-29 20:07:10 -0400696std::optional<int32_t> InputDevice::getBatteryEventHubId() const {
697 return mController ? std::make_optional(mController->getEventHubId()) : std::nullopt;
698}
699
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800700InputDeviceContext::InputDeviceContext(InputDevice& device, int32_t eventHubId)
Nathaniel R. Lewis26ec2222020-01-10 16:30:54 -0800701 : mDevice(device),
702 mContext(device.getContext()),
703 mEventHub(device.getContext()->getEventHub()),
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800704 mId(eventHubId),
705 mDeviceId(device.getId()) {}
Nathaniel R. Lewis26ec2222020-01-10 16:30:54 -0800706
707InputDeviceContext::~InputDeviceContext() {}
708
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700709} // namespace android