Skip to content

Commit 47d27c9

Browse files
author
wanjian
committed
去除屏幕方向判断,兼容Android8.0
1 parent 7d306fc commit 47d27c9

File tree

5 files changed

+53
-36
lines changed

5 files changed

+53
-36
lines changed

Main.dex

320 Bytes
Binary file not shown.

lib/src/main/java/com/client/Client.java

+14-6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
public class Client extends JFrame {
2828
JLabel label;
2929
boolean isMove = false;
30+
JLabel tips;
3031

3132
public Client() throws IOException {
3233
setLayout(new BorderLayout(0, 0));
@@ -45,10 +46,16 @@ public Client() throws IOException {
4546

4647
JPanel btnPanel = new JPanel(new BorderLayout(5, 5));
4748
JButton btn = new JButton("链接");
48-
btnPanel.add(btn, BorderLayout.CENTER);
49+
btnPanel.add(btn, BorderLayout.NORTH);
4950

50-
JSlider jSlider=createSlider();
51-
btnPanel.add(jSlider,BorderLayout.SOUTH);
51+
tips = new JLabel();
52+
tips.setBorder(new EmptyBorder(0, 8, 0, 0));
53+
tips.setText("清晰度 100%");
54+
btnPanel.add(tips, BorderLayout.CENTER);
55+
56+
57+
JSlider jSlider = createSlider();
58+
btnPanel.add(jSlider, BorderLayout.SOUTH);
5259

5360
JPanel panelContainer = new JPanel(new BorderLayout());
5461
panelContainer.add(ipPanel, BorderLayout.NORTH);
@@ -148,14 +155,15 @@ public void mouseDragged(MouseEvent mouseEvent) {
148155
private JSlider createSlider() {
149156
int minimum = 30;
150157
int maximum = 100;
151-
JSlider slider = new JSlider(minimum, maximum,maximum);
158+
JSlider slider = new JSlider(minimum, maximum, maximum);
152159

153160
slider.addChangeListener(new ChangeListener() {
154161
@Override
155162
public void stateChanged(ChangeEvent changeEvent) {
156163
try {
157-
int v=((JSlider) changeEvent.getSource()).getValue();
158-
writer.write("DEGREE"+v);
164+
int v = ((JSlider) changeEvent.getSource()).getValue();
165+
tips.setText("清晰度 " + v + "%");
166+
writer.write("DEGREE" + v);
159167
writer.newLine();
160168
writer.flush();
161169
} catch (Exception e) {

shareandcontrollib/src/main/java/android/view/IWindowManager.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
public interface IWindowManager {
1111
void getInitialDisplaySize(int i, Point displaySize);
1212

13-
int getRotation();
13+
// int getRotation();
1414

1515
void getRealDisplaySize(Point displaySize);
1616

shareandcontrollib/src/main/java/com/wanjian/puppet/Main.java

+31-22
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ public class Main {
4141
public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, IOException {
4242

4343
System.out.println("start!");
44+
45+
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
46+
@Override
47+
public void uncaughtException(Thread t, Throwable e) {
48+
System.out.println(e.getMessage());
49+
}
50+
});
51+
4452
LocalServerSocket serverSocket = new LocalServerSocket("puppet-ver1");
4553

4654
init();
@@ -51,6 +59,7 @@ public static void main(String[] args) throws ClassNotFoundException, NoSuchMeth
5159
LocalSocket socket = serverSocket.accept();
5260
acceptConnect(socket);
5361
} catch (Exception e) {
62+
System.out.println(e.getMessage());
5463
serverSocket = new LocalServerSocket("puppet-ver1");
5564
}
5665

@@ -93,8 +102,8 @@ public void run() {
93102
outputStream.write(byteArrayOutputStream.toByteArray());
94103
outputStream.flush();
95104
}
96-
} catch (Exception e) {
97-
e.printStackTrace();
105+
} catch (Throwable e) {
106+
System.out.println(e.getMessage());
98107
}
99108
}
100109
}.start();
@@ -126,7 +135,7 @@ public void run() {
126135
return;
127136
}
128137
} catch (Exception e) {
129-
e.printStackTrace();
138+
System.out.println(e.getMessage());
130139
return;
131140
}
132141
try {
@@ -146,13 +155,13 @@ public void run() {
146155
scale = Float.parseFloat(line.substring(DEGREE.length())) / 100;
147156
}
148157
} catch (Exception e) {
149-
e.printStackTrace();
158+
System.out.println(e.getMessage());
150159
}
151160

152161

153162
}
154-
} catch (Exception e) {
155-
e.printStackTrace();
163+
} catch (Throwable e) {
164+
System.out.println(e.getMessage());
156165
}
157166

158167
}
@@ -165,7 +174,7 @@ private static void handlerUp(String line) {
165174
try {
166175
touchUp(point.x, point.y);
167176
} catch (Exception e) {
168-
e.printStackTrace();
177+
System.out.println(e.getMessage());
169178
}
170179
}
171180
}
@@ -176,7 +185,7 @@ private static void hanlerMove(String line) {
176185
try {
177186
touchMove(point.x, point.y);
178187
} catch (Exception e) {
179-
e.printStackTrace();
188+
System.out.println(e.getMessage());
180189
}
181190
}
182191
}
@@ -187,7 +196,7 @@ private static void hanlerDown(String line) {
187196
try {
188197
touchDown(point.x, point.y);
189198
} catch (Exception e) {
190-
e.printStackTrace();
199+
System.out.println(e.getMessage());
191200
}
192201
}
193202
}
@@ -203,7 +212,7 @@ private static Point getXY(String nums) {
203212
point.y *= scaleY;
204213
return point;
205214
} catch (Exception e) {
206-
e.printStackTrace();
215+
System.out.println(e.getMessage());
207216
}
208217
return null;
209218
}
@@ -232,19 +241,19 @@ public static Bitmap screenshot() throws Exception {
232241
}
233242
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)});
234243

