Skip to content
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

Android 12: Stay Awake setting fails #2402

Closed
2 tasks done
ac87 opened this issue Jun 18, 2021 · 14 comments
Closed
2 tasks done

Android 12: Stay Awake setting fails #2402

ac87 opened this issue Jun 18, 2021 · 14 comments

Comments

@ac87
Copy link

ac87 commented Jun 18, 2021

  • I have read the FAQ.
  • I have searched in existing issues.

Environment

  • OS: Windows
  • scrcpy version: 1.17
  • installation method: Release
  • device model: Pixel 4a
  • Android version: "S" SPB2 (12 Beta 2)

Describe the bug

In addition to the display error in #2129. It looks like writing the settings for stay-awake fails under Android 12.

The error looks a lot like #1468 so I guess Google have changed the methods again. In https://cs.android.com/android/platform/superproject/+/android-s-preview-1:frameworks/base/core/java/android/provider/Settings.java;drc=android-s-preview-1;l=14487

C:\Users\user\Desktop\Tools\scrcpy-win64-v1.17>scrcpy.exe --stay-awake
INFO: scrcpy 1.17 <https://github.com/Genymobile/scrcpy>
C:\Users\user\Desktop\Tools\scrcpy-win64-v1.17\scrcpy-serv... file pushed, 0 skipped. 30.5 MB/s (34930 bytes in 0.001s)
[server] INFO: Device: Google Pixel 4a (Android 11)
[server] ERROR: Could not invoke method
java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.genymobile.scrcpy.wrappers.ContentProvider.call(ContentProvider.java:83)
        at com.genymobile.scrcpy.wrappers.ContentProvider.getValue(ContentProvider.java:124)
        at com.genymobile.scrcpy.wrappers.ContentProvider.getAndPutValue(ContentProvider.java:140)
        at com.genymobile.scrcpy.Server.scrcpy(Server.java:39)
        at com.genymobile.scrcpy.Server.main(Server.java:252)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
Caused by: java.lang.SecurityException: The authority unknown does not match the one of the contentProvider: settings
        at android.os.Parcel.createExceptionOrNull(Parcel.java:2418)
        at android.os.Parcel.createException(Parcel.java:2402)
        at android.os.Parcel.readException(Parcel.java:2385)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:190)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
        at android.content.ContentProviderProxy.call(ContentProviderNative.java:732)
        at android.content.IContentProvider.call(IContentProvider.java:119)
        ... 8 more
Caused by: android.os.RemoteException: Remote stack trace:
        at android.content.ContentProvider.validateIncomingAuthority(ContentProvider.java:2535)
        at android.content.ContentProvider.access$200(ContentProvider.java:108)
        at android.content.ContentProvider$Transport.call(ContentProvider.java:505)
        at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:295)
        at android.os.Binder.execTransactInternal(Binder.java:1179)

[server] ERROR: Could not invoke method
java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.genymobile.scrcpy.wrappers.ContentProvider.call(ContentProvider.java:83)
        at com.genymobile.scrcpy.wrappers.ContentProvider.putValue(ContentProvider.java:136)
        at com.genymobile.scrcpy.wrappers.ContentProvider.getAndPutValue(ContentProvider.java:142)
        at com.genymobile.scrcpy.Server.scrcpy(Server.java:39)
        at com.genymobile.scrcpy.Server.main(Server.java:252)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
Caused by: java.lang.SecurityException: The authority unknown does not match the one of the contentProvider: settings
        at android.os.Parcel.createExceptionOrNull(Parcel.java:2418)
        at android.os.Parcel.createException(Parcel.java:2402)
        at android.os.Parcel.readException(Parcel.java:2385)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:190)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
        at android.content.ContentProviderProxy.call(ContentProviderNative.java:732)
        at android.content.IContentProvider.call(IContentProvider.java:119)
        ... 8 more
[server] ERROR: Exception on thread Thread[main,5,main]
java.lang.AssertionError: java.lang.reflect.InvocationTargetException
        at com.genymobile.scrcpy.wrappers.SurfaceControl.setDisplaySurface(SurfaceControl.java:75)
        at com.genymobile.scrcpy.ScreenEncoder.setDisplaySurface(ScreenEncoder.java:243)
        at com.genymobile.scrcpy.ScreenEncoder.internalStreamScreen(ScreenEncoder.java:91)
        at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:60)
        at com.genymobile.scrcpy.Server.scrcpy(Server.java:80)
        at com.genymobile.scrcpy.Server.main(Server.java:252)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.genymobile.scrcpy.wrappers.SurfaceControl.setDisplaySurface(SurfaceControl.java:73)
        ... 7 more
Caused by: java.lang.IllegalArgumentException: displayToken must not be null
        at android.view.SurfaceControl$Transaction.setDisplaySurface(SurfaceControl.java:3144)
        at android.view.SurfaceControl.setDisplaySurface(SurfaceControl.java:2203)
        ... 9 more
INFO: Renderer: direct3d
INFO: Initial texture: 1080x2336
WARN: Device disconnected
WARN: Killing the server...
@rom1v
Copy link
Collaborator

rom1v commented Jun 18, 2021

Thank you for the report.

Could you please execute scrcpy --stay-awake with this patch, to list the methods available?

