使用Xposed禁用通过Android中的剪贴板功能复制和粘贴

时间:2016-12-05 12:11:33

标签: java android clipboardmanager xposed xposed-framework

我目前正在开发一个应用程序(API级别23),该应用程序允许用户选择启用了复制和粘贴功能的应用程序。我正在与Xposed合作。

目前我有2个文件。 MainActivity.java和Main.java和 我的代码没有错误但由于某些原因不起作用。经过广泛的研究,我选择修改SetPrimaryClip和GetPrimaryClip的行为,如下所示:

在Main.java中修改了SetPrimaryClip:

if (isBlackListed())
{
    //if app checked

    //TO DO: Add block copy and paste functionality for UI

    //Here the context is passing
    ClipboardManager clipBoard = (ClipboardManager) c.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData data = ClipData.newPlainText("", "");
    clipBoard.setPrimaryClip(data);


    Toast.makeText(c, "Hack Enabled for copy func", Toast.LENGTH_SHORT).show();

    //debug hack enabled
    XposedBridge.log(" hack enabled for copy func");
    XposedBridge.log(packName);
    log_call(", hack enabled for copy func");


} else {
    //if app not checked
    Toast.makeText(c, "Hack disabled for copy func", Toast.LENGTH_SHORT).show();

    //debug hack disabled
    XposedBridge.log(" hack disabled for copy func");
    XposedBridge.log(packName);
    log_call(", hack disabled for copy func");

}

在Main.java中修改了GetPrimaryClip:

if (isBlackListed())
{
    ClipboardManager clipBoard = (ClipboardManager) c.getSystemService(Context.CLIPBOARD_SERVICE);


    ClipData cp = clipBoard.getPrimaryClip();
    ClipData.Item item = cp.getItemAt(0);
    String text = item.getText().toString(); text=null;


    //if app not checked
    Toast.makeText(c, "Hack enabled for paste func", Toast.LENGTH_SHORT).show();

    //debug hack disabled
    XposedBridge.log("hack enabled for paste func");
    XposedBridge.log(packName);
    log_call(", hack enabled for paste func");


    param.setResult(null);

} else {



    //if app not checked
    Toast.makeText(c, "Hack disabled for paste func", Toast.LENGTH_SHORT).show();

    //debug hack disabled
    XposedBridge.log("hack disabled for paste func");
    XposedBridge.log(packName);
    log_call(", hack disabled for paste func");


}

请注意,我根本没有任何编译错误。我在这里挂错了方法吗?

0 个答案:

没有答案