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
diff --git a/core/jni/android_hardware_display_DisplayViewport.cpp b/core/jni/android_hardware_display_DisplayViewport.cpp
index 23c3877..ab8e685 100644
--- a/core/jni/android_hardware_display_DisplayViewport.cpp
+++ b/core/jni/android_hardware_display_DisplayViewport.cpp
@@ -61,7 +61,7 @@
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 =
diff --git a/core/jni/android_view_InputDevice.cpp b/core/jni/android_view_InputDevice.cpp
index 494fad7..a698d66 100644
--- a/core/jni/android_view_InputDevice.cpp
+++ b/core/jni/android_view_InputDevice.cpp
@@ -37,13 +37,13 @@
} 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;
}
diff --git a/libs/input/Android.bp b/libs/input/Android.bp
index 67682a0..c5a6ec5 100644
--- a/libs/input/Android.bp
+++ b/libs/input/Android.bp
@@ -36,9 +36,8 @@
cflags: [
"-Wall",
+ "-Wextra",
"-Werror",
- "-Wunused",
- "-Wunreachable-code",
],
}
diff --git a/libs/input/PointerController.h b/libs/input/PointerController.h
index 4794f3d..eb3469e 100644
--- a/libs/input/PointerController.h
+++ b/libs/input/PointerController.h
@@ -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 {
diff --git a/libs/input/SpriteController.cpp b/libs/input/SpriteController.cpp
index 173cd50..eb2bc98 100644
--- a/libs/input/SpriteController.cpp
+++ b/libs/input/SpriteController.cpp
@@ -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>
diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp
index 52f2d67..b467d61 100644
--- a/services/core/jni/com_android_server_input_InputManagerService.cpp
+++ b/services/core/jni/com_android_server_input_InputManagerService.cpp
@@ -230,11 +230,11 @@
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 @@
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 @@
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 @@
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(
- 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 @@
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);
diff --git a/tools/validatekeymaps/Android.bp b/tools/validatekeymaps/Android.bp
index 6fb278c..819e75b 100644
--- a/tools/validatekeymaps/Android.bp
+++ b/tools/validatekeymaps/Android.bp
@@ -15,6 +15,7 @@
],
static_libs: [
+ "libbase",
"libinput",
"libutils",
"libcutils",
diff --git a/tools/validatekeymaps/Main.cpp b/tools/validatekeymaps/Main.cpp
index bbfcba6..f31f771 100644
--- a/tools/validatekeymaps/Main.cpp
+++ b/tools/validatekeymaps/Main.cpp
@@ -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 @@
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 @@
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 @@
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;