Refactor String8 to std::string calls
DisplayViewport::uniqueId is now std::string, so change the calls appropriately. Do some additional cleanups and conversions. This almost completely removes the dependency on String8. Test: build only Bug: 111108021 Change-Id: Ibbb6ca59e9061954d4a5fb930ef03d42cb0230db
This commit is contained in:
@@ -61,7 +61,7 @@ status_t android_hardware_display_DisplayViewport_toNative(JNIEnv* env, jobject
|
||||
jstring uniqueId =
|
||||
jstring(env->GetObjectField(viewportObj, gDisplayViewportClassInfo.uniqueId));
|
||||
if (uniqueId != nullptr) {
|
||||
viewport->uniqueId.setTo(ScopedUtfChars(env, uniqueId).c_str());
|
||||
viewport->uniqueId = ScopedUtfChars(env, uniqueId).c_str();
|
||||
}
|
||||
|
||||
jobject logicalFrameObj =
|
||||
|
||||
@@ -37,13 +37,13 @@ static struct {
|
||||
} gInputDeviceClassInfo;
|
||||
|
||||
jobject android_view_InputDevice_create(JNIEnv* env, const InputDeviceInfo& deviceInfo) {
|
||||
ScopedLocalRef<jstring> nameObj(env, env->NewStringUTF(deviceInfo.getDisplayName().string()));
|
||||
ScopedLocalRef<jstring> nameObj(env, env->NewStringUTF(deviceInfo.getDisplayName().c_str()));
|
||||
if (!nameObj.get()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ScopedLocalRef<jstring> descriptorObj(env,
|
||||
env->NewStringUTF(deviceInfo.getIdentifier().descriptor.string()));
|
||||
env->NewStringUTF(deviceInfo.getIdentifier().descriptor.c_str()));
|
||||
if (!descriptorObj.get()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -36,9 +36,8 @@ cc_library_shared {
|
||||
|
||||
cflags: [
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-Werror",
|
||||
"-Wunused",
|
||||
"-Wunreachable-code",
|
||||
],
|
||||
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <utils/BitSet.h>
|
||||
#include <utils/RefBase.h>
|
||||
#include <utils/Looper.h>
|
||||
#include <utils/String8.h>
|
||||
#include <gui/DisplayEventReceiver.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
@@ -23,14 +23,10 @@
|
||||
#include <utils/String8.h>
|
||||
#include <gui/Surface.h>
|
||||
|
||||
// ToDo: Fix code to be warning free
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#include <SkBitmap.h>
|
||||
#include <SkCanvas.h>
|
||||
#include <SkColor.h>
|
||||
#include <SkPaint.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include <android/native_window.h>
|
||||
|
||||
|
||||
@@ -230,11 +230,11 @@ public:
|
||||
virtual sp<PointerControllerInterface> obtainPointerController(int32_t deviceId);
|
||||
virtual void notifyInputDevicesChanged(const Vector<InputDeviceInfo>& inputDevices);
|
||||
virtual sp<KeyCharacterMap> getKeyboardLayoutOverlay(const InputDeviceIdentifier& identifier);
|
||||
virtual String8 getDeviceAlias(const InputDeviceIdentifier& identifier);
|
||||
virtual std::string getDeviceAlias(const InputDeviceIdentifier& identifier);
|
||||
virtual TouchAffineTransformation getTouchAffineTransformation(JNIEnv *env,
|
||||
jfloatArray matrixArr);
|
||||
virtual TouchAffineTransformation getTouchAffineTransformation(
|
||||
const String8& inputDeviceDescriptor, int32_t surfaceRotation);
|
||||
const std::string& inputDeviceDescriptor, int32_t surfaceRotation);
|
||||
|
||||
/* --- InputDispatcherPolicyInterface implementation --- */
|
||||
|
||||
@@ -480,7 +480,7 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon
|
||||
for (jsize i = 0; i < length; i++) {
|
||||
jstring item = jstring(env->GetObjectArrayElement(excludedDeviceNames, i));
|
||||
const char* deviceNameChars = env->GetStringUTFChars(item, NULL);
|
||||
outConfig->excludedDeviceNames.add(String8(deviceNameChars));
|
||||
outConfig->excludedDeviceNames.push_back(deviceNameChars);
|
||||
env->ReleaseStringUTFChars(item, deviceNameChars);
|
||||
env->DeleteLocalRef(item);
|
||||
}
|
||||
@@ -606,7 +606,7 @@ sp<KeyCharacterMap> NativeInputManager::getKeyboardLayoutOverlay(
|
||||
JNIEnv* env = jniEnv();
|
||||
|
||||
sp<KeyCharacterMap> result;
|
||||
ScopedLocalRef<jstring> descriptor(env, env->NewStringUTF(identifier.descriptor.string()));
|
||||
ScopedLocalRef<jstring> descriptor(env, env->NewStringUTF(identifier.descriptor.c_str()));
|
||||
ScopedLocalRef<jobject> identifierObj(env, env->NewObject(gInputDeviceIdentifierInfo.clazz,
|
||||
gInputDeviceIdentifierInfo.constructor, descriptor.get(),
|
||||
identifier.vendor, identifier.product));
|
||||
@@ -620,24 +620,24 @@ sp<KeyCharacterMap> NativeInputManager::getKeyboardLayoutOverlay(
|
||||
ScopedUtfChars filenameChars(env, filenameObj.get());
|
||||
ScopedUtfChars contentsChars(env, contentsObj.get());
|
||||
|
||||
KeyCharacterMap::loadContents(String8(filenameChars.c_str()),
|
||||
String8(contentsChars.c_str()), KeyCharacterMap::FORMAT_OVERLAY, &result);
|
||||
KeyCharacterMap::loadContents(filenameChars.c_str(),
|
||||
contentsChars.c_str(), KeyCharacterMap::FORMAT_OVERLAY, &result);
|
||||
}
|
||||
checkAndClearExceptionFromCallback(env, "getKeyboardLayoutOverlay");
|
||||
return result;
|
||||
}
|
||||
|
||||
String8 NativeInputManager::getDeviceAlias(const InputDeviceIdentifier& identifier) {
|
||||
std::string NativeInputManager::getDeviceAlias(const InputDeviceIdentifier& identifier) {
|
||||
ATRACE_CALL();
|
||||
JNIEnv* env = jniEnv();
|
||||
|
||||
ScopedLocalRef<jstring> uniqueIdObj(env, env->NewStringUTF(identifier.uniqueId.string()));
|
||||
ScopedLocalRef<jstring> uniqueIdObj(env, env->NewStringUTF(identifier.uniqueId.c_str()));
|
||||
ScopedLocalRef<jstring> aliasObj(env, jstring(env->CallObjectMethod(mServiceObj,
|
||||
gServiceClassInfo.getDeviceAlias, uniqueIdObj.get())));
|
||||
String8 result;
|
||||
std::string result;
|
||||
if (aliasObj.get()) {
|
||||
ScopedUtfChars aliasChars(env, aliasObj.get());
|
||||
result.setTo(aliasChars.c_str());
|
||||
result = aliasChars.c_str();
|
||||
}
|
||||
checkAndClearExceptionFromCallback(env, "getDeviceAlias");
|
||||
return result;
|
||||
@@ -932,10 +932,10 @@ TouchAffineTransformation NativeInputManager::getTouchAffineTransformation(
|
||||
}
|
||||
|
||||
TouchAffineTransformation NativeInputManager::getTouchAffineTransformation(
|
||||
const String8& inputDeviceDescriptor, int32_t surfaceRotation) {
|
||||
const std::string& inputDeviceDescriptor, int32_t surfaceRotation) {
|
||||
JNIEnv* env = jniEnv();
|
||||
|
||||
ScopedLocalRef<jstring> descriptorObj(env, env->NewStringUTF(inputDeviceDescriptor.string()));
|
||||
ScopedLocalRef<jstring> descriptorObj(env, env->NewStringUTF(inputDeviceDescriptor.c_str()));
|
||||
|
||||
jobject cal = env->CallObjectMethod(mServiceObj,
|
||||
gServiceClassInfo.getTouchCalibrationForInputDevice, descriptorObj.get(),
|
||||
@@ -1281,7 +1281,7 @@ static void nativeSetDisplayViewport(JNIEnv* env, jclass /* clazz */, jlong ptr,
|
||||
v.deviceWidth = deviceWidth;
|
||||
v.deviceHeight = deviceHeight;
|
||||
if (uniqueId != nullptr) {
|
||||
v.uniqueId.setTo(ScopedUtfChars(env, uniqueId).c_str());
|
||||
v.uniqueId = ScopedUtfChars(env, uniqueId).c_str();
|
||||
}
|
||||
|
||||
im->setDisplayViewport(viewportType, v);
|
||||
|
||||
@@ -15,6 +15,7 @@ cc_binary_host {
|
||||
],
|
||||
|
||||
static_libs: [
|
||||
"libbase",
|
||||
"libinput",
|
||||
"libutils",
|
||||
"libcutils",
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <input/KeyLayoutMap.h>
|
||||
#include <input/VirtualKeyMap.h>
|
||||
#include <utils/PropertyMap.h>
|
||||
#include <utils/String8.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
@@ -98,7 +97,7 @@ static bool validateFile(const char* filename) {
|
||||
|
||||
case FILETYPE_KEYLAYOUT: {
|
||||
sp<KeyLayoutMap> map;
|
||||
status_t status = KeyLayoutMap::load(String8(filename), &map);
|
||||
status_t status = KeyLayoutMap::load(filename, &map);
|
||||
if (status) {
|
||||
error("Error %d parsing key layout file.\n\n", status);
|
||||
return false;
|
||||
@@ -108,7 +107,7 @@ static bool validateFile(const char* filename) {
|
||||
|
||||
case FILETYPE_KEYCHARACTERMAP: {
|
||||
sp<KeyCharacterMap> map;
|
||||
status_t status = KeyCharacterMap::load(String8(filename),
|
||||
status_t status = KeyCharacterMap::load(filename,
|
||||
KeyCharacterMap::FORMAT_ANY, &map);
|
||||
if (status) {
|
||||
error("Error %d parsing key character map file.\n\n", status);
|
||||
@@ -130,7 +129,7 @@ static bool validateFile(const char* filename) {
|
||||
|
||||
case FILETYPE_VIRTUALKEYDEFINITION: {
|
||||
VirtualKeyMap* map;
|
||||
status_t status = VirtualKeyMap::load(String8(filename), &map);
|
||||
status_t status = VirtualKeyMap::load(filename, &map);
|
||||
if (status) {
|
||||
error("Error %d parsing virtual key definition file.\n\n", status);
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user