diff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/ContentProvider.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/ContentProvider.java
index f8393e59..c24651be 100644
--- a/server/src/main/java/com/genymobile/scrcpy/wrappers/ContentProvider.java
+++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/ContentProvider.java
@@ -45,6 +45,8 @@ public class ContentProvider implements Closeable {
     }
 
     private Method getCallMethod() throws NoSuchMethodException {
+        for (Method m : provider.getClass().getDeclaredMethods())
+            Ln.i("=== " + m);
         if (callMethod == null) {
 
             try {

Here is a binary (to replace in your v1.17 release):

  • scrcpy-server
    SHA256: b97602de06808a6cbc03dd8e59c19eb6c28ba15c60d3583c0ec051e877919fe7

Thank you.

@ac87
Copy link
Author

ac87 commented Jun 18, 2021

Replaced binary

C:\Users\user\Desktop\Tools\scrcpy-win64-v1.17>scrcpy.exe --stay-awake
INFO: scrcpy 1.17 <https://github.com/Genymobile/scrcpy>
C:\Users\user\Desktop\Tools\scrcpy-win64-v1.17\scrcpy-serv... file pushed, 0 skipped. 51.9 MB/s (48739 bytes in 0.001s)
[server] INFO: Device: Google Pixel 4a (Android 11)
[server] INFO: === public android.content.ContentProviderResult[] android.content.ContentProviderProxy.applyBatch(android.content.AttributionSource,java.lang.String,java.util.ArrayList) throws android.os.RemoteException,android.content.OperationApplicationException
[server] INFO: === public android.os.IBinder android.content.ContentProviderProxy.asBinder()
[server] INFO: === public int android.content.ContentProviderProxy.bulkInsert(android.content.AttributionSource,android.net.Uri,android.content.ContentValues[]) throws android.os.RemoteException
[server] INFO: === public android.os.Bundle android.content.ContentProviderProxy.call(android.content.AttributionSource,java.lang.String,java.lang.String,java.lang.String,android.os.Bundle) throws android.os.RemoteException
[server] INFO: === public android.net.Uri android.content.ContentProviderProxy.canonicalize(android.content.AttributionSource,android.net.Uri) throws android.os.RemoteException
[server] INFO: === public void android.content.ContentProviderProxy.canonicalizeAsync(android.content.AttributionSource,android.net.Uri,android.os.RemoteCallback) throws android.os.RemoteException
[server] INFO: === public int android.content.ContentProviderProxy.checkUriPermission(android.content.AttributionSource,android.net.Uri,int,int) throws android.os.RemoteException
[server] INFO: === public android.os.ICancellationSignal android.content.ContentProviderProxy.createCancellationSignal() throws android.os.RemoteException
[server] INFO: === public int android.content.ContentProviderProxy.delete(android.content.AttributionSource,android.net.Uri,android.os.Bundle) throws android.os.RemoteException
[server] INFO: === public java.lang.String[] android.content.ContentProviderProxy.getStreamTypes(android.net.Uri,java.lang.String) throws android.os.RemoteException
[server] INFO: === public java.lang.String android.content.ContentProviderProxy.getType(android.net.Uri) throws android.os.RemoteException
[server] INFO: === public void android.content.ContentProviderProxy.getTypeAsync(android.net.Uri,android.os.RemoteCallback) throws android.os.RemoteException
[server] INFO: === public android.net.Uri android.content.ContentProviderProxy.insert(android.content.AttributionSource,android.net.Uri,android.content.ContentValues,android.os.Bundle) throws android.os.RemoteException
[server] INFO: === public android.content.res.AssetFileDescriptor android.content.ContentProviderProxy.openAssetFile(android.content.AttributionSource,android.net.Uri,java.lang.String,android.os.ICancellationSignal) throws android.os.RemoteException,java.io.FileNotFoundException
[server] INFO: === public android.os.ParcelFileDescriptor android.content.ContentProviderProxy.openFile(android.content.AttributionSource,android.net.Uri,java.lang.String,android.os.ICancellationSignal) throws android.os.RemoteException,java.io.FileNotFoundException
[server] INFO: === public android.content.res.AssetFileDescriptor android.content.ContentProviderProxy.openTypedAssetFile(android.content.AttributionSource,android.net.Uri,java.lang.String,android.os.Bundle,android.os.ICancellationSignal) throws android.os.RemoteException,java.io.FileNotFoundException
[server] INFO: === public android.database.Cursor android.content.ContentProviderProxy.query(android.content.AttributionSource,android.net.Uri,java.lang.String[],android.os.Bundle,android.os.ICancellationSignal) throws android.os.RemoteException
[server] INFO: === public boolean android.content.ContentProviderProxy.refresh(android.content.AttributionSource,android.net.Uri,android.os.Bundle,android.os.ICancellationSignal) throws android.os.RemoteException
[server] INFO: === public android.net.Uri android.content.ContentProviderProxy.uncanonicalize(android.content.AttributionSource,android.net.Uri) throws android.os.RemoteException
[server] INFO: === public void android.content.ContentProviderProxy.uncanonicalizeAsync(android.content.AttributionSource,android.net.Uri,android.os.RemoteCallback) throws android.os.RemoteException
[server] INFO: === public int android.content.ContentProviderProxy.update(android.content.AttributionSource,android.net.Uri,android.content.ContentValues,android.os.Bundle) throws android.os.RemoteException
[server] ERROR: Could not invoke method
java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.genymobile.scrcpy.wrappers.ContentProvider.call(ContentProvider.java:85)
        at com.genymobile.scrcpy.wrappers.ContentProvider.getValue(ContentProvider.java:126)
        at com.genymobile.scrcpy.wrappers.ContentProvider.getAndPutValue(ContentProvider.java:142)
        at com.genymobile.scrcpy.Server.scrcpy(Server.java:39)
        at com.genymobile.scrcpy.Server.main(Server.java:252)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
Caused by: java.lang.SecurityException: The authority unknown does not match the one of the contentProvider: settings
        at android.os.Parcel.createExceptionOrNull(Parcel.java:2418)
        at android.os.Parcel.createException(Parcel.java:2402)
        at android.os.Parcel.readException(Parcel.java:2385)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:190)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
        at android.content.ContentProviderProxy.call(ContentProviderNative.java:732)
        at android.content.IContentProvider.call(IContentProvider.java:119)
        ... 8 more
Caused by: android.os.RemoteException: Remote stack trace:
        at android.content.ContentProvider.validateIncomingAuthority(ContentProvider.java:2535)
        at android.content.ContentProvider.access$200(ContentProvider.java:108)
        at android.content.ContentProvider$Transport.call(ContentProvider.java:505)
        at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:295)
        at android.os.Binder.execTransactInternal(Binder.java:1179)

[server] INFO: === public android.content.ContentProviderResult[] android.content.ContentProviderProxy.applyBatch(android.content.AttributionSource,java.lang.String,java.util.ArrayList) throws android.os.RemoteException,android.content.OperationApplicationException
[server] INFO: === public android.os.IBinder android.content.ContentProviderProxy.asBinder()
[server] INFO: === public int android.content.ContentProviderProxy.bulkInsert(android.content.AttributionSource,android.net.Uri,android.content.ContentValues[]) throws android.os.RemoteException
[server] INFO: === public android.os.Bundle android.content.ContentProviderProxy.call(android.content.AttributionSource,java.lang.String,java.lang.String,java.lang.String,android.os.Bundle) throws android.os.RemoteException
[server] INFO: === public android.net.Uri android.content.ContentProviderProxy.canonicalize(android.content.AttributionSource,android.net.Uri) throws android.os.RemoteException
[server] INFO: === public void android.content.ContentProviderProxy.canonicalizeAsync(android.content.AttributionSource,android.net.Uri,android.os.RemoteCallback) throws android.os.RemoteException
[server] INFO: === public int android.content.ContentProviderProxy.checkUriPermission(android.content.AttributionSource,android.net.Uri,int,int) throws android.os.RemoteException
[server] INFO: === public android.os.ICancellationSignal android.content.ContentProviderProxy.createCancellationSignal() throws android.os.RemoteException
[server] INFO: === public int android.content.ContentProviderProxy.delete(android.content.AttributionSource,android.net.Uri,android.os.Bundle) throws android.os.RemoteException
[server] INFO: === public java.lang.String[] android.content.ContentProviderProxy.getStreamTypes(android.net.Uri,java.lang.String) throws android.os.RemoteException
[server] INFO: === public java.lang.String android.content.ContentProviderProxy.getType(android.net.Uri) throws android.os.RemoteException
[server] INFO: === public void android.content.ContentProviderProxy.getTypeAsync(android.net.Uri,android.os.RemoteCallback) throws android.os.RemoteException
[server] INFO: === public android.net.Uri android.content.ContentProviderProxy.insert(android.content.AttributionSource,android.net.Uri,android.content.ContentValues,android.os.Bundle) throws android.os.RemoteException
[server] INFO: === public android.content.res.AssetFileDescriptor android.content.ContentProviderProxy.openAssetFile(android.content.AttributionSource,android.net.Uri,java.lang.String,android.os.ICancellationSignal) throws android.os.RemoteException,java.io.FileNotFoundException
[server] INFO: === public android.os.ParcelFileDescriptor android.content.ContentProviderProxy.openFile(android.content.AttributionSource,android.net.Uri,java.lang.String,android.os.ICancellationSignal) throws android.os.RemoteException,java.io.FileNotFoundException
[server] INFO: === public android.content.res.AssetFileDescriptor android.content.ContentProviderProxy.openTypedAssetFile(android.content.AttributionSource,android.net.Uri,java.lang.String,android.os.Bundle,android.os.ICancellationSignal) throws android.os.RemoteException,java.io.FileNotFoundException
[server] INFO: === public android.database.Cursor android.content.ContentProviderProxy.query(android.content.AttributionSource,android.net.Uri,java.lang.String[],android.os.Bundle,android.os.ICancellationSignal) throws android.os.RemoteException
[server] INFO: === public boolean android.content.ContentProviderProxy.refresh(android.content.AttributionSource,android.net.Uri,android.os.Bundle,android.os.ICancellationSignal) throws android.os.RemoteException
[server] INFO: === public android.net.Uri android.content.ContentProviderProxy.uncanonicalize(android.content.AttributionSource,android.net.Uri) throws android.os.RemoteException
[server] INFO: === public void android.content.ContentProviderProxy.uncanonicalizeAsync(android.content.AttributionSource,android.net.Uri,android.os.RemoteCallback) throws android.os.RemoteException
[server] INFO: === public int android.content.ContentProviderProxy.update(android.content.AttributionSource,android.net.Uri,android.content.ContentValues,android.os.Bundle) throws android.os.RemoteException
[server] ERROR: Could not invoke method
java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.genymobile.scrcpy.wrappers.ContentProvider.call(ContentProvider.java:85)
        at com.genymobile.scrcpy.wrappers.ContentProvider.putValue(ContentProvider.java:138)
        at com.genymobile.scrcpy.wrappers.ContentProvider.getAndPutValue(ContentProvider.java:144)
        at com.genymobile.scrcpy.Server.scrcpy(Server.java:39)
        at com.genymobile.scrcpy.Server.main(Server.java:252)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
Caused by: java.lang.SecurityException: The authority unknown does not match the one of the contentProvider: settings
        at android.os.Parcel.createExceptionOrNull(Parcel.java:2418)
        at android.os.Parcel.createException(Parcel.java:2402)
        at android.os.Parcel.readException(Parcel.java:2385)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:190)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
        at android.content.ContentProviderProxy.call(ContentProviderNative.java:732)
        at android.content.IContentProvider.call(IContentProvider.java:119)
        ... 8 more
