MIUI13截图功能失效,获取截图权限程序崩溃

异常信息
Version: 505
Android: 31
android.os.RemoteException: Remote stack trace:
at com.android.server.media.projection.MediaProjectionManagerService$MediaProjection.start(MediaProjectionManagerService.java:553)
at android.media.projection.IMediaProjection$Stub.onTransact(IMediaProjection.java:137)
at android.os.Binder.execTransactInternal(Binder.java:1182)
at android.os.Binder.execTransact(Binder.java:1146)

java.lang.RuntimeException:Failure delivering result ResultInfo{who=null, request=17777, result=-1, data=Intent { (has extras) }} to activity {org.autojs.autojs/com.stardust.autojs.core.image.capture.ScreenCaptureRequestActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'boolean java.util.Set.add(java.lang.Object)' on a null object reference
android.app.ActivityThread.deliverResults(ActivityThread.java:5411)
......
Caused by:
android.os.RemoteException:Remote stack trace:
at com.android.server.media.projection.MediaProjectionManagerService$MediaProjection.start(MediaProjectionManagerService.java:553)
at android.media.projection.IMediaProjection$Stub.onTransact(IMediaProjection.java:137)
at android.os.Binder.execTransactInternal(Binder.java:1182)
at android.os.Binder.execTransact(Binder.java:1146)

这是MIUI13的bug,需要等MIUI官方修复

MIUI13+Android12

RemoteException报错在MediaProjectionManagerService的553行,查阅源码发现错误信息为找不到申请mediaprojection的包。
猜测MIUI针对此处单独维护了一个list,只有申请过权限的package会在其中,且获得过mediaprojection并用完close后会移除。而其他系统未见到此类机制。

也就是说,无法复用intent data。解决方法也很简单,用完mediaprojection不close即可,避免重新申请