From f8358d3d055bb91a43c5fe41ddcb712b449809c2 Mon Sep 17 00:00:00 2001 From: Arthur Hung Date: Mon, 11 Mar 2019 11:54:56 +0800 Subject: [PATCH] User std::vector over Vector for InputFlinger (2/3) Replace Vector with std::vector. Bug: 112399697 Test: atest inputflinger_tests Change-Id: I258687a990c3e27a1e54bf3739fee854e03c1b8e --- core/jni/android_view_InputDevice.cpp | 5 ++--- .../com_android_server_input_InputManagerService.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/core/jni/android_view_InputDevice.cpp b/core/jni/android_view_InputDevice.cpp index a698d66965e44..9f4e3e516adaa 100644 --- a/core/jni/android_view_InputDevice.cpp +++ b/core/jni/android_view_InputDevice.cpp @@ -68,9 +68,8 @@ jobject android_view_InputDevice_create(JNIEnv* env, const InputDeviceInfo& devi deviceInfo.getKeyboardType(), kcmObj.get(), deviceInfo.hasVibrator(), hasMic, deviceInfo.hasButtonUnderPad())); - const Vector& ranges = deviceInfo.getMotionRanges(); - for (size_t i = 0; i < ranges.size(); i++) { - const InputDeviceInfo::MotionRange& range = ranges.itemAt(i); + const std::vector& ranges = deviceInfo.getMotionRanges(); + for (const InputDeviceInfo::MotionRange& range: ranges) { env->CallVoidMethod(inputDeviceObj.get(), gInputDeviceClassInfo.addMotionRange, range.axis, range.source, range.min, range.max, range.flat, range.fuzz, range.resolution); if (env->ExceptionCheck()) { diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp index 57377c633c9a0..3d84bd40fb5a8 100644 --- a/services/core/jni/com_android_server_input_InputManagerService.cpp +++ b/services/core/jni/com_android_server_input_InputManagerService.cpp @@ -228,7 +228,7 @@ public: virtual void getReaderConfiguration(InputReaderConfiguration* outConfig); virtual sp obtainPointerController(int32_t deviceId); - virtual void notifyInputDevicesChanged(const Vector& inputDevices); + virtual void notifyInputDevicesChanged(const std::vector& inputDevices); virtual sp getKeyboardLayoutOverlay(const InputDeviceIdentifier& identifier); virtual std::string getDeviceAlias(const InputDeviceIdentifier& identifier); virtual TouchAffineTransformation getTouchAffineTransformation(JNIEnv *env, @@ -598,7 +598,7 @@ void NativeInputManager::ensureSpriteControllerLocked() REQUIRES(mLock) { } } -void NativeInputManager::notifyInputDevicesChanged(const Vector& inputDevices) { +void NativeInputManager::notifyInputDevicesChanged(const std::vector& inputDevices) { ATRACE_CALL(); JNIEnv* env = jniEnv(); @@ -608,7 +608,7 @@ void NativeInputManager::notifyInputDevicesChanged(const Vector if (inputDevicesObjArray) { bool error = false; for (size_t i = 0; i < count; i++) { - jobject inputDeviceObj = android_view_InputDevice_create(env, inputDevices.itemAt(i)); + jobject inputDeviceObj = android_view_InputDevice_create(env, inputDevices[i]); if (!inputDeviceObj) { error = true; break; @@ -775,7 +775,7 @@ void NativeInputManager::getDispatcherConfiguration(InputDispatcherConfiguration void NativeInputManager::setInputWindows(JNIEnv* env, jobjectArray windowHandleObjArray, int32_t displayId) { - Vector > windowHandles; + std::vector > windowHandles; if (windowHandleObjArray) { jsize length = env->GetArrayLength(windowHandleObjArray); @@ -788,7 +788,7 @@ void NativeInputManager::setInputWindows(JNIEnv* env, jobjectArray windowHandleO sp windowHandle = android_view_InputWindowHandle_getHandle(env, windowHandleObj); if (windowHandle != nullptr) { - windowHandles.push(windowHandle); + windowHandles.push_back(windowHandle); } env->DeleteLocalRef(windowHandleObj); } @@ -800,7 +800,7 @@ void NativeInputManager::setInputWindows(JNIEnv* env, jobjectArray windowHandleO bool newPointerGesturesEnabled = true; size_t numWindows = windowHandles.size(); for (size_t i = 0; i < numWindows; i++) { - const sp& windowHandle = windowHandles.itemAt(i); + const sp& windowHandle = windowHandles[i]; const InputWindowInfo* windowInfo = windowHandle->getInfo(); if (windowInfo && windowInfo->hasFocus && (windowInfo->inputFeatures & InputWindowInfo::INPUT_FEATURE_DISABLE_TOUCH_PAD_GESTURES)) {