[server] ERROR: Exception on thread Thread[main,5,main]
java.lang.AssertionError: java.lang.reflect.InvocationTargetException
        at com.genymobile.scrcpy.wrappers.SurfaceControl.setDisplaySurface(SurfaceControl.java:75)
        at com.genymobile.scrcpy.ScreenEncoder.setDisplaySurface(ScreenEncoder.java:243)
        at com.genymobile.scrcpy.ScreenEncoder.internalStreamScreen(ScreenEncoder.java:91)
        at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:60)
        at com.genymobile.scrcpy.Server.scrcpy(Server.java:80)
        at com.genymobile.scrcpy.Server.main(Server.java:252)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.genymobile.scrcpy.wrappers.SurfaceControl.setDisplaySurface(SurfaceControl.java:73)
        ... 7 more
Caused by: java.lang.IllegalArgumentException: displayToken must not be null
        at android.view.SurfaceControl$Transaction.setDisplaySurface(SurfaceControl.java:3144)
        at android.view.SurfaceControl.setDisplaySurface(SurfaceControl.java:2203)
        ... 9 more
INFO: Renderer: direct3d
INFO: Initial texture: 1080x2336
WARN: Device disconnected
WARN: Killing the server...

@ac87
Copy link
Author

ac87 commented Jun 18, 2021

