From 4633681e4127dffe50e1274f15716f5d28391fa3 Mon Sep 17 00:00:00 2001 From: Rosheen Date: Thu, 17 Nov 2022 21:50:40 +0800 Subject: [PATCH 1/3] convert command --- .idea/.gitignore | 8 ++++++++ .idea/misc.xml | 9 +++++++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ AndroidPerfServer.iml | 11 +++++++++++ framework/AndroidPerfServerFW.java | 17 +++++++++++------ native/server.cpp | 4 ++++ 7 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 AndroidPerfServer.iml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..b59205c --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..2f23834 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/AndroidPerfServer.iml b/AndroidPerfServer.iml new file mode 100644 index 0000000..449026b --- /dev/null +++ b/AndroidPerfServer.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/framework/AndroidPerfServerFW.java b/framework/AndroidPerfServerFW.java index a23528e..dbd3b8c 100644 --- a/framework/AndroidPerfServerFW.java +++ b/framework/AndroidPerfServerFW.java @@ -1,17 +1,17 @@ package com.androidperf.server; import android.app.ActivityThread; +import android.app.usage.NetworkStats; +import android.app.usage.NetworkStatsManager; import android.content.Context; -import android.os.Looper; -import android.os.Build; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; import android.net.LocalServerSocket; import android.net.LocalSocket; import android.net.LocalSocketAddress; -import android.app.usage.NetworkStats; -import android.app.usage.NetworkStatsManager; +import android.os.Build; +import android.os.Looper; import android.util.Log; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; import java.io.IOException; import java.io.InputStream; @@ -56,6 +56,11 @@ private void handleData(OutputStream outputStream, String data) { } } else if (data.contains("PING")) { writeMSG(outputStream, "OKAY".getBytes()); + } else if (data.contains("convert ")) { + //todo 返回的内容 + String packageName = data.substring(data.indexOf("convert ")+"convert ".length()).split(" ")[0]; + String AppName = getAppName(packageName); + writeMSG(outputStream, AppName.getBytes()); } } diff --git a/native/server.cpp b/native/server.cpp index 9b81aef..e24a720 100644 --- a/native/server.cpp +++ b/native/server.cpp @@ -280,6 +280,10 @@ void AndroidPerf::handleData(int fd, String8 data) { writeMSG(fd, "OKAY", 4); } + else if (data.contains("convert")) + { + requestFramework(data.string(), data.size(), fd); + } } void AndroidPerf::writeMSG(int fd, const void *data, size_t size) From 6dcb78b8b58eb7d14db560ec4b2fdc0fb4ef8ffc Mon Sep 17 00:00:00 2001 From: Rosheen-2000 Date: Sun, 20 Nov 2022 03:22:48 -0800 Subject: [PATCH 2/3] add some debug messages --- framework/AndroidPerfServerFW.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/AndroidPerfServerFW.java b/framework/AndroidPerfServerFW.java index dbd3b8c..adabef4 100644 --- a/framework/AndroidPerfServerFW.java +++ b/framework/AndroidPerfServerFW.java @@ -58,9 +58,9 @@ private void handleData(OutputStream outputStream, String data) { writeMSG(outputStream, "OKAY".getBytes()); } else if (data.contains("convert ")) { //todo 返回的内容 - String packageName = data.substring(data.indexOf("convert ")+"convert ".length()).split(" ")[0]; + String packageName = data.substring(data.indexOf("convert ")+"convert ".length()); String AppName = getAppName(packageName); - writeMSG(outputStream, AppName.getBytes()); + writeMSG(outputStream, packageName.getBytes()); } } From 32d30fdcdc7ea2034aa801bdc97fb559ed30075d Mon Sep 17 00:00:00 2001 From: Rosheen-2000 Date: Fri, 25 Nov 2022 03:59:45 -0800 Subject: [PATCH 3/3] basically ok ver. --- framework/AndroidPerfServerFW.java | 2 +- native/server.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/framework/AndroidPerfServerFW.java b/framework/AndroidPerfServerFW.java index adabef4..e44bc02 100644 --- a/framework/AndroidPerfServerFW.java +++ b/framework/AndroidPerfServerFW.java @@ -56,7 +56,7 @@ private void handleData(OutputStream outputStream, String data) { } } else if (data.contains("PING")) { writeMSG(outputStream, "OKAY".getBytes()); - } else if (data.contains("convert ")) { + } else if (data.contains("convert")) { //todo 返回的内容 String packageName = data.substring(data.indexOf("convert ")+"convert ".length()); String AppName = getAppName(packageName); diff --git a/native/server.cpp b/native/server.cpp index e24a720..907082e 100644 --- a/native/server.cpp +++ b/native/server.cpp @@ -29,6 +29,8 @@ #include #include +#undef NDEBUG + using namespace android; using ::android::base::unique_fd; @@ -280,7 +282,7 @@ void AndroidPerf::handleData(int fd, String8 data) { writeMSG(fd, "OKAY", 4); } - else if (data.contains("convert")) + else if(data.contains("convert")) { requestFramework(data.string(), data.size(), fd); }