235-
int rotation = wm.getRotation();
236-
237-
if (rotation == 0) {
238-
return b;
239-
}
244+
// int rotation = wm.getRotation();
245+
//
246+
// if (rotation == 0) {
247+
// return b;
248+
// }
240249
Matrix m = new Matrix();
241-
if (rotation == 1) {
242-
m.postRotate(-90.0f);
243-
} else if (rotation == 2) {
244-
m.postRotate(-180.0f);
245-
} else if (rotation == 3) {
246-
m.postRotate(-270.0f);
247-
}
250+
// if (rotation == 1) {
251+
// m.postRotate(-90.0f);
252+
// } else if (rotation == 2) {
253+
// m.postRotate(-180.0f);
254+
// } else if (rotation == 3) {
255+
// m.postRotate(-270.0f);
256+
// }
248257
return Bitmap.createBitmap(b, 0, 0, size.x, size.y, m, false);
249258

250259
}

shareandcontrollib/src/main/java/com/wanjian/puppet/SurfaceControlVirtualDisplayFactory.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static Point getCurrentDisplaySize(boolean rotate) {
3333
if (VERSION.SDK_INT >= 18) {
3434
wm = Stub.asInterface((IBinder) getServiceMethod.invoke(null, new Object[]{"window"}));
3535
wm.getInitialDisplaySize(0, displaySize);
36-
rotation = wm.getRotation();
36+
// rotation = wm.getRotation();
3737
} else if (VERSION.SDK_INT == 17) {
3838
DisplayInfo di = IDisplayManager.Stub.asInterface((IBinder) getServiceMethod.invoke(null, new Object[]{"display"})).getDisplayInfo(0);
3939
displaySize.x = ((Integer) DisplayInfo.class.getDeclaredField("logicalWidth").get(di)).intValue();
@@ -42,13 +42,13 @@ public static Point getCurrentDisplaySize(boolean rotate) {
4242
} else {
4343
wm = Stub.asInterface((IBinder) getServiceMethod.invoke(null, new Object[]{"window"}));
4444
wm.getRealDisplaySize(displaySize);
45-
rotation = wm.getRotation();
46-
}
47-
if ((rotate && rotation == 1) || rotation == 3) {
48-
int swap = displaySize.x;
49-
displaySize.x = displaySize.y;
50-
displaySize.y = swap;
45+
// rotation = wm.getRotation();
5146
}
47+
// if ((rotate && rotation == 1) || rotation == 3) {
48+
// int swap = displaySize.x;
49+
// displaySize.x = displaySize.y;
50+
// displaySize.y = swap;
51+
// }
5252
return displaySize;
5353
} catch (Exception e) {
5454
throw new AssertionError(e);

0 commit comments

Comments
 (0)