@rom1v
Copy link
Collaborator

rom1v commented Jun 18, 2021

Oh, they now pass an instance of AttributionSource, introduced in Android 12.

[server] INFO: === public android.os.Bundle android.content.ContentProviderProxy.call(android.content.AttributionSource,java.lang.String,java.lang.String,java.lang.String,android.os.Bundle) throws android.os.RemoteException

We can try to pass null, but I think it will fail:

diff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/ContentProvider.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/ContentProvider.java
index f8393e59..f0a121c1 100644
--- a/server/src/main/java/com/genymobile/scrcpy/wrappers/ContentProvider.java
+++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/ContentProvider.java
@@ -2,6 +2,7 @@ package com.genymobile.scrcpy.wrappers;
 
 import com.genymobile.scrcpy.Ln;
 
+import android.annotation.SuppressLint;
 import android.os.Bundle;
 import android.os.IBinder;
 
@@ -57,8 +58,20 @@ public class ContentProvider implements Closeable {
                     callMethod = provider.getClass().getMethod("call", String.class, String.class, String.class, String.class, Bundle.class);
                     callMethodVersion = 1;
                 } catch (NoSuchMethodException e2) {
-                    callMethod = provider.getClass().getMethod("call", String.class, String.class, String.class, Bundle.class);
-                    callMethodVersion = 2;
+                    try {
+                        callMethod = provider.getClass().getMethod("call", String.class, String.class, String.class, Bundle.class);
+                        callMethodVersion = 2;
+                    } catch (NoSuchMethodException e3) {
+                        try {
+                            @SuppressLint("PrivateApi")
+                            Class<?> attributionSourceClass = Class.forName("android.content.AttributionSource");
+                            callMethod = provider.getClass()
+                                    .getMethod("call", attributionSourceClass, String.class, String.class, String.class, Bundle.class);
+                            callMethodVersion = 3;
+                        } catch (ClassNotFoundException cnfe) {
+                            throw new AssertionError(cnfe);
+                        }
+                    }
                 }
             }
         }
@@ -76,9 +89,12 @@ public class ContentProvider implements Closeable {
                 case 1:
                     args = new Object[]{ServiceManager.PACKAGE_NAME, "settings", callMethod, arg, extras};
                     break;
-                default:
+                case 2:
                     args = new Object[]{ServiceManager.PACKAGE_NAME, callMethod, arg, extras};
                     break;
+                default:
+                    args = new Object[]{null, "settings", callMethod, arg, extras};
+                    break;
             }
             return (Bundle) method.invoke(provider, args);
         } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
  • scrcpy-server
    SHA256: 616e617e705bad59f493f294f14daf759fd5455b074692178ea79ab09f143589

@ac87
Copy link
Author

ac87 commented Jun 18, 2021

My bad, I'm an idiot.

wrong phone.

@ac87
Copy link
Author

ac87 commented Jun 18, 2021

Looks the same on the Pixel. Too many phones, had swapped to the Samsung to see what the call() looked like on Android 11.

