-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash on Android 12 Developer Preview 1 (secure flag) #2129
Comments
Thank you for your report. Could you please apply this patch, run scrcpy, and provide the output, please? diff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/SurfaceControl.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/SurfaceControl.java
index 8fbb860b..f173a6a7 100644
--- a/server/src/main/java/com/genymobile/scrcpy/wrappers/SurfaceControl.java
+++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/SurfaceControl.java
@@ -23,6 +23,10 @@ public final class SurfaceControl {
static {
try {
CLASS = Class.forName("android.view.SurfaceControl");
+
+ for (Method m : CLASS.getDeclaredMethods()) {
+ Ln.i("-- " + m);
+ }
} catch (ClassNotFoundException e) {
throw new AssertionError(e);
} |
adb logcat
@rom1v please take it as refer, thanks~ |
Seems "public static void android.view.SurfaceControl.setDisplaySurface(android.os.IBinder,android.view.Surface)" keeps no change, so the error occurs from "displayToken must not be null". |
debug the source code , when 02-19 14:49:43.824 741 1870 E SurfaceFlinger: Only privileged processes can create a secure display so, modify the parameter “secure“ to false in Android 12. and re build the project to test, this problem was fixed. |
The source code of Android 12 is not available yet, but they probably remove |
Refs #1935 |
Sorry, I wasn't available to do that yesterday. In this case, maybe there's a better way that @rom1v knows, otherwise the createDisplay call with secure = false works. I don't understand the implications of that flag though. Do you think it would be valuable to have a special case for Android 12 where |
No, I have no other solution. (I have this change in mind since #1935, but the Android 12 preview was not available at that time.)
Yes, I guess I will merge something like this: android12_nosecure Unfortunately, #36 will be "unsolved". |
Other than that, everything works correctly on Android 12? |
Tried all the shortcuts and wifi debugging, everything there seemed fine. |
Thank you 👍 |
@rom1v I actually found various issues, even on third party apps. For example, on Nova launcher, dragging an app from the app drawer will crash it... Sadly this occurs on Windows 10 too. I can't use ScrCpy with Android 12 at all. Will it be possible for scrCpy to still work? Or you think Android should change? If so, can you please create something on the issue tracker: I love this tool! |
What if you drag it without scrcpy? What is the error (in |
@rom1v It has nothing to do with scrcpy. I drag the camera app, and Nova launcher crashes, for example, but for some apps it is ok. |
I might be misunderstanding what you're saying but we weren't talking about the stability of Android 12. That's in its first developer preview so bugs are expected. We were talking about the stability of scrcpy working with Android 12 after the fix discussed in this thread. Could you try the fix? |
@AfzalivE Wait you mean there is a fix to the crash? I don't see it mentioned here. |
FYI, for this check to work on the developer preview:
Need to add, eg:
Since the preview still reports the the SDK as 30 |
Is this issue on scrcpy itself, or because of Android 12 ? Would that help? |
In general, using BuildCompat.isAtLeastS() is the robust way to do this sort of check. |
|
Cross-ref: https://issuetracker.google.com/issues/180777866 EDIT: Here is the bug report content:
The bug has been assigned, and its state has been set to:
I have no more details. |
@rom1v What is this link? I can't reach it... |
In case anyone needs to know of the one workaround that does exist, if you are comfortable with rooting your device you can follow these instructions:
Unfortunately disabling flag_secure also means that the apps you disable it for will be, well, insecure. It will be possible to take screenshots of them and so forth. If any attacks targeting Android use the screen as their attack vector, the added security of flag_secure will no longer protect you. Rooting your device may also interfere with things like banking apps. To work around that, you can install an additional Magisk module called "Shamiko" which will help your device bypass SafetyNet checks. I have also installed the LPosed module "HiddenCore" but I don't know if this is actually doing anything for me that Shamiko isn't, since it hasn't been updated in quite some time and doesn't even seem to be in the LPosed repository anymore. Hopefully this information will prove useful for users with disabilities who rely on scrcpy to use their mobile devices. |
Root users may also use this fork which simply runs the scrcpy-server as the system user: #3049 (comment) |
Environment
ADB Logcat output
adb logcat
Terminal output
EDIT by rom1v: Use scrcpy >= 1.18
The text was updated successfully, but these errors were encountered: