Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4a88b461 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Prefer ScopedUtfChars where possible"

parents 0f60a8de 712de28e
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#define LOG_TAG "InputApplicationHandle"

#include <nativehelper/JNIHelp.h>
#include "nativehelper/scoped_utf_chars.h"
#include "jni.h"
#include <android_runtime/AndroidRuntime.h>
#include <utils/threads.h>
@@ -64,9 +65,8 @@ bool NativeInputApplicationHandle::updateInfo() {
    jstring nameObj = jstring(env->GetObjectField(obj,
            gInputApplicationHandleClassInfo.name));
    if (nameObj) {
        const char* nameStr = env->GetStringUTFChars(nameObj, NULL);
        mInfo->name = nameStr;
        env->ReleaseStringUTFChars(nameObj, nameStr);
        ScopedUtfChars nameChars(env, nameObj);
        mInfo->name = nameChars.c_str();
        env->DeleteLocalRef(nameObj);
    } else {
        mInfo->name = "<null>";
+3 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#define LOG_TAG "InputWindowHandle"

#include <nativehelper/JNIHelp.h>
#include "nativehelper/scoped_utf_chars.h"
#include "jni.h"
#include <android_runtime/AndroidRuntime.h>
#include <utils/threads.h>
@@ -102,9 +103,8 @@ bool NativeInputWindowHandle::updateInfo() {
    jstring nameObj = jstring(env->GetObjectField(obj,
            gInputWindowHandleClassInfo.name));
    if (nameObj) {
        const char* nameStr = env->GetStringUTFChars(nameObj, NULL);
        mInfo->name = nameStr;
        env->ReleaseStringUTFChars(nameObj, nameStr);
        ScopedUtfChars nameChars(env, nameObj);
        mInfo->name = nameChars.c_str();
        env->DeleteLocalRef(nameObj);
    } else {
        mInfo->name = "<null>";
+3 −4
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
#define LOG_TAG "InputChannel-JNI"

#include <nativehelper/JNIHelp.h>

#include "nativehelper/scoped_utf_chars.h"
#include <android_runtime/AndroidRuntime.h>
#include <binder/Parcel.h>
#include <utils/Log.h>
@@ -123,9 +123,8 @@ static jobject android_view_InputChannel_createInputChannel(JNIEnv* env,

static jobjectArray android_view_InputChannel_nativeOpenInputChannelPair(JNIEnv* env,
        jclass clazz, jstring nameObj) {
    const char* nameChars = env->GetStringUTFChars(nameObj, NULL);
    std::string name = nameChars;
    env->ReleaseStringUTFChars(nameObj, nameChars);
    ScopedUtfChars nameChars(env, nameObj);
    std::string name = nameChars.c_str();

    sp<InputChannel> serverChannel;
    sp<InputChannel> clientChannel;