C:\Users\user\Desktop\Tools\scrcpy-win64-v1.17>scrcpy.exe --stay-awake
INFO: scrcpy 1.17 <https://github.com/Genymobile/scrcpy>
C:\Users\user\Desktop\Tools\scrcpy-win64-v1.17\scrcpy-serv... file pushed, 0 skipped. 61.8 MB/s (48739 bytes in 0.001s)
[server] INFO: Device: Google Pixel 4a (Android 11)
[server] INFO: === public android.content.ContentProviderResult[] android.content.ContentProviderProxy.applyBatch(android.content.AttributionSource,java.lang.String,java.util.ArrayList) throws android.os.RemoteException,android.content.OperationApplicationException
[server] INFO: === public android.os.IBinder android.content.ContentProviderProxy.asBinder()
[server] INFO: === public int android.content.ContentProviderProxy.bulkInsert(android.content.AttributionSource,android.net.Uri,android.content.ContentValues[]) throws android.os.RemoteException
[server] INFO: === public android.os.Bundle android.content.ContentProviderProxy.call(android.content.AttributionSource,java.lang.String,java.lang.String,java.lang.String,android.os.Bundle) throws android.os.RemoteException
[server] INFO: === public android.net.Uri android.content.ContentProviderProxy.canonicalize(android.content.AttributionSource,android.net.Uri) throws android.os.RemoteException
[server] INFO: === public void android.content.ContentProviderProxy.canonicalizeAsync(android.content.AttributionSource,android.net.Uri,android.os.RemoteCallback) throws android.os.RemoteException
[server] INFO: === public int android.content.ContentProviderProxy.checkUriPermission(android.content.AttributionSource,android.net.Uri,int,int) throws android.os.RemoteException
[server] INFO: === public android.os.ICancellationSignal android.content.ContentProviderProxy.createCancellationSignal() throws android.os.RemoteException
[server] INFO: === public int android.content.ContentProviderProxy.delete(android.content.AttributionSource,android.net.Uri,android.os.Bundle) throws android.os.RemoteException
[server] INFO: === public java.lang.String[] android.content.ContentProviderProxy.getStreamTypes(android.net.Uri,java.lang.String) throws android.os.RemoteException
[server] INFO: === public java.lang.String android.content.ContentProviderProxy.getType(android.net.Uri) throws android.os.RemoteException
[server] INFO: === public void android.content.ContentProviderProxy.getTypeAsync(android.net.Uri,android.os.RemoteCallback) throws android.os.RemoteException
[server] INFO: === public android.net.Uri android.content.ContentProviderProxy.insert(android.content.AttributionSource,android.net.Uri,android.content.ContentValues,android.os.Bundle) throws android.os.RemoteException
[server] INFO: === public android.content.res.AssetFileDescriptor android.content.ContentProviderProxy.openAssetFile(android.content.AttributionSource,android.net.Uri,java.lang.String,android.os.ICancellationSignal) throws android.os.RemoteException,java.io.FileNotFoundException
[server] INFO: === public android.os.ParcelFileDescriptor android.content.ContentProviderProxy.openFile(android.content.AttributionSource,android.net.Uri,java.lang.String,android.os.ICancellationSignal) throws android.os.RemoteException,java.io.FileNotFoundException
[server] INFO: === public android.content.res.AssetFileDescriptor android.content.ContentProviderProxy.openTypedAssetFile(android.content.AttributionSource,android.net.Uri,java.lang.String,android.os.Bundle,android.os.ICancellationSignal) throws android.os.RemoteException,java.io.FileNotFoundException
[server] INFO: === public android.database.Cursor android.content.ContentProviderProxy.query(android.content.AttributionSource,android.net.Uri,java.lang.String[],android.os.Bundle,android.os.ICancellationSignal) throws android.os.RemoteException
[server] INFO: === public boolean android.content.ContentProviderProxy.refresh(android.content.AttributionSource,android.net.Uri,android.os.Bundle,android.os.ICancellationSignal) throws android.os.RemoteException
[server] INFO: === public android.net.Uri android.content.ContentProviderProxy.uncanonicalize(android.content.AttributionSource,android.net.Uri) throws android.os.RemoteException
[server] INFO: === public void android.content.ContentProviderProxy.uncanonicalizeAsync(android.content.AttributionSource,android.net.Uri,android.os.RemoteCallback) throws android.os.RemoteException
[server] INFO: === public int android.content.ContentProviderProxy.update(android.content.AttributionSource,android.net.Uri,android.content.ContentValues,android.os.Bundle) throws android.os.RemoteException
[server] ERROR: Could not invoke method
java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.genymobile.scrcpy.wrappers.ContentProvider.call(ContentProvider.java:101)
        at com.genymobile.scrcpy.wrappers.ContentProvider.getValue(ContentProvider.java:142)
        at com.genymobile.scrcpy.wrappers.ContentProvider.getAndPutValue(ContentProvider.java:158)
        at com.genymobile.scrcpy.Server.scrcpy(Server.java:39)
        at com.genymobile.scrcpy.Server.main(Server.java:252)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
Caused by: java.lang.SecurityException: The authority unknown does not match the one of the contentProvider: settings
        at android.os.Parcel.createExceptionOrNull(Parcel.java:2418)
        at android.os.Parcel.createException(Parcel.java:2402)
        at android.os.Parcel.readException(Parcel.java:2385)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:190)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
        at android.content.ContentProviderProxy.call(ContentProviderNative.java:732)
        at android.content.IContentProvider.call(IContentProvider.java:119)
        ... 8 more
Caused by: android.os.RemoteException: Remote stack trace:
        at android.content.ContentProvider.validateIncomingAuthority(ContentProvider.java:2535)
        at android.content.ContentProvider.access$200(ContentProvider.java:108)
        at android.content.ContentProvider$Transport.call(ContentProvider.java:505)
        at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:295)
        at android.os.Binder.execTransactInternal(Binder.java:1179)

