I am currently developing an app(API level 23) that is going to allow the user to choose what application will have the copy and paste functionality enabled. I am working with Xposed to do so.
I have 2 files at the moment. MainActivity.java and Main.java and my code is error free but does not work for some reasons. After extensive research, I chose to modify the behavior of SetPrimaryClip and GetPrimaryClip as follows:
Modified SetPrimaryClip in Main.java:
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");
}
Modified GetPrimaryClip in Main.java:
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");
}
Note that I don't have any compilation errors at all. Am I hooking the wrong methods here?