Program: 34128
Project: 34128
Buggy source:
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
  XposedHelpers.findAndHookMethod(TextView.class,"String_Node_Str",boolean.class,int.class,Rect.class,new XC_MethodHook(){
    @Override protected void afterHookedMethod(    MethodHookParam param) throws Throwable {
      TextView textView=(TextView)param.thisObject;
      boolean isEditText=textView instanceof EditText;
      if (!isEditText)       return;
      boolean focused=(Boolean)param.args[0];
      if (focused) {
        Etextview=textView;
        Ectx=Etextview.getContext();
        Log.d("String_Node_Str","String_Node_Str");
      }
    }
  }
);
  if (pref.getBoolean("String_Node_Str",true)) {
    XposedHelpers.findAndHookMethod("String_Node_Str",lpparam.classLoader,"String_Node_Str",ActionMode.class,Menu.class,new XC_MethodHook(){
      @Override protected void afterHookedMethod(      MethodHookParam param) throws Throwable {
        menu=(Menu)param.args[1];
        CBButton(menu);
      }
    }
);
    XposedHelpers.findAndHookMethod("String_Node_Str",lpparam.classLoader,"String_Node_Str",ActionMode.class,MenuItem.class,new XC_MethodHook(){
      @Override protected void afterHookedMethod(      final MethodHookParam param) throws Throwable {
        MenuItem item=(MenuItem)param.args[1];
switch (item.getItemId()) {
case id:
          Open(Ectx);
        final int start=Etextview.getSelectionStart();
      final int end=Etextview.getSelectionEnd();
    mClipboardManager=(ClipboardManager)Ectx.getSystemService(Context.CLIPBOARD_SERVICE);
  mOnPrimaryClipChangedListener=new ClipboardManager.OnPrimaryClipChangedListener(){
    @Override public void onPrimaryClipChanged(){
      if (mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(Ectx).toString().equals("String_Node_Str")) {
        try {
          mClipboardManager.removePrimaryClipChangedListener(mOnPrimaryClipChangedListener);
        }
 catch (        Exception e1) {
          Toast.makeText(Ectx,"String_Node_Str",Toast.LENGTH_SHORT).show();
          e1.printStackTrace();
        }
      }
 else       if (pref.getBoolean("String_Node_Str",false)) {
        try {
          mClipboardManager.removePrimaryClipChangedListener(mOnPrimaryClipChangedListener);
        }
 catch (        Exception e1) {
          Toast.makeText(Ectx,"String_Node_Str",Toast.LENGTH_SHORT).show();
          e1.printStackTrace();
        }
        try {
          Etextview.setText(Etextview.getText().subSequence(0,start).toString() + mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(Ectx).toString() + Etextview.getText().subSequence(end,Etextview.getText().length()).toString());
          Selection.setSelection((Spannable)Etextview.getText(),start + mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(Ectx).length());
        }
 catch (        Throwable e) {
          Toast.makeText(Ectx,"String_Node_Str",Toast.LENGTH_SHORT).show();
          e.printStackTrace();
        }
      }
 else {
        try {
          Etextview.setText(Etextview.getText().subSequence(0,start).toString() + mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(Ectx).toString() + Etextview.getText().subSequence(end,Etextview.getText().length()).toString());
          Selection.setSelection((Spannable)Etextview.getText(),start + mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(Ectx).length());
        }
 catch (        Throwable e) {
          Toast.makeText(Ectx,"String_Node_Str",Toast.LENGTH_SHORT).show();
          e.printStackTrace();
        }
      }
    }
  }
;
mClipboardManager.addPrimaryClipChangedListener(mOnPrimaryClipChangedListener);
param.setResult(true);
return;
}
}
}
);
}
if (pref.getBoolean("String_Node_Str",false)) {
XposedHelpers.findAndHookMethod("String_Node_Str",lpparam.classLoader,"String_Node_Str",View.class,new XC_MethodHook(){
@Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
TextView text=(TextView)param.args[0];
if (Resources.getSystem().getString(android.R.string.paste).equals(text.getText().toString())) {
Open(Ectx);
final int start=Etextview.getSelectionStart();
final int end=Etextview.getSelectionEnd();
mClipboardManager=(ClipboardManager)Ectx.getSystemService(Context.CLIPBOARD_SERVICE);
mOnPrimaryClipChangedListener=new ClipboardManager.OnPrimaryClipChangedListener(){
@Override public void onPrimaryClipChanged(){
if (mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(Ectx).toString().equals("String_Node_Str")) {
try {
  mClipboardManager.removePrimaryClipChangedListener(mOnPrimaryClipChangedListener);
}
 catch (Exception e1) {
  Toast.makeText(Ectx,"String_Node_Str",Toast.LENGTH_SHORT).show();
  e1.printStackTrace();
}
}
 else if (pref.getBoolean("String_Node_Str",false)) {
try {
  mClipboardManager.removePrimaryClipChangedListener(mOnPrimaryClipChangedListener);
}
 catch (Exception e1) {
  Toast.makeText(Ectx,"String_Node_Str",Toast.LENGTH_SHORT).show();
  e1.printStackTrace();
}
try {
  Etextview.setText(Etextview.getText().subSequence(0,start).toString() + mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(Ectx).toString() + Etextview.getText().subSequence(end,Etextview.getText().length()).toString());
  Selection.setSelection((Spannable)Etextview.getText(),start + mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(Ectx).length());
}
 catch (Throwable e) {
  Toast.makeText(Ectx,"String_Node_Str",Toast.LENGTH_SHORT).show();
  e.printStackTrace();
}
}
 else {
try {
  Etextview.setText(Etextview.getText().subSequence(0,start).toString() + mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(Ectx).toString() + Etextview.getText().subSequence(end,Etextview.getText().length()).toString());
  Selection.setSelection((Spannable)Etextview.getText(),start + mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(Ectx).length());
}
 catch (Throwable e) {
  Toast.makeText(Ectx,"String_Node_Str",Toast.LENGTH_SHORT).show();
  e.printStackTrace();
}
}
}
}
;
mClipboardManager.addPrimaryClipChangedListener(mOnPrimaryClipChangedListener);
param.setResult(null);
return;
}
}
}
);
}
if (lpparam.packageName.equals("String_Node_Str") || lpparam.packageName.equals("String_Node_Str")) {
if (pref.getBoolean("String_Node_Str",true)) {
XposedHelpers.findAndHookMethod("String_Node_Str",lpparam.classLoader,"String_Node_Str",ActionMode.class,Menu.class,new XC_MethodHook(){
@Override protected void afterHookedMethod(MethodHookParam param) throws Throwable {
menu=(Menu)param.args[1];
CBButton(menu);
}
}
);
XposedHelpers.findAndHookMethod("String_Node_Str",lpparam.classLoader,"String_Node_Str",ActionMode.class,MenuItem.class,new XC_MethodHook(){
@Override protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
Object[] args={};
CSctx=(Context)XposedHelpers.findMethodBestMatch(XposedHelpers.findClass("String_Node_Str",lpparam.classLoader),"String_Node_Str").invoke(param.thisObject,args);
MenuItem item=(MenuItem)param.args[1];
mparam=param;
switch (item.getItemId()) {
case id:
Open(CSctx);
mparam.args[1]=menu.getItem(3);
mClipboardManager=(ClipboardManager)CSctx.getSystemService(Context.CLIPBOARD_SERVICE);
mOnPrimaryClipChangedListener=new ClipboardManager.OnPrimaryClipChangedListener(){
@Override public void onPrimaryClipChanged(){
if (mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(CPctx).toString().equals("String_Node_Str")) {
try {
mClipboardManager.removePrimaryClipChangedListener(mOnPrimaryClipChangedListener);
}
 catch (Exception e1) {
Toast.makeText(Ectx,"String_Node_Str",Toast.LENGTH_SHORT).show();
e1.printStackTrace();
}
}
 else if (pref.getBoolean("String_Node_Str",false)) {
try {
mClipboardManager.removePrimaryClipChangedListener(mOnPrimaryClipChangedListener);
}
 catch (Exception e1) {
Toast.makeText(Ectx,"String_Node_Str",Toast.LENGTH_SHORT).show();
e1.printStackTrace();
}
try {
XposedHelpers.callMethod(mparam.thisObject,"String_Node_Str",mparam.args);
}
 catch (Throwable e) {
Toast.makeText(CSctx,"String_Node_Str",Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
 else {
try {
XposedHelpers.callMethod(mparam.thisObject,"String_Node_Str",mparam.args);
}
 catch (Throwable e) {
Toast.makeText(CSctx,"String_Node_Str",Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
}
}
;
mClipboardManager.addPrimaryClipChangedListener(mOnPrimaryClipChangedListener);
param.setResult(true);
return;
}
}
}
);
}
XposedHelpers.findAndHookMethod("String_Node_Str",lpparam.classLoader,"String_Node_Str",View.class,new XC_MethodHook(){
@Override protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
View mview=(View)param.args[0];
CPctx=mview.getContext();
Open(CPctx);
mClipboardManager=(ClipboardManager)CPctx.getSystemService(Context.CLIPBOARD_SERVICE);
mOnPrimaryClipChangedListener=new ClipboardManager.OnPrimaryClipChangedListener(){
@Override public void onPrimaryClipChanged(){
if (mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(CPctx).toString().equals("String_Node_Str")) {
try {
mClipboardManager.removePrimaryClipChangedListener(mOnPrimaryClipChangedListener);
}
 catch (Exception e1) {
Toast.makeText(Ectx,"String_Node_Str",Toast.LENGTH_SHORT).show();
e1.printStackTrace();
}
}
 else if (pref.getBoolean("String_Node_Str",false)) {
try {
mClipboardManager.removePrimaryClipChangedListener(mOnPrimaryClipChangedListener);
}
 catch (Exception e1) {
Toast.makeText(Ectx,"String_Node_Str",Toast.LENGTH_SHORT).show();
e1.printStackTrace();
}
try {
XposedBridge.invokeOriginalMethod(param.method,param.thisObject,param.args);
}
 catch (Throwable e) {
Toast.makeText(CPctx,"String_Node_Str",Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
 else {
try {
XposedBridge.invokeOriginalMethod(param.method,param.thisObject,param.args);
}
 catch (Throwable e) {
Toast.makeText(CPctx,"String_Node_Str",Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
}
}
;
mClipboardManager.addPrimaryClipChangedListener(mOnPrimaryClipChangedListener);
param.setResult(null);
return;
}
}
);
}
}

Fixed version (ground truth):
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
  XposedHelpers.findAndHookMethod(TextView.class,"String_Node_Str",boolean.class,int.class,Rect.class,new XC_MethodHook(){
    @Override protected void afterHookedMethod(    MethodHookParam param) throws Throwable {
      TextView textView=(TextView)param.thisObject;
      boolean isEditText=textView instanceof EditText;
      if (!isEditText)       return;
      boolean focused=(Boolean)param.args[0];
      if (focused) {
        Etextview=textView;
        Ectx=Etextview.getContext();
        Log.d("String_Node_Str","String_Node_Str");
      }
    }
  }
);
  if (pref.getBoolean("String_Node_Str",true)) {
    XposedHelpers.findAndHookMethod("String_Node_Str",lpparam.classLoader,"String_Node_Str",ActionMode.class,Menu.class,new XC_MethodHook(){
      @Override protected void afterHookedMethod(      MethodHookParam param) throws Throwable {
        menu=(Menu)param.args[1];
        CBButton(menu);
      }
    }
);
    XposedHelpers.findAndHookMethod("String_Node_Str",lpparam.classLoader,"String_Node_Str",ActionMode.class,MenuItem.class,new XC_MethodHook(){
      @Override protected void afterHookedMethod(      final MethodHookParam param) throws Throwable {
        MenuItem item=(MenuItem)param.args[1];
switch (item.getItemId()) {
case id:
          Open(Ectx);
        start=Etextview.getSelectionStart();
      end=Etextview.getSelectionEnd();
    mClipboardManager=(ClipboardManager)Ectx.getSystemService(Context.CLIPBOARD_SERVICE);
  mOnPrimaryClipChangedListener=new ClipboardManager.OnPrimaryClipChangedListener(){
    @Override public void onPrimaryClipChanged(){
      if (mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(Ectx).toString().equals("String_Node_Str")) {
        try {
          mClipboardManager.removePrimaryClipChangedListener(mOnPrimaryClipChangedListener);
        }
 catch (        Exception e1) {
          Toast.makeText(Ectx,"String_Node_Str",Toast.LENGTH_SHORT).show();
          e1.printStackTrace();
        }
      }
 else       if (pref.getBoolean("String_Node_Str",false)) {
        try {
          mClipboardManager.removePrimaryClipChangedListener(mOnPrimaryClipChangedListener);
        }
 catch (        Exception e1) {
          Toast.makeText(Ectx,"String_Node_Str",Toast.LENGTH_SHORT).show();
          e1.printStackTrace();
        }
        try {
          Etextview.setText(Etextview.getText().subSequence(0,start).toString() + mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(Ectx).toString() + Etextview.getText().subSequence(end,Etextview.getText().length()).toString());
          Selection.setSelection((Spannable)Etextview.getText(),start + mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(Ectx).length());
        }
 catch (        Throwable e) {
          Toast.makeText(Ectx,"String_Node_Str",Toast.LENGTH_SHORT).show();
          e.printStackTrace();
        }
      }
 else {
        try {
          Etextview.setText(Etextview.getText().subSequence(0,start).toString() + mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(Ectx).toString() + Etextview.getText().subSequence(end,Etextview.getText().length()).toString());
          Selection.setSelection((Spannable)Etextview.getText(),start + mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(Ectx).length());
          start=start + mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(Ectx).length();
          end=start;
        }
 catch (        Throwable e) {
          Toast.makeText(Ectx,"String_Node_Str",Toast.LENGTH_SHORT).show();
          e.printStackTrace();
        }
      }
    }
  }
;
mClipboardManager.addPrimaryClipChangedListener(mOnPrimaryClipChangedListener);
param.setResult(true);
return;
}
}
}
);
}
if (pref.getBoolean("String_Node_Str",false)) {
XposedHelpers.findAndHookMethod("String_Node_Str",lpparam.classLoader,"String_Node_Str",View.class,new XC_MethodHook(){
@Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
TextView text=(TextView)param.args[0];
if (Resources.getSystem().getString(android.R.string.paste).equals(text.getText().toString())) {
Open(Ectx);
start=Etextview.getSelectionStart();
end=Etextview.getSelectionEnd();
mClipboardManager=(ClipboardManager)Ectx.getSystemService(Context.CLIPBOARD_SERVICE);
mOnPrimaryClipChangedListener=new ClipboardManager.OnPrimaryClipChangedListener(){
@Override public void onPrimaryClipChanged(){
if (mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(Ectx).toString().equals("String_Node_Str")) {
try {
  mClipboardManager.removePrimaryClipChangedListener(mOnPrimaryClipChangedListener);
}
 catch (Exception e1) {
  Toast.makeText(Ectx,"String_Node_Str",Toast.LENGTH_SHORT).show();
  e1.printStackTrace();
}
}
 else if (pref.getBoolean("String_Node_Str",false)) {
try {
  mClipboardManager.removePrimaryClipChangedListener(mOnPrimaryClipChangedListener);
}
 catch (Exception e1) {
  Toast.makeText(Ectx,"String_Node_Str",Toast.LENGTH_SHORT).show();
  e1.printStackTrace();
}
try {
  Etextview.setText(Etextview.getText().subSequence(0,start).toString() + mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(Ectx).toString() + Etextview.getText().subSequence(end,Etextview.getText().length()).toString());
  Selection.setSelection((Spannable)Etextview.getText(),start + mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(Ectx).length());
}
 catch (Throwable e) {
  Toast.makeText(Ectx,"String_Node_Str",Toast.LENGTH_SHORT).show();
  e.printStackTrace();
}
}
 else {
try {
  Etextview.setText(Etextview.getText().subSequence(0,start).toString() + mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(Ectx).toString() + Etextview.getText().subSequence(end,Etextview.getText().length()).toString());
  Selection.setSelection((Spannable)Etextview.getText(),start + mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(Ectx).length());
  start=start + mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(Ectx).length();
  end=start;
}
 catch (Throwable e) {
  Toast.makeText(Ectx,"String_Node_Str",Toast.LENGTH_SHORT).show();
  e.printStackTrace();
}
}
}
}
;
mClipboardManager.addPrimaryClipChangedListener(mOnPrimaryClipChangedListener);
param.setResult(null);
return;
}
}
}
);
}
if (lpparam.packageName.equals("String_Node_Str") || lpparam.packageName.equals("String_Node_Str")) {
if (pref.getBoolean("String_Node_Str",true)) {
XposedHelpers.findAndHookMethod("String_Node_Str",lpparam.classLoader,"String_Node_Str",ActionMode.class,Menu.class,new XC_MethodHook(){
@Override protected void afterHookedMethod(MethodHookParam param) throws Throwable {
menu=(Menu)param.args[1];
CBButton(menu);
}
}
);
XposedHelpers.findAndHookMethod("String_Node_Str",lpparam.classLoader,"String_Node_Str",ActionMode.class,MenuItem.class,new XC_MethodHook(){
@Override protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
Object[] args={};
CSctx=(Context)XposedHelpers.findMethodBestMatch(XposedHelpers.findClass("String_Node_Str",lpparam.classLoader),"String_Node_Str").invoke(param.thisObject,args);
MenuItem item=(MenuItem)param.args[1];
mparam=param;
switch (item.getItemId()) {
case id:
Open(CSctx);
mparam.args[1]=menu.getItem(3);
mClipboardManager=(ClipboardManager)CSctx.getSystemService(Context.CLIPBOARD_SERVICE);
mOnPrimaryClipChangedListener=new ClipboardManager.OnPrimaryClipChangedListener(){
@Override public void onPrimaryClipChanged(){
if (mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(CPctx).toString().equals("String_Node_Str")) {
try {
mClipboardManager.removePrimaryClipChangedListener(mOnPrimaryClipChangedListener);
}
 catch (Exception e1) {
Toast.makeText(Ectx,"String_Node_Str",Toast.LENGTH_SHORT).show();
e1.printStackTrace();
}
}
 else if (pref.getBoolean("String_Node_Str",false)) {
try {
mClipboardManager.removePrimaryClipChangedListener(mOnPrimaryClipChangedListener);
}
 catch (Exception e1) {
Toast.makeText(Ectx,"String_Node_Str",Toast.LENGTH_SHORT).show();
e1.printStackTrace();
}
try {
XposedHelpers.callMethod(mparam.thisObject,"String_Node_Str",mparam.args);
}
 catch (Throwable e) {
Toast.makeText(CSctx,"String_Node_Str",Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
 else {
try {
XposedHelpers.callMethod(mparam.thisObject,"String_Node_Str",mparam.args);
}
 catch (Throwable e) {
Toast.makeText(CSctx,"String_Node_Str",Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
}
}
;
mClipboardManager.addPrimaryClipChangedListener(mOnPrimaryClipChangedListener);
param.setResult(true);
return;
}
}
}
);
}
XposedHelpers.findAndHookMethod("String_Node_Str",lpparam.classLoader,"String_Node_Str",View.class,new XC_MethodHook(){
@Override protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
View mview=(View)param.args[0];
CPctx=mview.getContext();
Open(CPctx);
mClipboardManager=(ClipboardManager)CPctx.getSystemService(Context.CLIPBOARD_SERVICE);
mOnPrimaryClipChangedListener=new ClipboardManager.OnPrimaryClipChangedListener(){
@Override public void onPrimaryClipChanged(){
if (mClipboardManager.getPrimaryClip().getItemAt(0).coerceToText(CPctx).toString().equals("String_Node_Str")) {
try {
mClipboardManager.removePrimaryClipChangedListener(mOnPrimaryClipChangedListener);
}
 catch (Exception e1) {
Toast.makeText(Ectx,"String_Node_Str",Toast.LENGTH_SHORT).show();
e1.printStackTrace();
}
}
 else if (pref.getBoolean("String_Node_Str",false)) {
try {
mClipboardManager.removePrimaryClipChangedListener(mOnPrimaryClipChangedListener);
}
 catch (Exception e1) {
Toast.makeText(Ectx,"String_Node_Str",Toast.LENGTH_SHORT).show();
e1.printStackTrace();
}
try {
XposedBridge.invokeOriginalMethod(param.method,param.thisObject,param.args);
}
 catch (Throwable e) {
Toast.makeText(CPctx,"String_Node_Str",Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
 else {
try {
XposedBridge.invokeOriginalMethod(param.method,param.thisObject,param.args);
}
 catch (Throwable e) {
Toast.makeText(CPctx,"String_Node_Str",Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
}
}
;
mClipboardManager.addPrimaryClipChangedListener(mOnPrimaryClipChangedListener);
param.setResult(null);
return;
}
}
);
}
}