[server] INFO: === public android.content.ContentProviderResult[] android.content.ContentProviderProxy.applyBatch(android.content.AttributionSource,java.lang.String,java.util.ArrayList) throws android.os.RemoteException,android.content.OperationApplicationException
[server] INFO: === public android.os.IBinder android.content.ContentProviderProxy.asBinder()
[server] INFO: === public int android.content.ContentProviderProxy.bulkInsert(android.content.AttributionSource,android.net.Uri,android.content.ContentValues[]) throws android.os.RemoteException
[server] INFO: === public android.os.Bundle android.content.ContentProviderProxy.call(android.content.AttributionSource,java.lang.String,java.lang.String,java.lang.String,android.os.Bundle) throws android.os.RemoteException
[server] INFO: === public android.net.Uri android.content.ContentProviderProxy.canonicalize(android.content.AttributionSource,android.net.Uri) throws android.os.RemoteException
[server] INFO: === public void android.content.ContentProviderProxy.canonicalizeAsync(android.content.AttributionSource,android.net.Uri,android.os.RemoteCallback) throws android.os.RemoteException
[server] INFO: === public int android.content.ContentProviderProxy.checkUriPermission(android.content.AttributionSource,android.net.Uri,int,int) throws android.os.RemoteException
[server] INFO: === public android.os.ICancellationSignal android.content.ContentProviderProxy.createCancellationSignal() throws android.os.RemoteException
[server] INFO: === public int android.content.ContentProviderProxy.delete(android.content.AttributionSource,android.net.Uri,android.os.Bundle) throws android.os.RemoteException
[server] INFO: === public java.lang.String[] android.content.ContentProviderProxy.getStreamTypes(android.net.Uri,java.lang.String) throws android.os.RemoteException
[server] INFO: === public java.lang.String android.content.ContentProviderProxy.getType(android.net.Uri) throws android.os.RemoteException
[server] INFO: === public void android.content.ContentProviderProxy.getTypeAsync(android.net.Uri,android.os.RemoteCallback) throws android.os.RemoteException
[server] INFO: === public android.net.Uri android.content.ContentProviderProxy.insert(android.content.AttributionSource,android.net.Uri,android.content.ContentValues,android.os.Bundle) throws android.os.RemoteException
[server] INFO: === public android.content.res.AssetFileDescriptor android.content.ContentProviderProxy.openAssetFile(android.content.AttributionSource,android.net.Uri,java.lang.String,android.os.ICancellationSignal) throws android.os.RemoteException,java.io.FileNotFoundException
[server] INFO: === public android.os.ParcelFileDescriptor android.content.ContentProviderProxy.openFile(android.content.AttributionSource,android.net.Uri,java.lang.String,android.os.ICancellationSignal) throws android.os.RemoteException,java.io.FileNotFoundException
[server] INFO: === public android.content.res.AssetFileDescriptor android.content.ContentProviderProxy.openTypedAssetFile(android.content.AttributionSource,android.net.Uri,java.lang.String,android.os.Bundle,android.os.ICancellationSignal) throws android.os.RemoteException,java.io.FileNotFoundException
[server] INFO: === public android.database.Cursor android.content.ContentProviderProxy.query(android.content.AttributionSource,android.net.Uri,java.lang.String[],android.os.Bundle,android.os.ICancellationSignal) throws android.os.RemoteException
[server] INFO: === public boolean android.content.ContentProviderProxy.refresh(android.content.AttributionSource,android.net.Uri,android.os.Bundle,android.os.ICancellationSignal) throws android.os.RemoteException
[server] INFO: === public android.net.Uri android.content.ContentProviderProxy.uncanonicalize(android.content.AttributionSource,android.net.Uri) throws android.os.RemoteException
[server] INFO: === public void android.content.ContentProviderProxy.uncanonicalizeAsync(android.content.AttributionSource,android.net.Uri,android.os.RemoteCallback) throws android.os.RemoteException
[server] INFO: === public int android.content.ContentProviderProxy.update(android.content.AttributionSource,android.net.Uri,android.content.ContentValues,android.os.Bundle) throws android.os.RemoteException
[server] ERROR: Could not invoke method
java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.genymobile.scrcpy.wrappers.ContentProvider.call(ContentProvider.java:101)
        at com.genymobile.scrcpy.wrappers.ContentProvider.putValue(ContentProvider.java:154)
        at com.genymobile.scrcpy.wrappers.ContentProvider.getAndPutValue(ContentProvider.java:160)
        at com.genymobile.scrcpy.Server.scrcpy(Server.java:39)
        at com.genymobile.scrcpy.Server.main(Server.java:252)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
Caused by: java.lang.SecurityException: The authority unknown does not match the one of the contentProvider: settings
        at android.os.Parcel.createExceptionOrNull(Parcel.java:2418)
        at android.os.Parcel.createException(Parcel.java:2402)
        at android.os.Parcel.readException(Parcel.java:2385)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:190)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
        at android.content.ContentProviderProxy.call(ContentProviderNative.java:732)
        at android.content.IContentProvider.call(IContentProvider.java:119)
        ... 8 more
[server] ERROR: Exception on thread Thread[main,5,main]
java.lang.AssertionError: java.lang.reflect.InvocationTargetException
        at com.genymobile.scrcpy.wrappers.SurfaceControl.setDisplaySurface(SurfaceControl.java:75)
        at com.genymobile.scrcpy.ScreenEncoder.setDisplaySurface(ScreenEncoder.java:243)
        at com.genymobile.scrcpy.ScreenEncoder.internalStreamScreen(ScreenEncoder.java:91)
        at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:60)
        at com.genymobile.scrcpy.Server.scrcpy(Server.java:80)
        at com.genymobile.scrcpy.Server.main(Server.java:252)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.genymobile.scrcpy.wrappers.SurfaceControl.setDisplaySurface(SurfaceControl.java:73)
        ... 7 more
Caused by: java.lang.IllegalArgumentException: displayToken must not be null
        at android.view.SurfaceControl$Transaction.setDisplaySurface(SurfaceControl.java:3144)
        at android.view.SurfaceControl.setDisplaySurface(SurfaceControl.java:2203)
        ... 9 more
INFO: Renderer: direct3d
INFO: Initial texture: 1080x2336
WARN: Device disconnected
WARN: Killing the server...

C:\Users\user\Desktop\Tools\scrcpy-win64-v1.17>

@rom1v
Copy link
Collaborator

rom1v commented Jun 18, 2021

Let's try with only the fix (disabling all the other method versions):

diff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/ContentProvider.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/ContentProvider.java
index f8393e59..4cc68253 100644
--- a/server/src/main/java/com/genymobile/scrcpy/wrappers/ContentProvider.java
+++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/ContentProvider.java
@@ -2,6 +2,7 @@ package com.genymobile.scrcpy.wrappers;
 
 import com.genymobile.scrcpy.Ln;
 
+import android.annotation.SuppressLint;
 import android.os.Bundle;
 import android.os.IBinder;
 
