From 2e82e62cdc0845173d9291848ac99858e3d40c81 Mon Sep 17 00:00:00 2001 From: Siarhei Vishniakou Date: Fri, 10 Jul 2020 14:40:18 -0500 Subject: [PATCH] Use unique_ptr when creating InputChannel To highlight the point where input channel becomes shared, use unique_ptr in the create methods. Bug: 142581626 Test: presubmit Change-Id: I1d2738bae77266ca05034c2e6d9393825a52aa60 --- core/jni/android_view_InputChannel.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/jni/android_view_InputChannel.cpp b/core/jni/android_view_InputChannel.cpp index 8459410bccd14..2436b23a45d09 100644 --- a/core/jni/android_view_InputChannel.cpp +++ b/core/jni/android_view_InputChannel.cpp @@ -122,8 +122,8 @@ static jlongArray android_view_InputChannel_nativeOpenInputChannelPair(JNIEnv* e ScopedUtfChars nameChars(env, nameObj); std::string name = nameChars.c_str(); - std::shared_ptr serverChannel; - std::shared_ptr clientChannel; + std::unique_ptr serverChannel; + std::unique_ptr clientChannel; status_t result = InputChannel::openInputChannelPair(name, serverChannel, clientChannel); if (result) { @@ -139,12 +139,12 @@ static jlongArray android_view_InputChannel_nativeOpenInputChannelPair(JNIEnv* e } jlong* outArray = env->GetLongArrayElements(channelPair, 0); - outArray[0] = android_view_InputChannel_createInputChannel(env, serverChannel); + outArray[0] = android_view_InputChannel_createInputChannel(env, std::move(serverChannel)); if (env->ExceptionCheck()) { return nullptr; } - outArray[1] = android_view_InputChannel_createInputChannel(env, clientChannel); + outArray[1] = android_view_InputChannel_createInputChannel(env, std::move(clientChannel)); if (env->ExceptionCheck()) { return nullptr; }