Compare commits
10 Commits
fdaf5849ec
...
07172aaafe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07172aaafe | ||
|
|
47d27c9542 | ||
|
|
6f89f70fe5 | ||
|
|
89fde42cdf | ||
|
|
7d306fc743 | ||
|
|
60c4841855 | ||
|
|
ced2cbbf99 | ||
|
|
ff2f1e7aed | ||
|
|
92ee21ae3d | ||
|
|
eeafd04c25 |
38
README.md
38
README.md
@@ -1,6 +1,7 @@
|
||||
|
||||
### 免root兼容所有Android版本屏幕共享及远程控制。
|
||||
|
||||
### 效果
|
||||

|
||||
### 使用方式
|
||||
|
||||
对于mac 笔记本用户:
|
||||
@@ -20,7 +21,7 @@
|
||||
* 新建命令窗口,然后执行 `adb forward tcp:8888 localabstract:puppet-ver1`
|
||||
* 运行lib目录下的Client,用于显示和控制,点击连接按钮即可
|
||||
|
||||
|
||||
注意:高版本的android手机需要去开发者选项中开启 允许模拟点击
|
||||
|
||||
完整命令如下
|
||||
```html
|
||||
@@ -185,3 +186,36 @@ public interface IRotationWatcher {
|
||||
[https://github.com/android-notes/androidScreenShareAndControl](https://github.com/android-notes/androidScreenShareAndControl)
|
||||
|
||||
|
||||
### 附 编译class方式:
|
||||
|
||||
最简单的方式:
|
||||
在`android studio`中右击`com.wanjian.puppet.Main`这个文件,选择 `run Main.main()`,编译后的class文件就会自动保存到
|
||||
`androidScreenShareAndControl/shareandcontrollib/build/intermediates/classes/debug` 这个目录中
|
||||
|
||||
|
||||
方式2:
|
||||
* 把 `android sdk`目录下的`android.jar`和`supportv4.jar`拷贝到
|
||||
`androidScreenShareAndControl/shareandcontrollib/src/main/java`
|
||||
目录下
|
||||
|
||||
* 同时在这个目录下新建`classes`文件夹,用于保存编译后的class文件,并把命令行切换到这个目录
|
||||
|
||||
* 执行如下命令,其中`android.jar`和`support-v4-23.4.0-sources.jar` 是`android sdk`中的`jar`包,一个在`platforms/android-xx`文件夹下,一个在`extras/android/m2repository/com/android/support/support-v4`下。(命令中间用:分割,windows的话需要用;分割)
|
||||
|
||||
* `javac -cp android.jar:support-v4-23.4.0-sources.jar:./ com/wanjian/puppet/Main.java -d classes`
|
||||
|
||||
* 这样就会在classes文件夹中生成class文件了 (JDK版本不能太高,不然会提示 unsupported class file version 52.0)
|
||||
|
||||

|
||||
|
||||
|
||||
### 打包dex方式:
|
||||
首先命令窗口切换到 `androidScreenShareAndControl/shareandcontrollib/build/intermediates/classes/debug` 目录下,可以看到
|
||||
所有编译生成的class文件,如果没有先执行上面步骤生成class文件。
|
||||
|
||||
然后使用 `dx --dex --output=Main.dex ./`命令生成dex文件。dx命令文件在 `sdk/build-tools/版本号` 下
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
|
||||
BIN
dex-package.png
Normal file
BIN
dex-package.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 446 KiB |
@@ -27,6 +27,7 @@ import javax.swing.event.ChangeListener;
|
||||
public class Client extends JFrame {
|
||||
JLabel label;
|
||||
boolean isMove = false;
|
||||
JLabel tips;
|
||||
|
||||
public Client() throws IOException {
|
||||
setLayout(new BorderLayout(0, 0));
|
||||
@@ -45,10 +46,16 @@ public class Client extends JFrame {
|
||||
|
||||
JPanel btnPanel = new JPanel(new BorderLayout(5, 5));
|
||||
JButton btn = new JButton("链接");
|
||||
btnPanel.add(btn, BorderLayout.CENTER);
|
||||
btnPanel.add(btn, BorderLayout.NORTH);
|
||||
|
||||
JSlider jSlider=createSlider();
|
||||
btnPanel.add(jSlider,BorderLayout.SOUTH);
|
||||
tips = new JLabel();
|
||||
tips.setBorder(new EmptyBorder(0, 8, 0, 0));
|
||||
tips.setText("清晰度 100%");
|
||||
btnPanel.add(tips, BorderLayout.CENTER);
|
||||
|
||||
|
||||
JSlider jSlider = createSlider();
|
||||
btnPanel.add(jSlider, BorderLayout.SOUTH);
|
||||
|
||||
JPanel panelContainer = new JPanel(new BorderLayout());
|
||||
panelContainer.add(ipPanel, BorderLayout.NORTH);
|
||||
@@ -148,14 +155,15 @@ public class Client extends JFrame {
|
||||
private JSlider createSlider() {
|
||||
int minimum = 30;
|
||||
int maximum = 100;
|
||||
JSlider slider = new JSlider(minimum, maximum,maximum);
|
||||
JSlider slider = new JSlider(minimum, maximum, maximum);
|
||||
|
||||
slider.addChangeListener(new ChangeListener() {
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent changeEvent) {
|
||||
try {
|
||||
int v=((JSlider) changeEvent.getSource()).getValue();
|
||||
writer.write("DEGREE"+v);
|
||||
int v = ((JSlider) changeEvent.getSource()).getValue();
|
||||
tips.setText("清晰度 " + v + "%");
|
||||
writer.write("DEGREE" + v);
|
||||
writer.newLine();
|
||||
writer.flush();
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -10,7 +10,7 @@ import android.os.IBinder;
|
||||
public interface IWindowManager {
|
||||
void getInitialDisplaySize(int i, Point displaySize);
|
||||
|
||||
int getRotation();
|
||||
// int getRotation();
|
||||
|
||||
void getRealDisplaySize(Point displaySize);
|
||||
|
||||
|
||||
@@ -41,6 +41,14 @@ public class Main {
|
||||
public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, IOException {
|
||||
|
||||
System.out.println("start!");
|
||||
|
||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
LocalServerSocket serverSocket = new LocalServerSocket("puppet-ver1");
|
||||
|
||||
init();
|
||||
@@ -51,6 +59,7 @@ public class Main {
|
||||
LocalSocket socket = serverSocket.accept();
|
||||
acceptConnect(socket);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
serverSocket = new LocalServerSocket("puppet-ver1");
|
||||
}
|
||||
|
||||
@@ -93,8 +102,8 @@ public class Main {
|
||||
outputStream.write(byteArrayOutputStream.toByteArray());
|
||||
outputStream.flush();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} catch (Throwable e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
@@ -126,7 +135,7 @@ public class Main {
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println(e.getMessage());
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@@ -146,13 +155,13 @@ public class Main {
|
||||
scale = Float.parseFloat(line.substring(DEGREE.length())) / 100;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} catch (Throwable e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -165,7 +174,7 @@ public class Main {
|
||||
try {
|
||||
touchUp(point.x, point.y);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -176,7 +185,7 @@ public class Main {
|
||||
try {
|
||||
touchMove(point.x, point.y);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -187,7 +196,7 @@ public class Main {
|
||||
try {
|
||||
touchDown(point.x, point.y);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,7 +212,7 @@ public class Main {
|
||||
point.y *= scaleY;
|
||||
return point;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -232,19 +241,19 @@ public class Main {
|
||||
}
|
||||
b = (Bitmap) Class.forName(surfaceClassName).getDeclaredMethod("screenshot", new Class[]{Integer.TYPE, Integer.TYPE}).invoke(null, new Object[]{Integer.valueOf(size.x), Integer.valueOf(size.y)});
|
||||
|
||||
int rotation = wm.getRotation();
|
||||
|
||||
if (rotation == 0) {
|
||||
return b;
|
||||
}
|
||||
// int rotation = wm.getRotation();
|
||||
//
|
||||
// if (rotation == 0) {
|
||||
// return b;
|
||||
// }
|
||||
Matrix m = new Matrix();
|
||||
if (rotation == 1) {
|
||||
m.postRotate(-90.0f);
|
||||
} else if (rotation == 2) {
|
||||
m.postRotate(-180.0f);
|
||||
} else if (rotation == 3) {
|
||||
m.postRotate(-270.0f);
|
||||
}
|
||||
// if (rotation == 1) {
|
||||
// m.postRotate(-90.0f);
|
||||
// } else if (rotation == 2) {
|
||||
// m.postRotate(-180.0f);
|
||||
// } else if (rotation == 3) {
|
||||
// m.postRotate(-270.0f);
|
||||
// }
|
||||
return Bitmap.createBitmap(b, 0, 0, size.x, size.y, m, false);
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class SurfaceControlVirtualDisplayFactory implements VirtualDisplayFactor
|
||||
if (VERSION.SDK_INT >= 18) {
|
||||
wm = Stub.asInterface((IBinder) getServiceMethod.invoke(null, new Object[]{"window"}));
|
||||
wm.getInitialDisplaySize(0, displaySize);
|
||||
rotation = wm.getRotation();
|
||||
// rotation = wm.getRotation();
|
||||
} else if (VERSION.SDK_INT == 17) {
|
||||
DisplayInfo di = IDisplayManager.Stub.asInterface((IBinder) getServiceMethod.invoke(null, new Object[]{"display"})).getDisplayInfo(0);
|
||||
displaySize.x = ((Integer) DisplayInfo.class.getDeclaredField("logicalWidth").get(di)).intValue();
|
||||
@@ -42,13 +42,13 @@ public class SurfaceControlVirtualDisplayFactory implements VirtualDisplayFactor
|
||||
} else {
|
||||
wm = Stub.asInterface((IBinder) getServiceMethod.invoke(null, new Object[]{"window"}));
|
||||
wm.getRealDisplaySize(displaySize);
|
||||
rotation = wm.getRotation();
|
||||
}
|
||||
if ((rotate && rotation == 1) || rotation == 3) {
|
||||
int swap = displaySize.x;
|
||||
displaySize.x = displaySize.y;
|
||||
displaySize.y = swap;
|
||||
// rotation = wm.getRotation();
|
||||
}
|
||||
// if ((rotate && rotation == 1) || rotation == 3) {
|
||||
// int swap = displaySize.x;
|
||||
// displaySize.x = displaySize.y;
|
||||
// displaySize.y = swap;
|
||||
// }
|
||||
return displaySize;
|
||||
} catch (Exception e) {
|
||||
throw new AssertionError(e);
|
||||
|
||||
Reference in New Issue
Block a user