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/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);