@@ -48,18 +49,13 @@ public class ContentProvider implements Closeable {
         if (callMethod == null) {
 
             try {
+                @SuppressLint("PrivateApi")
+                Class<?> attributionSourceClass = Class.forName("android.content.AttributionSource");
                 callMethod = provider.getClass()
-                        .getMethod("call", String.class, String.class, String.class, String.class, String.class, Bundle.class);
-                callMethodVersion = 0;
-            } catch (NoSuchMethodException e) {
-                // old versions
-                try {
-                    callMethod = provider.getClass().getMethod("call", String.class, String.class, String.class, String.class, Bundle.class);
-                    callMethodVersion = 1;
-                } catch (NoSuchMethodException e2) {
-                    callMethod = provider.getClass().getMethod("call", String.class, String.class, String.class, Bundle.class);
-                    callMethodVersion = 2;
-                }
+                        .getMethod("call", attributionSourceClass, String.class, String.class, String.class, Bundle.class);
+                callMethodVersion = -1;
+            } catch (ClassNotFoundException cnfe) {
+                throw new AssertionError(cnfe);
             }
         }
         return callMethod;
@@ -70,14 +66,8 @@ public class ContentProvider implements Closeable {
             Method method = getCallMethod();
             Object[] args;
             switch (callMethodVersion) {
-                case 0:
-                    args = new Object[]{ServiceManager.PACKAGE_NAME, null, "settings", callMethod, arg, extras};
-                    break;
-                case 1:
-                    args = new Object[]{ServiceManager.PACKAGE_NAME, "settings", callMethod, arg, extras};
-                    break;
                 default:
-                    args = new Object[]{ServiceManager.PACKAGE_NAME, callMethod, arg, extras};
+                    args = new Object[]{null, "settings", callMethod, arg, extras};
                     break;
             }
             return (Bundle) method.invoke(provider, args);
  • scrcpy-server
    SHA256: 56226a8565aad1abfda1a509b3d228cba22cffbfefbf23bfba8a7c8c3a6f0d5f

@ac87
Copy link
Author

ac87 commented Jun 18, 2021

C:\Users\user\Desktop\Tools\scrcpy-win64-v1.17>scrcpy.exe --stay-awake
INFO: scrcpy 1.17 <https://github.com/Genymobile/scrcpy>
C:\Users\user\Desktop\Tools\scrcpy-win64-v1.17\scrcpy-serv... file pushed, 0 skipped. 36.8 MB/s (48739 bytes in 0.001s)
[server] INFO: Device: Google Pixel 4a (Android 11)
[server] ERROR: Could not invoke method
java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.genymobile.scrcpy.wrappers.ContentProvider.call(ContentProvider.java:72)
        at com.genymobile.scrcpy.wrappers.ContentProvider.getValue(ContentProvider.java:113)
        at com.genymobile.scrcpy.wrappers.ContentProvider.getAndPutValue(ContentProvider.java:129)
        at com.genymobile.scrcpy.Server.scrcpy(Server.java:39)
        at com.genymobile.scrcpy.Server.main(Server.java:252)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.content.AttributionSource.writeToParcel(android.os.Parcel, int)' on a null object reference
        at android.content.ContentProviderProxy.call(ContentProviderNative.java:724)
        ... 8 more
[server] ERROR: Could not invoke method
java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.genymobile.scrcpy.wrappers.ContentProvider.call(ContentProvider.java:72)
        at com.genymobile.scrcpy.wrappers.ContentProvider.putValue(ContentProvider.java:125)
        at com.genymobile.scrcpy.wrappers.ContentProvider.getAndPutValue(ContentProvider.java:131)
        at com.genymobile.scrcpy.Server.scrcpy(Server.java:39)
        at com.genymobile.scrcpy.Server.main(Server.java:252)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.content.AttributionSource.writeToParcel(android.os.Parcel, int)' on a null object reference
        at android.content.ContentProviderProxy.call(ContentProviderNative.java:724)
        ... 8 more
[server] ERROR: Exception on thread Thread[main,5,main]
java.lang.AssertionError: java.lang.reflect.InvocationTargetException
        at com.genymobile.scrcpy.wrappers.SurfaceControl.setDisplaySurface(SurfaceControl.java:75)
        at com.genymobile.scrcpy.ScreenEncoder.setDisplaySurface(ScreenEncoder.java:243)
        at com.genymobile.scrcpy.ScreenEncoder.internalStreamScreen(ScreenEncoder.java:91)
        at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:60)
        at com.genymobile.scrcpy.Server.scrcpy(Server.java:80)
        at com.genymobile.scrcpy.Server.main(Server.java:252)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.genymobile.scrcpy.wrappers.SurfaceControl.setDisplaySurface(SurfaceControl.java:73)
        ... 7 more
Caused by: java.lang.IllegalArgumentException: displayToken must not be null
        at android.view.SurfaceControl$Transaction.setDisplaySurface(SurfaceControl.java:3144)
        at android.view.SurfaceControl.setDisplaySurface(SurfaceControl.java:2203)
        ... 9 more
INFO: Renderer: direct3d
INFO: Initial texture: 1080x2336
WARN: Device disconnected
WARN: Killing the server...

C:\Users\user\Desktop\Tools\scrcpy-win64-v1.17>

I've got a separate app with just the ContentProvider in, you are right, it doesn't like passing null. It does like the code from that test app

Object attrSrcObj = null;
try {
    Class<?> attrSrcClass = Class.forName("android.content.AttributionSource");
    Constructor<?> attrSrcCons = attrSrcClass.getConstructor(Integer.TYPE, String.class, String.class);
    attrSrcObj = attrSrcCons.newInstance(/* uid */ -1, null, null);
} catch (ClassNotFoundException | InstantiationException e) {
    e.printStackTrace();
}
args = new Object[]{attrSrcObj, "settings", callMethod, arg, extras};

@rom1v
Copy link
Collaborator

rom1v commented Jun 18, 2021

Let's create an AttributionSource then:

diff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/ContentProvider.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/ContentProvider.java
index f8393e59..b6d7f5f0 100644
--- a/server/src/main/java/com/genymobile/scrcpy/wrappers/ContentProvider.java
+++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/ContentProvider.java
@@ -2,6 +2,7 @@ package com.genymobile.scrcpy.wrappers;
 
 import com.genymobile.scrcpy.Ln;
 
+import android.annotation.SuppressLint;
 import android.os.Bundle;
 import android.os.IBinder;
 
@@ -48,18 +49,13 @@ public class ContentProvider implements Closeable {
         if (callMethod == null) {
 
             try {
+                @SuppressLint("PrivateApi")
+                Class<?> attributionSourceClass = Class.forName("android.content.AttributionSource");
                 callMethod = provider.getClass()
-                        .getMethod("call", String.class, String.class, String.class, String.class, String.class, Bundle.class);
-                callMethodVersion = 0;
-            } catch (NoSuchMethodException e) {
-                // old versions
-                try {
-                    callMethod = provider.getClass().getMethod("call", String.class, String.class, String.class, String.class, Bundle.class);
-                    callMethodVersion = 1;
-                } catch (NoSuchMethodException e2) {
-                    callMethod = provider.getClass().getMethod("call", String.class, String.class, String.class, Bundle.class);
-                    callMethodVersion = 2;
-                }
+                        .getMethod("call", attributionSourceClass, String.class, String.class, String.class, Bundle.class);
+                callMethodVersion = -1;
+            } catch (ClassNotFoundException cnfe) {
+                throw new AssertionError(cnfe);
             }
         }
         return callMethod;
@@ -70,18 +66,16 @@ public class ContentProvider implements Closeable {
             Method method = getCallMethod();
             Object[] args;
             switch (callMethodVersion) {
-                case 0:
-                    args = new Object[]{ServiceManager.PACKAGE_NAME, null, "settings", callMethod, arg, extras};
-                    break;
-                case 1:
-                    args = new Object[]{ServiceManager.PACKAGE_NAME, "settings", callMethod, arg, extras};
-                    break;
                 default:
-                    args = new Object[]{ServiceManager.PACKAGE_NAME, callMethod, arg, extras};
+                    Class<?> cl = Class.forName("android.content.AttributionSource$Builder");
+                    Object builder = cl.getConstructor(int.class).newInstance(ServiceManager.USER_ID);
+                    cl.getDeclaredMethod("setPackageName", String.class).invoke(builder, ServiceManager.PACKAGE_NAME);
+                    Object attributionSource = cl.getDeclaredMethod("build").invoke(builder);
+                    args = new Object[]{attributionSource, "settings", callMethod, arg, extras};
                     break;
             }
             return (Bundle) method.invoke(provider, args);
-        } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
+        } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException | ClassNotFoundException | InstantiationException e) {
             Ln.e("Could not invoke method", e);
             return null;
         }
  • scrcpy-server
    SHA256: 485e2474896da6e17c8da9ccbe84d6c5ef96d304a7b61447394f1f12a7df383b

