当前位置: 首页 > news >正文

如何做网站流量桂平seo关键词优化

如何做网站流量,桂平seo关键词优化,wordpress 太多重定向,岳阳市网站建设推广由前面的分析知道,在创建inputreader 线程的时候,会去循环执行 looponce 方法。主要的处理工作是: 通过 getEvents() 从 EventHub 获取未处理的事件,这些事件分为两类:一类是原始输入事 件即从设备节点中读取出的原始…

由前面的分析知道,在创建inputreader 线程的时候,会去循环执行 looponce 方法。主要的处理工作是:

  • 通过 getEvents() 从 EventHub 获取未处理的事件,这些事件分为两类:一类是原始输入事 件即从设备节点中读取出的原始事件;一类是设备事件即输入设备可用性变化事件
  • 通过 processEventsLocked() 对事件进行预处理

/frameworks/native/services/inputflinger/reader/InputReader.cpp

void InputReader::loopOnce() {int32_t oldGeneration;int32_t timeoutMillis;bool inputDevicesChanged = false;std::vector<InputDeviceInfo> inputDevices;{ // acquire lockstd::scoped_lock _l(mLock);oldGeneration = mGeneration;timeoutMillis = -1;uint32_t changes = mConfigurationChangesToRefresh;if (changes) {mConfigurationChangesToRefresh = 0;timeoutMillis = 0;refreshConfigurationLocked(changes);} else if (mNextTimeout != LLONG_MAX) {nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC);timeoutMillis = toMillisecondTimeoutDelay(now, mNextTimeout);}} // release lock// 1)首先去eventhub 中获取事件,缓存到 mEventBuffersize_t count = mEventHub->getEvents(timeoutMillis, mEventBuffer, EVENT_BUFFER_SIZE);{ // acquire lockstd::scoped_lock _l(mLock);mReaderIsAliveCondition.notify_all();if (count) {// 2)对 mEventBuffer 事件进行处理processEventsLocked(mEventBuffer, count);}

1)首先去eventhub 中获取事件,缓存到 mEventBuffer

 /frameworks/native/services/inputflinger/reader/EventHub.cpp

size_t EventHub::getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSize) {ALOG_ASSERT(bufferSize >= 1);std::scoped_lock _l(mLock);。。。。
//  初始值 mNeedToScanDevices 是为true 的if (mNeedToScanDevices) {mNeedToScanDevices = false;
// 去扫描设备 scanDevicesLockedscanDevicesLocked();mNeedToSendFinishedDeviceScan = true;}
// 遍历所有的打开的设备mOpeningDeviceswhile (!mOpeningDevices.empty()) {
// 获取设备 Devicestd::unique_ptr<Device> device = std::move(*mOpeningDevices.rbegin());mOpeningDevices.pop_back();ALOGV("Reporting device opened: id=%d, name=%s\n", device->id, device->path.c_str());event->when = now;event->deviceId = device->id == mBuiltInKeyboardId ? 0 : device->id;// 设置event事件类型是增加的DEVICE_ADDEDevent->type = DEVICE_ADDED;event += 1;// Try to find a matching video device by comparing device namesfor (auto it = mUnattachedVideoDevices.begin(); it != mUnattachedVideoDevices.end();it++) {std::unique_ptr<TouchVideoDevice>& videoDevice = *it;if (tryAddVideoDeviceLocked(*device, videoDevice)) {// videoDevice was transferred to 'device'it = mUnattachedVideoDevices.erase(it);break;}}// 然后将设备的id和设备保存到 mDevices 中auto [dev_it, inserted] = mDevices.insert_or_assign(device->id, std::move(device));

 // 扫描设备 scanDevicesLocked


// 扫描设备,path 为:DEVICE_PATH = "/dev/input";
void EventHub::scanDevicesLocked() {status_t result = scanDirLocked(DEVICE_PATH);=======
status_t EventHub::scanDirLocked(const std::string& dirname) {for (const auto& entry : std::filesystem::directory_iterator(dirname)) {// 打开所有的设备openDeviceLocked(entry.path());}=======
void EventHub::openDeviceLocked(const std::string& devicePath) {ALOGV("Opening device: %s", devicePath.c_str());// 打开驱动设备int fd = open(devicePath.c_str(), O_RDWR | O_CLOEXEC | O_NONBLOCK);。。。。。// Allocate device.  (The device object takes ownership of the fd at this point.)int32_t deviceId = mNextDeviceId++;
// 创建 Device 对象std::unique_ptr<Device> device = std::make_unique<Device>(fd, deviceId, devicePath, identifier);。。。。device->configureFd();// 增肌 device,会打印下列logALOGI("New device: id=%d, fd=%d, path='%s', name='%s', classes=%s, ""configuration='%s', keyLayout='%s', keyCharacterMap='%s', builtinKeyboard=%s, ",deviceId, fd, devicePath.c_str(), device->identifier.name.c_str(),device->classes.string().c_str(), device->configurationFile.c_str(),device->keyMap.keyLayoutFile.c_str(), device->keyMap.keyCharacterMapFile.c_str(),toString(mBuiltInKeyboardId == deviceId));// 将其增加到map 中addDeviceLocked(std::move(device));
}======
void EventHub::addDeviceLocked(std::unique_ptr<Device> device) {reportDeviceAddedForStatisticsLocked(device->identifier, device->classes);// 将其保存到已经打开的设备map 中mOpeningDevicesmOpeningDevices.push_back(std::move(device));
}

eventhub 将打开的设备保存到了 mOpeningDevices 中,在 InputReader 调用eventhub getevents的时候,去获取 mOpeningDevices先去eventhub 中获取事件,缓存到 mEventBuffer

2)对 mEventBuffer 事件进行处理

设置事件类型是增加的DEVICE_ADDED ,然后在inputreader 线程中处理 processEventsLocked

/frameworks/native/services/inputflinger/reader/InputReader.cpp

void InputReader::processEventsLocked(const RawEvent* rawEvents, size_t count) {for (const RawEvent* rawEvent = rawEvents; count;) {int32_t type = rawEvent->type;size_t batchSize = 1;if (type < EventHubInterface::FIRST_SYNTHETIC_EVENT) {int32_t deviceId = rawEvent->deviceId;while (batchSize < count) {if (rawEvent[batchSize].type >= EventHubInterface::FIRST_SYNTHETIC_EVENT ||rawEvent[batchSize].deviceId != deviceId) {break;}batchSize += 1;}
#if DEBUG_RAW_EVENTSALOGD("BatchSize: %zu Count: %zu", batchSize, count);
#endifprocessEventsForDeviceLocked(deviceId, rawEvent, batchSize);} else {switch (rawEvent->type) {case EventHubInterface::DEVICE_ADDED:// 处理设备增加的消息addDeviceLocked(rawEvent->when, rawEvent->deviceId);break;case EventHubInterface::DEVICE_REMOVED:removeDeviceLocked(rawEvent->when, rawEvent->deviceId);break;case EventHubInterface::FINISHED_DEVICE_SCAN:handleConfigurationChangedLocked(rawEvent->when);break;default:ALOG_ASSERT(false); // can't happenbreak;}}count -= batchSize;rawEvent += batchSize;}
}
void InputReader::addDeviceLocked(nsecs_t when, int32_t eventHubId) {if (mDevices.find(eventHubId) != mDevices.end()) {ALOGW("Ignoring spurious device added event for eventHubId %d.", eventHubId);return;}InputDeviceIdentifier identifier = mEventHub->getDeviceIdentifier(eventHubId);// 依据设备的id 创建了 inputdevice 对象std::shared_ptr<InputDevice> device = createDeviceLocked(eventHubId, identifier);device->configure(when, &mConfig, 0);device->reset(when);if (device->isIgnored()) {ALOGI("Device added: id=%d, eventHubId=%d, name='%s', descriptor='%s' ""(ignored non-input device)",device->getId(), eventHubId, identifier.name.c_str(), identifier.descriptor.c_str());} else {// 会打印下列log 增加了设备ALOGI("Device added: id=%d, eventHubId=%d, name='%s', descriptor='%s',sources=0x%08x",device->getId(), eventHubId, identifier.name.c_str(), identifier.descriptor.c_str(),device->getSources());}// 将id 和对应的device 增加到了 mDevices 中mDevices.emplace(eventHubId, device);// Add device to device to EventHub ids map.const auto mapIt = mDeviceToEventHubIdsMap.find(device);if (mapIt == mDeviceToEventHubIdsMap.end()) {std::vector<int32_t> ids = {eventHubId};mDeviceToEventHubIdsMap.emplace(device, ids);} else {mapIt->second.push_back(eventHubId);}bumpGenerationLocked();

// 依据设备的id 创建了 inputdevice 对象

std::shared_ptr<InputDevice> InputReader::createDeviceLocked(int32_t eventHubId, const InputDeviceIdentifier& identifier) {auto deviceIt = std::find_if(mDevices.begin(), mDevices.end(), [identifier](auto& devicePair) {return devicePair.second->getDescriptor().size() && identifier.descriptor.size() &&devicePair.second->getDescriptor() == identifier.descriptor;});std::shared_ptr<InputDevice> device;if (deviceIt != mDevices.end()) {device = deviceIt->second;} else {int32_t deviceId = (eventHubId < END_RESERVED_ID) ? eventHubId : nextInputDeviceIdLocked();// 创建了 InputDevice 对象device = std::make_shared<InputDevice>(&mContext, deviceId, bumpGenerationLocked(),identifier);}// 调用方法 addEventHubDevicedevice->addEventHubDevice(eventHubId);return device;
}

// 调用方法 addEventHubDevice

/frameworks/native/services/inputflinger/reader/InputDevice.cpp

New device: id=2, fd=246, path='/dev/input/event4', name='adaptive_ts', classes=TOUCH | TOUCH_MT 

void InputDevice::addEventHubDevice(int32_t eventHubId, bool populateMappers) {if (mDevices.find(eventHubId) != mDevices.end()) {return;}/ / 创建了 InputDeviceContext 对象,传入this 对象和 eventHubIdstd::unique_ptr<InputDeviceContext> contextPtr(new InputDeviceContext(*this, eventHubId));Flags<InputDeviceClass> classes = contextPtr->getDeviceClasses();std::vector<std::unique_ptr<InputMapper>> mappers;// Check if we should skip populationif (!populateMappers) {mDevices.insert({eventHubId, std::make_pair(std::move(contextPtr), std::move(mappers))});return;}// 然后依据不同的设备创建不同的 mapper:SwitchInputMapper
// 将其放到 mappers 中// Switch-like devices.if (classes.test(InputDeviceClass::SWITCH)) {mappers.push_back(std::make_unique<SwitchInputMapper>(*contextPtr));}// 下列是多点触控和单触控的// Touchscreens and touchpad devices.if (classes.test(InputDeviceClass::TOUCH_MT)) {mappers.push_back(std::make_unique<MultiTouchInputMapper>(*contextPtr));} else if (classes.test(InputDeviceClass::TOUCH)) {mappers.push_back(std::make_unique<SingleTouchInputMapper>(*contextPtr));}。。。。// insert the context into the devices set
// 最后将其保存到 mDevices 中mDevices.insert({eventHubId, std::make_pair(std::move(contextPtr), std::move(mappers))});

MultiTouchInputMapper 多点触控是继承了 TouchInputMapper

class MultiTouchInputMapper : public TouchInputMapper

/frameworks/native/services/inputflinger/reader/mapper/InputMapper.h

47      inline InputDeviceContext& getDeviceContext() { return mDeviceContext; }
48      inline const std::string getDeviceName() { return mDeviceContext.getName(); }
49      inline InputReaderContext* getContext() { return mDeviceContext.getContext(); }
50      inline InputReaderPolicyInterface* getPolicy() { return getContext()->getPolicy(); }// getContext 获取的值是 inputreader::contextimpl 对象,在获取getListener,则是
51      inline InputListenerInterface* getListener() { return getContext()->getListener(); }=======
/frameworks/native/services/inputflinger/reader/InputReader.cppInputListenerInterface* InputReader::ContextImpl::getListener() {// 获取的是  mQueuedListenerreturn mReader->mQueuedListener.get();
}

http://www.shuangfujiaoyu.com/news/42092.html

相关文章:

  • wordpress bt影视青岛seo网站管理
  • 白山网站seo上海牛巨微seo关键词优化
  • 怎样用java做网站爱站关键词挖掘
  • 网站制作编辑软件百度浏览器app
  • 网站开发外包售后维护合同seo顾问服务深圳
  • 企业怎样选择域名做网站中国市场营销网网站
  • 成都热点新闻最新网站seo基础优化
  • 网络推广策划书seo销售
  • 网站开发合同注意事项网站设计方案模板
  • 织梦英文版网站怎么做2345网址导航下载桌面
  • wordpress模板脚步代码哪里修改百度seo关键词优化电话
  • 织梦网站怎么做301跳转seo技术培训价格表
  • 做网站 以图搜货深圳推广公司排行榜
  • 如何做网站热线电话站长之家素材
  • 网站建设 广州app拉新一手渠道
  • 做灯带的网站原画培训机构哪里好
  • 免费营销软件网站建设竞价推广员月挣多少
  • 自适应网站制作江苏做网站的公司有哪些
  • 长沙做网站建设价格网络市场调研的五个步骤
  • 虚拟机做网站网络营销的营销方式
  • 网站产品优化方案百度关键词刷搜索量
  • 专注企业网站建设外贸seo推广招聘
  • 找人做网站都要提供什么下载百度搜索
  • ui设计界面设计seo外贸推广
  • 简单的做海报的网站国外引流推广软件
  • 求网站建设规划万网域名注册查询
  • 网站后台构建seo研究中心超逸seo
  • 电脑课做网站所需的软件最新国际新闻 大事件
  • 建设大型视频网站需要的资金量哈尔滨优化调整人员流动管理
  • wordpress taobaoke超云seo优化