From 5b7a0cd8e958946a51409767630cb43504807b0f Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Thu, 17 Oct 2019 22:11:39 +0200 Subject: [PATCH] Extract String literal to static constant --- .../com/genymobile/scrcpy/wrappers/ClipboardManager.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java index 7dc2e75e..5cc71cd4 100644 --- a/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java +++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java @@ -9,6 +9,9 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class ClipboardManager { + + private static final String PACKAGE_NAME = "com.android.shell"; + private final IInterface manager; private Method getPrimaryClipMethod; private Method setPrimaryClipMethod; @@ -45,7 +48,7 @@ public class ClipboardManager { return null; } try { - ClipData clipData = (ClipData) method.invoke(manager, "com.android.shell"); + ClipData clipData = (ClipData) method.invoke(manager, PACKAGE_NAME); if (clipData == null || clipData.getItemCount() == 0) { return null; } @@ -63,7 +66,7 @@ public class ClipboardManager { } ClipData clipData = ClipData.newPlainText(null, text); try { - method.invoke(manager, clipData, "com.android.shell"); + method.invoke(manager, clipData, PACKAGE_NAME); } catch (InvocationTargetException | IllegalAccessException e) { Ln.e("Could not invoke " + method.getName(), e); }