@ac87
Copy link
Author

ac87 commented Jun 18, 2021

LGTM. I guess it immediately cleans up that its changed it due to the other issue.

C:\Users\user\Desktop\Tools\scrcpy-win64-v1.17>scrcpy.exe --stay-awake
INFO: scrcpy 1.17 <https://github.com/Genymobile/scrcpy>
C:\Users\user\Desktop\Tools\scrcpy-win64-v1.17\scrcpy-serv... file pushed, 0 skipped. 53.9 MB/s (48739 bytes in 0.001s)
[server] INFO: Device: Google Pixel 4a (Android 11)
[server] ERROR: Exception on thread Thread[main,5,main]
java.lang.AssertionError: java.lang.reflect.InvocationTargetException
        at com.genymobile.scrcpy.wrappers.SurfaceControl.setDisplaySurface(SurfaceControl.java:75)
        at com.genymobile.scrcpy.ScreenEncoder.setDisplaySurface(ScreenEncoder.java:243)
        at com.genymobile.scrcpy.ScreenEncoder.internalStreamScreen(ScreenEncoder.java:91)
        at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:60)
        at com.genymobile.scrcpy.Server.scrcpy(Server.java:80)
        at com.genymobile.scrcpy.Server.main(Server.java:252)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.genymobile.scrcpy.wrappers.SurfaceControl.setDisplaySurface(SurfaceControl.java:73)
        ... 7 more
Caused by: java.lang.IllegalArgumentException: displayToken must not be null
        at android.view.SurfaceControl$Transaction.setDisplaySurface(SurfaceControl.java:3144)
        at android.view.SurfaceControl.setDisplaySurface(SurfaceControl.java:2203)
        ... 9 more
INFO: Renderer: direct3d
INFO: Initial texture: 1080x2336
WARN: Device disconnected
WARN: Killing the server...

@rom1v
Copy link
Collaborator

rom1v commented Jun 18, 2021

Ok, good, thank you. Will do a proper fix.

rom1v added a commit that referenced this issue Jun 19, 2021
Android 12 changed one of the call() overloads with a new parameter
AttributionSource. Adapt the wrapper.

Fixes #2402 <#2402>
@rom1v
Copy link
Collaborator

rom1v commented Jun 19, 2021

I implemented a proper fix on fix_android12_settings.

Please confirm that it works for you before I merge it into dev. (You could try both --stay-awake and --show-touches.)

Here are binaries (replace both files in v1.17):

  • scrcpy.exe
    SHA256: e170aa18264c4a319217beaeddc42049902b3f8c5d5c897c10abf92fb0a825b8
  • scrcpy-server
    SHA256: 37d76e0bda8b221bef9a71dd1f6381308e99dfcd99cd863249f2787598aae645

@ac87
Copy link
Author

ac87 commented Jun 19, 2021

No errors in the console and screen mirrors
--show-touches and --stay-awake both working.

rom1v added a commit that referenced this issue Jun 19, 2021
Android 12 changed one of the call() overloads with a new parameter
AttributionSource. Adapt the wrapper.

Fixes #2402 <#2402>
@rom1v
Copy link
Collaborator

rom1v commented Jun 19, 2021

Great! Thank you. Merged into dev.

@rom1v rom1v closed this as completed Jun 19, 2021
rom1v added a commit that referenced this issue Jun 19, 2021
Android 12 changed one of the call() overloads with a new parameter
AttributionSource. Adapt the wrapper.

Fixes #2402 <#2402>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants