Skip to content

Commit

Permalink
Merge branch '1.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
helloklf committed Jul 17, 2020
2 parents 49ce479 + 51d2169 commit 6469dac
Show file tree
Hide file tree
Showing 90 changed files with 2,846 additions and 1,652 deletions.
Binary file modified app/adb_process/jar/adb_process.dex
Binary file not shown.
Binary file modified app/adb_process/jar/adb_process.jar
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion app/adb_process/src/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void run() {
}
*/

System.out.println("Gesture ADB Process!");
// System.out.println("Gesture ADB Process!");

RemoteAPI remoteAPI = new RemoteAPI();
remoteAPI.start();
Expand Down
8 changes: 4 additions & 4 deletions app/adb_process/src/shell/GlobalState.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package shell;

public class GlobalState {
public static int displayHeight = 2340;
public static int displayWidth = 1080;
public static int lastBarColor = Integer.MIN_VALUE;
public static boolean onBarColorGeting = false;
public static int displayHeight = 2340;
public static int displayWidth = 1080;
public static int lastBarColor = Integer.MIN_VALUE;
public static boolean onBarColorGeting = false;
}
4 changes: 2 additions & 2 deletions app/adb_process/src/shell/KeepShell.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package shell;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.nio.charset.Charset;
Expand Down Expand Up @@ -62,7 +62,7 @@ public void run() {
errorReader.readLine();
}
} catch (Exception ex) {
System.out.println("Gesture ADB Error " + ex.getMessage());
// System.out.println("Gesture ADB Error " + ex.getMessage());
}
}
}).start();
Expand Down
2 changes: 0 additions & 2 deletions app/adb_process/src/shell/KeepShellPublic.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package shell;

import java.util.List;

/**
* Created by Hello on 2018/01/23.
*/
Expand Down
68 changes: 45 additions & 23 deletions app/adb_process/src/shell/RemoteAPI.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
package shell;

import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;

public class RemoteAPI {
// 从=分割
private String subPackageName(String recents) {
private ArrayList<String> recentBlackList = new ArrayList<String>() {{
add("com.android.systemui");
}};

// 从 cmp= 分割
private String subPackageName2(String recents, String separator) {
StringBuilder stringBuilder = new StringBuilder();
int separatorLength = separator.length();
try {
if (recents != null) {
String[] rows = recents.split("\n");
for (String row : rows) {
if (row.contains("=") && row.contains("/")) {
stringBuilder.append(row.substring(row.indexOf("=") + 1, row.indexOf("/")));
if (row.contains(separator) && row.contains("/")) {
String r = row.substring(row.indexOf(separator) + separatorLength);
stringBuilder.append(r, 0, r.indexOf("/"));
stringBuilder.append("\n");
}
}
Expand All @@ -28,29 +34,45 @@ private String subPackageName(String recents) {
return stringBuilder.toString();
}

// 从 cmp= 分割
private String subPackageName2(String recents, String separator) {
// Android 5.1 ~ 9.0
private String filterPackages(String dumpResult) {
StringBuilder stringBuilder = new StringBuilder();
int separatorLength = separator.length();
try {
if (recents != null) {
String[] rows = recents.split("\n");
for (String row : rows) {
if (row.contains(separator) && row.contains("/")) {
String r = row.substring(row.indexOf(separator) + separatorLength);
stringBuilder.append(r, 0, r.indexOf("/"));
stringBuilder.append("\n");
ArrayList<String> packages = new ArrayList<>();
if (dumpResult != null) {
String[] recents = dumpResult.split("Recent #");
for (String recent : recents) {
// Activities=[] 通常意味着这个应用已经被销毁,如果正在后台运行,则一般显示类似于 Activities=[ActivityRecord{651f32f u0 com.android.chrome/com.google.android.apps.chrome.Main t46}]
// realActivity=com.android.settings/.FallbackHome 非常讨厌的一个东西
if (recent.contains("Activities=[ActivityRecord") && recent.contains("autoRemoveRecents=false")) {
String[] rows = recent.split("\n");
for (String row : rows) {
if (row.contains("realActivity=com.android.settings/.FallbackHome")) {
break;
}

if (row.contains("Activities=[ActivityRecord")) {
for (String column : row.split(" ")) {
if (column.indexOf("/") > 0) {
String packageName = column.substring(0, column.indexOf("/"));
if (!packages.contains(packageName) && !recentBlackList.contains(packageName)) {
packages.add(packageName);

stringBuilder.append(packageName);
stringBuilder.append("\n");
}
}
}
}
}
}
}
} catch (Exception ignored) {
}
System.out.println(stringBuilder.toString());
// System.out.println(">>>" + stringBuilder.toString());
return stringBuilder.toString();
}

private void routerMatch(String request, Socket socket) {
System.out.println("Gesture Router Match:" + request);
// System.out.println("Gesture Router Match:" + request);
if (request.startsWith("/version")) {
responseEnd(socket, "0.1.0(1)");
} else if (request.startsWith("/bar-color")) {
Expand All @@ -73,7 +95,7 @@ private void routerMatch(String request, Socket socket) {
responseEnd(socket, (isLight ? "true" : "false"));
} else if (request.startsWith("/recent-9")) {
// responseEnd(socket, subPackageName(KeepShellPublic.doCmdSync("dumpsys activity r | grep realActivity")));
responseEnd(socket, subPackageName2(KeepShellPublic.doCmdSync("dumpsys activity r | grep 'cmp='"), "cmp="));
responseEnd(socket, filterPackages(KeepShellPublic.doCmdSync("dumpsys activity r")));
} else if (request.startsWith("/recent-10")) {
// responseEnd(socket, subPackageName(KeepShellPublic.doCmdSync("dumpsys activity r | grep mActivityComponent")));
responseEnd(socket, subPackageName2(KeepShellPublic.doCmdSync("dumpsys activity r | grep baseIntent"), "cmp="));
Expand Down Expand Up @@ -126,7 +148,7 @@ public void start() {
int begin = requestHeader.indexOf("Content-Lengh:") + "Content-Length:".length();
String postParamterLength = requestHeader.substring(begin).trim();
contentLength = Integer.parseInt(postParamterLength);
System.out.println("POST参数长度是:" + Integer.parseInt(postParamterLength));
// System.out.println("POST参数长度是:" + Integer.parseInt(postParamterLength));
}
}

Expand All @@ -135,7 +157,7 @@ public void start() {
for (int i = 0; i < contentLength; i++) {
sb.append((char) bd.read());
}
System.out.println("POST参数是:" + sb.toString());
// System.out.println("POST参数是:" + sb.toString());
}

/*
Expand All @@ -152,7 +174,7 @@ public void start() {
*/
}
} catch (IOException e) {
System.out.println("Gesture ADB Process RemoteAPI Fail!");
// System.out.println("Gesture ADB Process RemoteAPI Fail!");
}
}

Expand Down
Loading

0 comments on commit 6469dac

Please sign in to comment.