Skip to content

Commit 480fb55

Browse files
author
朱辉\harry
committed
change resources
1 parent ffdca41 commit 480fb55

69 files changed

Lines changed: 39 additions & 18 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎build.gradle‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
apply plugin: 'java'// UTF-8支持tasks.withType(JavaCompile) { options.encoding = "UTF-8"}task "java-mkdirs" <<{ sourceSets*.java.srcDirs*.each{it.mkdirs()} sourceSets*.resources.srcDirs*.each{it.mkdirs()}}// 依赖库仓库repositories { mavenLocal() mavenCentral() }dependencies { compile group: 'com.android.tools.ddms', name: 'ddmlib', version: '25.3.0' compile group: 'io.netty', name: 'netty-all', version: '4.1.9.Final' compile group: 'com.alibaba', name: 'fastjson', version: '1.2.31' compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.4'} jar { manifest { attributes("Main-Class": "com.yeetor.Main") }}apply plugin: 'application'mainClassName= 'com.yeetor.Main'task copyExtRes(type: Copy) { def src = file("$projectDir/resources") def dst = file("$buildDir/resources") from src into dst}distributions { main { contents { from (copyExtRes) { into "resources" } } }}
1+
apply plugin: 'java'// UTF-8支持tasks.withType(JavaCompile) { options.encoding = "UTF-8"}task "java-mkdirs" <<{ sourceSets*.java.srcDirs*.each{it.mkdirs()} sourceSets*.resources.srcDirs*.each{it.mkdirs()}}// 依赖库仓库repositories { mavenLocal() mavenCentral() }dependencies { compile group: 'com.android.tools.ddms', name: 'ddmlib', version: '25.3.0' compile group: 'io.netty', name: 'netty-all', version: '4.1.9.Final' compile group: 'com.alibaba', name: 'fastjson', version: '1.2.31' compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.4'} jar { manifest { attributes("Main-Class": "com.yeetor.Main") }}apply plugin: 'application'mainClassName= 'com.yeetor.Main'//task copyExtRes(type: Copy) {// def src = file("$projectDir/resources")// def dst = file("$buildDir/resources")//// from src// into dst//}////distributions {// main {// contents {// from (copyExtRes) {// into "resources"// }// }// }//}

‎src/main/java/com/yeetor/Main.java‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
11
package com.yeetor;
22

3-
import com.yeetor.adb.AdbForward;
4-
import com.yeetor.adb.AdbServer;
5-
import com.yeetor.minicap.Minicap;
63
import com.yeetor.minicap.MinicapInstallException;
74
import com.yeetor.p2p.WSServer;
5+
import com.yeetor.util.Constant;
86

9-
import java.io.File;
10-
import java.io.FileOutputStream;
11-
import java.io.IOException;
127

138
/**
149
* Created by harry on 2017/4/15.
1510
*/
1611
public class Main {
1712
public static void main(String[] args) throws MinicapInstallException {
1813

19-
20-
System.out.println("dasdasdasdasdasda");
2114
boolean isServer = true;
2215

2316
if (isServer) {

‎src/main/java/com/yeetor/minicap/Minicap.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static void installMinicap(IDevice device) throws MinicapInstallException
6262
String abi = device.getProperty(Constant.PROP_ABI).trim();
6363

6464
// minicap
65-
File minicap_bin = new File(Constant.getMinicap(), abi + File.separator + MINICAP_BIN);
65+
File minicap_bin = Constant.getMinicap(abi);
6666
if (!minicap_bin.exists()) {
6767
throw new MinicapInstallException("File: " + minicap_bin.getAbsolutePath() + " not exists!");
6868
}
@@ -75,7 +75,7 @@ public static void installMinicap(IDevice device) throws MinicapInstallException
7575
AdbServer.executeShellCommand(device, "chmod 777 " + REMOTE_PATH + "/" + MINICAP_BIN);
7676

7777
// minicap.so
78-
File minicap_so = new File(Constant.getMinicapSo(), "android-" + sdk + File.separator + abi + File.separator + MINICAP_SO);
78+
File minicap_so = Constant.getMinicapSo(abi, sdk);
7979
if (!minicap_so.exists()) {
8080
throw new MinicapInstallException("File: " + minicap_so.getAbsolutePath() + " not exists!");
8181
}

‎src/main/java/com/yeetor/minitouch/Minitouch.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static void installMinitouch(IDevice device) throws MinitouchInstallExcep
4343
String sdk = device.getProperty(Constant.PROP_SDK).trim();
4444
String abi = device.getProperty(Constant.PROP_ABI).trim();
4545

46-
File minitouch_bin = new File(Constant.getMinitouchBin(), abi + File.separator + MINITOUCH_BIN);
46+
File minitouch_bin = Constant.getMinitouchBin(abi);
4747
if (!minitouch_bin.exists()) {
4848
throw new MinitouchInstallException("File: " + minitouch_bin.getAbsolutePath() + " not exists!");
4949
}
Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package com.yeetor.util;
22

33
import java.io.File;
4+
import java.io.UnsupportedEncodingException;
5+
import java.net.ResponseCache;
6+
import java.net.URI;
7+
import java.net.URISyntaxException;
8+
import java.net.URLDecoder;
49

510
/**
611
* Created by harry on 2017/4/17.
@@ -10,16 +15,39 @@ public class Constant {
1015
public static final String PROP_ABI = "ro.product.cpu.abi";
1116
public static final String PROP_SDK = "ro.build.version.sdk";
1217

13-
public static File getMinicap() {
14-
return new File("resources" + File.separator + "minicap" + File.separator + "bin");
18+
public static File getMinicap(String abi) {
19+
20+
URI uri = null;
21+
try {
22+
uri = ClassLoader.getSystemResource("minicap" + File.separator + "bin" +
23+
File.separator + abi + File.separator + "minicap").toURI();
24+
} catch (URISyntaxException e) {
25+
e.printStackTrace();
26+
}
27+
return new File(uri);
1528
}
1629

17-
public static File getMinicapSo() {
18-
return new File("resources" + File.separator + "minicap" + File.separator + "shared");
30+
public static File getMinicapSo(String abi, String sdk) {
31+
URI uri = null;
32+
try {
33+
uri = ClassLoader.getSystemResource("minicap" + File.separator + "shared" +
34+
File.separator + "android-" + sdk + File.separator + abi + File.separator + "minicap.so").toURI();
35+
36+
} catch (URISyntaxException e) {
37+
e.printStackTrace();
38+
}
39+
return new File(uri);
1940
}
2041

21-
public static File getMinitouchBin() {
22-
return new File("resources" + File.separator + "minitouch");
42+
public static File getMinitouchBin(String abi) {
43+
URI uri = null;
44+
try {
45+
uri = ClassLoader.getSystemResource("minitouch" + File.separator +
46+
File.separator + abi + File.separator + "minitouch").toURI();
47+
} catch (URISyntaxException e) {
48+
e.printStackTrace();
49+
}
50+
return new File(uri);
2351
}
2452

2553
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)