打印App所有的Api请求
Java.use('java.net.URL').$init.overload('java.lang.String').implementation = function (apiUrl){
console.log(apiUrl);
printStack();
this.$init(apiUrl);
};
打印堆栈信息
function printStack(){
var Thread = Java.use('java.lang.Thread').$new();
var stack = Thread.currentThread().getStackTrace();
for(var i = 0;i<stack.length;i++){
console.log("Call stack: " + stack[i].toString());
}
}
byte转字符串 & 字符串转bute
function byteToString(arr) {
if (typeof arr === 'string') {
return arr;
}
var str = '',
_arr = arr;
for (var i = 0; i < _arr.length; i++) {
var one = _arr[i].toString(2),
v = one.match(/^1+?(?=0)/);
if (v && one.length == 8) {
var bytesLength = v[0].length;
var store = _arr[i].toString(2).slice(7 - bytesLength);
for (var st = 1; st < bytesLength; st++) {
store += _arr[st + i].toString(2).slice(2);
}
str += String.fromCharCode(parseInt(store, 2));
i += bytesLength - 1;
} else {
str += String.fromCharCode(_arr[i]);
}
}
return str;
}
function stringToBytes(str) {
var ch, st, re = [];
for (var i = 0; i < str.length; i++) {
ch = str.charCodeAt(i);
st = [];
do {
st.push(ch & 0xFF);
ch = ch >> 8;
}
while (ch);
re = re.concat(st.reverse());
}
return re;
}