Skip to content

Commit 2b6089c

Browse files
committed
Enable workarounds by default
Workarounds were disabled by default, and only enabled for some devices or under specific conditions. But it seems they are needed for more and more devices, so enable them by default. They could be disabled for specific devices if necessary in the future. In the past, these workarounds caused a (harmless) exception to be printed on some Xiaomi devices [1]. But this is not a problem anymore since commit b8c5853. They also caused problems for audio on Vivo devices [2], but it seems this is not the case anymore [3]. They might also impact an old Nvidia Shield [4], but hopefully this is fixed now. [1]: <#4015 (comment)> [2]: <#3805 (comment)> [3]: <#3805 (comment)> [4]: <#940> PR #5154 <#5154>
1 parent f691ebb commit 2b6089c

File tree

2 files changed

+7
-55
lines changed

2 files changed

+7
-55
lines changed

server/src/main/java/com/genymobile/scrcpy/Server.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ private static void scrcpy(Options options) throws IOException, ConfigurationExc
144144

145145
final Device device = camera ? null : new Device(options);
146146

147-
Workarounds.apply(audio, camera);
147+
Workarounds.apply();
148148

149149
List<AsyncProcessor> asyncProcessors = new ArrayList<>();
150150

@@ -279,7 +279,7 @@ private static void internalMain(String... args) throws Exception {
279279
Ln.i(LogUtils.buildDisplayListMessage());
280280
}
281281
if (options.getListCameras() || options.getListCameraSizes()) {
282-
Workarounds.apply(false, true);
282+
Workarounds.apply();
283283
Ln.i(LogUtils.buildCameraListMessage(options.getListCameraSizes()));
284284
}
285285
// Just print the requested data, do not mirror

server/src/main/java/com/genymobile/scrcpy/Workarounds.java

+5-53
Original file line numberDiff line numberDiff line change
@@ -51,66 +51,18 @@ private Workarounds() {
5151
// not instantiable
5252
}
5353

54-
public static void apply(boolean audio, boolean camera) {
55-
boolean mustFillConfigurationController = false;
56-
boolean mustFillAppInfo = false;
57-
boolean mustFillAppContext = false;
58-
59-
if (Build.BRAND.equalsIgnoreCase("meizu")) {
60-
// Workarounds must be applied for Meizu phones:
61-
// - <https://github.com/Genymobile/scrcpy/issues/240>
62-
// - <https://github.com/Genymobile/scrcpy/issues/365>
63-
// - <https://github.com/Genymobile/scrcpy/issues/2656>
64-
//
65-
// But only apply when strictly necessary, since workarounds can cause other issues:
66-
// - <https://github.com/Genymobile/scrcpy/issues/940>
67-
// - <https://github.com/Genymobile/scrcpy/issues/994>
68-
mustFillAppInfo = true;
69-
} else if (Build.BRAND.equalsIgnoreCase("honor") || Build.MANUFACTURER.equalsIgnoreCase("skyworth") || Build.BRAND.equalsIgnoreCase("tcl")) {
70-
// More workarounds must be applied for Honor devices:
71-
// - <https://github.com/Genymobile/scrcpy/issues/4015>
72-
// for Skyworth devices:
73-
// - <https://github.com/Genymobile/scrcpy/issues/4922>
74-
// and for TCL devices:
75-
// - <https://github.com/Genymobile/scrcpy/issues/5140>
76-
//
77-
// The system context must not be set for all devices, because it would cause other problems:
78-
// - <https://github.com/Genymobile/scrcpy/issues/4015#issuecomment-1595382142>
79-
// - <https://github.com/Genymobile/scrcpy/issues/3805#issuecomment-1596148031>
80-
mustFillAppInfo = true;
81-
mustFillAppContext = true;
82-
}
83-
84-
if (audio && Build.VERSION.SDK_INT == Build.VERSION_CODES.R) {
85-
// Before Android 11, audio is not supported.
86-
// Since Android 12, we can properly set a context on the AudioRecord.
87-
// Only on Android 11 we must fill the application context for the AudioRecord to work.
88-
mustFillAppContext = true;
89-
}
90-
91-
if (camera) {
92-
mustFillAppInfo = true;
93-
mustFillAppContext = true;
94-
}
95-
54+
public static void apply() {
9655
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
9756
// On some Samsung devices, DisplayManagerGlobal.getDisplayInfoLocked() calls ActivityThread.currentActivityThread().getConfiguration(),
9857
// which requires a non-null ConfigurationController.
9958
// ConfigurationController was introduced in Android 12, so do not attempt to set it on lower versions.
10059
// <https://github.com/Genymobile/scrcpy/issues/4467>
101-
mustFillConfigurationController = true;
102-
}
103-
104-
if (mustFillConfigurationController) {
105-
// Must be call before fillAppContext() because it is necessary to get a valid system context
60+
// Must be called before fillAppContext() because it is necessary to get a valid system context.
10661
fillConfigurationController();
10762
}
108-
if (mustFillAppInfo) {
109-
fillAppInfo();
110-
}
111-
if (mustFillAppContext) {
112-
fillAppContext();
113-
}
63+
64+
fillAppInfo();
65+
fillAppContext();
11466
}
11567

11668
@SuppressWarnings("deprecation")

0 commit comments

Comments
 (0)