Commit 1bd498d3 authored by Administrator's avatar Administrator

conflict

parents b084598c 59363e00
......@@ -24,7 +24,7 @@ dependencies {
compileOnly 'com.google.android:android:4.1.1.4'
compileOnly 'com.google.code.findbugs:jsr305:3.0.2'
compileOnly 'com.android.support:support-annotations:28.0.0'
compileOnly 'com.virjar:ratel-api:1.3.2'
compileOnly 'com.virjar:ratel-api:1.3.3'
compileOnly 'com.virjar:sekiro-api:1.0.1'
}
......@@ -35,7 +35,7 @@ targetCompatibility = JDK_VERSION
group 'com.virjar'
version '1.0.5-SNAPSHOT'
version '1.0.6-SNAPSHOT'
compileJava {
......
File mode changed from 100644 to 100755
......@@ -12,10 +12,15 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.RandomAccessFile;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.LinkedBlockingDeque;
import external.org.apache.commons.io.FileUtils;
import external.org.apache.commons.io.IOUtils;
public class FileLogger {
......@@ -25,6 +30,11 @@ public class FileLogger {
private static OutputStream outputStream = null;
private static byte[] newLine = System.getProperty("line.separator", "\n").getBytes();
private static File mLogFile = null;
public static File getLogFile() {
return mLogFile;
}
public synchronized static void startRecord(File baseDir) {
if (syncLogThread != null) {
......@@ -42,14 +52,28 @@ public class FileLogger {
processName = processName.replace(":", "_");
File filename = new File(dir, processName + "__" + System.currentTimeMillis() + ".txt");
File filename = new File(dir, processName + ".txt");
mLogFile = filename;
RposedBridge.log("filename:" + filename.getAbsolutePath());
try {
if (filename.createNewFile()) {
outputStream = new FileOutputStream(filename, true);
if (!filename.exists()) {
if (!filename.createNewFile()) {
RposedBridge.log("failed to create log file :" + filename.getAbsolutePath());
}
} else {
RposedBridge.log("failed to create log file :" + filename.getAbsolutePath());
if (filename.length() > 2 * 1024 * 1024) {
RandomAccessFile accessFile = new RandomAccessFile(filename, "r");
long total = accessFile.length();
long index = total - 2 * 1024 * 1024;
if (index > 0) {
accessFile.seek(index);
byte[] bytes = new byte[2 * 1024 * 1024 + 1024];
int read = accessFile.read(bytes);
FileUtils.writeByteArrayToFile(filename, bytes, 0, read);
}
}
}
outputStream = new FileOutputStream(filename, true);
} catch (IOException e) {
e.printStackTrace();
return;
......@@ -109,7 +133,7 @@ public class FileLogger {
@Override
public void handle(OutputStream outputStream) throws IOException {
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream, StandardCharsets.UTF_8);
outputStreamWriter.write(message);
outputStreamWriter.write(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINESE).format(new Date()) + message);
outputStreamWriter.flush();
}
......@@ -149,7 +173,8 @@ public class FileLogger {
@Override
public void handle(OutputStream outputStream) throws IOException {
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream, StandardCharsets.UTF_8);
outputStreamWriter.append(tag);
outputStreamWriter.append(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINESE).format(new Date()))
.append(tag);
outputStreamWriter.append(message);
outputStreamWriter.flush();
}
......@@ -239,6 +264,7 @@ public class FileLogger {
public static String getTrack(Throwable e) {
StringBuilder msg = new StringBuilder("\n=============>\n");
while (e != null) {
msg.append(e.getClass().getName()).append(":").append(e.getMessage()).append("\n");
StackTraceElement[] ste = e.getStackTrace();
for (StackTraceElement stackTraceElement : ste) {
msg.append(stackTraceElement.getClassName()).append(".").append(stackTraceElement.getMethodName()).append(":").append(stackTraceElement.getLineNumber()).append("\n");
......
......@@ -7,8 +7,6 @@ import android.os.SystemClock;
import android.util.Log;
import android.view.MotionEvent;
import java.lang.ref.WeakReference;
import static android.view.MotionEvent.TOOL_TYPE_FINGER;
/**
......@@ -143,7 +141,7 @@ public class SwipeUtils {
}
static class ViewHandler extends Handler {
ViewImage mView;
ViewImage mView;
ViewHandler(ViewImage activity) {
super(Looper.getMainLooper());
......@@ -153,13 +151,14 @@ public class SwipeUtils {
@Override
public void handleMessage(Message msg) {
ViewImage theView = mView;
if (theView == null) {
Log.e(SuperAppium.TAG, "scroll view has bean destroyed");
isScrolling = false;
return;
}
GestureBean bean = (GestureBean) msg.obj;
final GestureBean bean = (GestureBean) msg.obj;
long count = bean.count;
if (count >= bean.totalCount) {
theView.dispatchPointerEvent(genFingerEvent(MotionEvent.ACTION_MOVE, bean.endX, bean.endY));
......@@ -196,8 +195,8 @@ public class SwipeUtils {
if (upEarly) {
theView.dispatchPointerEvent(genFingerEvent(MotionEvent.ACTION_MOVE, x, y));
float finalX = x;
float finalY = y;
final float finalX = x;
final float finalY = y;
new Handler(Looper.myLooper()).post(
new Runnable() {
@Override
......
......@@ -32,6 +32,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import static android.view.MotionEvent.TOOL_TYPE_FINGER;
......@@ -293,22 +294,22 @@ public class ViewImage {
}
public boolean click() {
if (originView.isClickable()) {
if (originView.performClick()) {
return true;
}
}
ViewImage parentViewImage = parentNode();
if (parentViewImage != null) {
View parentOriginView = parentViewImage.getOriginView();
if (parentOriginView instanceof AdapterView) {
if (!originView.performClick()) {
if (clickAdapterView((AdapterView) parentOriginView, originView)) {
return true;
}
}
}
}
// if (originView.isClickable()) {
// if (originView.performClick()) {
// return true;
// }
// }
// ViewImage parentViewImage = parentNode();
// if (parentViewImage != null) {
// View parentOriginView = parentViewImage.getOriginView();
// if (parentOriginView instanceof AdapterView) {
// if (!originView.performClick()) {
// if (clickAdapterView((AdapterView) parentOriginView, originView)) {
// return true;
// }
// }
// }
// }
return clickV2();
}
......@@ -361,17 +362,26 @@ public class ViewImage {
return rootView.dispatchTouchEvent(inputEvent);
}
@SuppressLint("NewApi")
private boolean clickV2() {
public boolean clickV2() {
float[] floats = measureClickPoint();
return clickByPoint(floats[0], floats[1]);
}
private static Random random = new Random();
private float[] measureClickPoint() {
int[] locs = new int[2];
originView.getLocationOnScreen(locs);
float x = locs[0] + originView.getWidth() / 4;
float y = locs[1] + originView.getHeight() / 4;
float x = locs[0];//+ ((float) originView.getWidth() / 4) + random.nextInt(originView.getWidth() / 4);
float y = locs[1];//+ ((float) originView.getHeight() / 4) + random.nextInt(originView.getHeight() / 4);
if (originView.getWidth() > 5) {
x += ((float) originView.getWidth() / 4) + random.nextInt(originView.getWidth() / 4);
}
if (originView.getHeight() > 5) {
y += ((float) originView.getHeight() / 4) + random.nextInt(originView.getHeight() / 4);
}
float[] ret = new float[2];
ret[0] = x;
......
package com.virjar.ratel.api.extension.superappium.sekiro;
import android.util.Log;
import com.virjar.ratel.api.RatelToolKit;
import com.virjar.ratel.api.extension.superappium.SuperAppium;
import com.virjar.sekiro.api.SekiroRequest;
import com.virjar.sekiro.api.SekiroRequestHandler;
import com.virjar.sekiro.api.SekiroResponse;
import com.virjar.sekiro.api.databind.AutoBind;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import external.org.apache.commons.lang3.StringUtils;
public class FileExploreHandler implements SekiroRequestHandler {
@AutoBind(defaultStringValue = "/")
private String path;
@AutoBind(defaultStringValue = "get")
private String op;
@Override
public void handleRequest(SekiroRequest sekiroRequest, SekiroResponse sekiroResponse) {
if (StringUtils.isBlank(path)) {
path = "/";
}
String base = RatelToolKit.sContext.getFilesDir().getParentFile().getAbsolutePath();
if (path.startsWith(base)) {
path = path.substring(base.length());
}
File targetFile = new File(RatelToolKit.sContext.getFilesDir().getParent());
if (!"/".equals(path)) {
targetFile = new File(RatelToolKit.sContext.getFilesDir().getParentFile(), path);
}
if ("get".equalsIgnoreCase(op)) {
if (!targetFile.exists()) {
sekiroResponse.failed(404, "the file :" + targetFile.getAbsolutePath() + " not exist");
return;
}
handleGet(sekiroRequest, sekiroResponse, targetFile);
} else if ("post".equalsIgnoreCase(op)) {
if (!targetFile.exists()) {
sekiroResponse.failed(404, "the file :" + targetFile.getAbsolutePath() + " not exist");
return;
}
handlePost(sekiroRequest, sekiroResponse, targetFile);
} else if ("put".equalsIgnoreCase(op)) {
handlePut(sekiroRequest, sekiroResponse, targetFile);
}
}
private void handleGet(SekiroRequest sekiroRequest, SekiroResponse sekiroResponse, File targetFile) {
if (targetFile.isDirectory()) {
List<String> ret = new ArrayList<>();
String[] list = targetFile.list();
if (list == null) {
sekiroResponse.failed("can not read dir file: " + targetFile.getAbsolutePath());
return;
}
String base = RatelToolKit.sContext.getFilesDir().getParentFile().getAbsolutePath();
for (String str : list) {
if (str.startsWith(base)) {
ret.add(str.substring(base.length()));
} else {
ret.add(str);
}
}
sekiroResponse.success(ret);
return;
}
if (!targetFile.canRead()) {
sekiroResponse.failed("can not read file: " + targetFile.getAbsolutePath());
return;
}
try {
sekiroResponse.sendFile(targetFile);
} catch (IOException e) {
Log.e(SuperAppium.TAG, "read filed failed", e);
sekiroResponse.failed("can not read file: " + targetFile.getAbsolutePath());
}
}
private void handlePost(SekiroRequest sekiroRequest, SekiroResponse sekiroResponse, File targetFile) {
sekiroResponse.failed("not implement now");
}
private void handlePut(SekiroRequest sekiroRequest, SekiroResponse sekiroResponse, File targetFile) {
sekiroResponse.failed("not implement now");
}
}
......@@ -14,20 +14,25 @@ public class SekiroStarter {
private static final String dumpTopFragment = "dumpFragment";
private static final String screenShot = "screenShot";
private static final String executeJsOnWebView = "ExecuteJsOnWebView";
private static final String fileExplore = "fileExplore";
private static boolean isStarted = false;
private static SekiroClient defaultSekiroClient = null;
public static void startService(String host, int port, String token) {
if (isStarted) {
return;
}
Log.i(SuperAppium.TAG, "start a supperAppium client: " + token);
PageTriggerManager.getTopFragment("insureComponentStarted");
SekiroClient.start(host, port, token, sekiroGroup)
defaultSekiroClient = SekiroClient.start(host, port, token, sekiroGroup)
.registerHandler(dumpTopActivity, new DumpTopActivityHandler())
.registerHandler(dumpTopFragment, new DumpTopFragmentHandler())
.registerHandler(screenShot, new ScreenShotHandler())
.registerHandler(executeJsOnWebView, new ExecuteJsOnWebViewHandler())
.registerHandler(fileExplore, new FileExploreHandler())
;
isStarted = true;
......@@ -36,4 +41,8 @@ public class SekiroStarter {
public static void startService(String host, int port) {
startService(host, port, UUID.randomUUID().toString());
}
public static SekiroClient getDefaultSekiroClient() {
return defaultSekiroClient;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment