mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-04-21 03:55:05 +00:00
Add intents capability and handling to the server
This commit is contained in:
parent
538320add9
commit
fc97b00ac8
3 changed files with 56 additions and 1 deletions
36
server/src/main/java/com/genymobile/scrcpy/Intents.java
Normal file
36
server/src/main/java/com/genymobile/scrcpy/Intents.java
Normal file
|
@ -0,0 +1,36 @@
|
|||
package com.genymobile.scrcpy;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
enum Intents {
|
||||
START(1),
|
||||
STOP(30),
|
||||
CLEANED(31),
|
||||
;
|
||||
|
||||
public static final String SCRCPY_PREFIX = "com.genymobile.scrcpy.";
|
||||
|
||||
int shift;
|
||||
Intents(int shift) {
|
||||
this.shift = shift;
|
||||
}
|
||||
|
||||
public static EnumSet<Intents> fromBitSet(BitSet bits) {
|
||||
EnumSet<Intents> es = EnumSet.allOf(Intents.class);
|
||||
|
||||
Iterator<Intents> it = es.iterator();
|
||||
Intents intent;
|
||||
while (it.hasNext()) {
|
||||
intent = it.next();
|
||||
if (!bits.get(intent.shift - 1)) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
return es;
|
||||
}
|
||||
|
||||
public static String scrcpyPrefix(String unprefixed){
|
||||
return SCRCPY_PREFIX + unprefixed;
|
||||
}
|
||||
}
|
|
@ -2,6 +2,9 @@ package com.genymobile.scrcpy;
|
|||
|
||||
import android.graphics.Rect;
|
||||
|
||||
import java.util.BitSet;
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class Options {
|
||||
private Ln.Level logLevel;
|
||||
private int maxSize;
|
||||
|
@ -18,6 +21,7 @@ public class Options {
|
|||
private String codecOptions;
|
||||
private String encoderName;
|
||||
private boolean powerOffScreenOnClose;
|
||||
private EnumSet<Intents> broadcastIntents;
|
||||
|
||||
public Ln.Level getLogLevel() {
|
||||
return logLevel;
|
||||
|
@ -83,6 +87,10 @@ public class Options {
|
|||
this.sendFrameMeta = sendFrameMeta;
|
||||
}
|
||||
|
||||
public void setBroadcastIntents(EnumSet<Intents> broadcastIntents) {
|
||||
this.broadcastIntents = broadcastIntents;
|
||||
}
|
||||
|
||||
public boolean getControl() {
|
||||
return control;
|
||||
}
|
||||
|
@ -138,4 +146,8 @@ public class Options {
|
|||
public boolean getPowerOffScreenOnClose() {
|
||||
return this.powerOffScreenOnClose;
|
||||
}
|
||||
|
||||
public EnumSet<Intents> getBroadcastIntents() {
|
||||
return broadcastIntents;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.genymobile.scrcpy;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import com.genymobile.scrcpy.wrappers.ContentProvider;
|
||||
|
||||
import android.graphics.Rect;
|
||||
|
@ -9,6 +11,8 @@ import android.os.BatteryManager;
|
|||
import android.os.Build;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.BitSet;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
|
@ -135,7 +139,7 @@ public final class Server {
|
|||
"The server version (" + BuildConfig.VERSION_NAME + ") does not match the client " + "(" + clientVersion + ")");
|
||||
}
|
||||
|
||||
final int expectedParameters = 16;
|
||||
final int expectedParameters = 17;
|
||||
if (args.length != expectedParameters) {
|
||||
throw new IllegalArgumentException("Expecting " + expectedParameters + " parameters");
|
||||
}
|
||||
|
@ -188,6 +192,9 @@ public final class Server {
|
|||
boolean powerOffScreenOnClose = Boolean.parseBoolean(args[15]);
|
||||
options.setPowerOffScreenOnClose(powerOffScreenOnClose);
|
||||
|
||||
EnumSet<Intents> broadcastIntents = Intents.fromBitSet(BitSet.valueOf(new long[]{Long.parseLong(args[16])}));
|
||||
options.setBroadcastIntents(broadcastIntents);
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue