Closed P-stevens closed 1 month ago
Could you share the full appium server log as well?
According to https://github.com/ChickenHook/RestrictionBypass?tab=readme-ov-file , it is https://developer.android.com/guide/app-compatibility/restrictions-non-sdk-interfaces related. As https://developer.android.com/about/versions/10/non-sdk-q#enable-non-sdk-access , we set the hidden policy flag in a new session request procedure.
I quickly checked Android 11, 12, and 13 devices (pixel and Samsung devices). Then I saw the below warning in the logcat, but the toast was found, although the warning was actually presented in the logcat.
05-30 14:44:48.330 15649 15678 I appium : Adding toast message to root: Think of the penguins!
05-30 14:44:48.331 15649 15678 W tomator2.server: Accessing hidden field Landroid/view/accessibility/AccessibilityNodeInfo;->mSealed:Z (max-target-r, reflection, allowed)
05-30 14:44:48.331 15649 15678 I appium : Adding toast message to root: Clicky?
https://github.com/appium/android-apidemos/blob/c0d4c7607ae86d0545ee686e23f62e9a68ae4326/app/src/main/java/io/appium/android/apis/view/SecureView.java#L96-L106 is the test app in appium repo.
I wondered what caused (max-target-r, reflection, denied)
in your description. e.g. specific models
i have no full appium server log, because the appium server was not use for my test requirements
Sure, then as this project, we won't add the dependency right now. You could try out the official method https://developer.android.com/guide/app-compatibility/restrictions-non-sdk-interfaces#how_can_i_enable_access_to_non-sdk_interfaces first, or you could fork and add the deps for your usage.
Thk, i can not access https://developer.android.com/guide/app-compatibility/restrictions-non-sdk-interfaces#how_can_i_enable_access_to_non-sdk_interfaces at my country, but i found a better method at appium server code
oh, i see. then below is the link's commands to set flag for hidden API policy:
Android 10 (API level 29) or higher
Allow to access hidden API policy
adb shell settings put global hidden_api_policy 1
disable:
adb shell settings delete global hidden_api_policy
Android 9 (API level 28)
adb shell settings put global hidden_api_policy_pre_p_apps 1
adb shell settings put global hidden_api_policy_p_apps 1
adb shell settings delete global hidden_api_policy_pre_p_apps
adb shell settings delete global hidden_api_policy_p_apps
log:
2024-05-30 18:59:39.585 2118-2248 tomator2.serve io.appium.uiautomator2.server W Accessing hidden field Landroid/view/accessibility/AccessibilityNodeInfo;->mSealed:Z (max-target-r, reflection, denied) 2024-05-30 18:59:39.586 2118-2248 System.err io.appium.uiautomator2.server W io.appium.uiautomator2.common.exceptions.UiAutomator2Exception: Cannot set AccessibilityNodeInfo's field 'mSealed' to 'true' 2024-05-30 18:59:39.586 2118-2248 System.err io.appium.uiautomator2.server W at io.appium.uiautomator2.utils.ReflectionUtils.setField(ReflectionUtils.java:83) 2024-05-30 18:59:39.586 2118-2248 System.err io.appium.uiautomator2.server W at io.appium.uiautomator2.model.UiElementSnapshot.addToastMsg(UiElementSnapshot.java:227) 2024-05-30 18:59:39.586 2118-2248 System.err io.appium.uiautomator2.server W at io.appium.uiautomator2.model.UiElementSnapshot.take(UiElementSnapshot.java:200) 2024-05-30 18:59:39.586 2118-2248 System.err io.appium.uiautomator2.server W at io.appium.uiautomator2.core.AccessibilityNodeInfoDumper.toStream(AccessibilityNodeInfoDumper.java:228) 2024-05-30 18:59:39.586 2118-2248 System.err io.appium.uiautomator2.server W at io.appium.uiautomator2.core.AccessibilityNodeInfoDumper.findNodesUsingXpath2(AccessibilityNodeInfoDumper.java:337) 2024-05-30 18:59:39.586 2118-2248 System.err io.appium.uiautomator2.server W at io.appium.uiautomator2.core.AccessibilityNodeInfoDumper.findNodes(AccessibilityNodeInfoDumper.java:388) 2024-05-30 18:59:39.586 2118-2248 System.err io.appium.uiautomator2.server W at io.appium.uiautomator2.utils.ElementLocationHelpers.getXPathNodeMatch(ElementLocationHelpers.java:127) 2024-05-30 18:59:39.586 2118-2248 System.err io.appium.uiautomator2.server W at io.appium.uiautomator2.utils.ElementLocationHelpers.findElement(ElementLocationHelpers.java:154) 2024-05-30 18:59:39.586 2118-2248 System.err io.appium.uiautomator2.server W at io.appium.uiautomator2.handler.FindElement.safeHandle(FindElement.java:60) 2024-05-30 18:59:39.586 2118-2248 System.err io.appium.uiautomator2.server W at io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:59) 2024-05-30 18:59:39.586 2118-2248 System.err io.appium.uiautomator2.server W at io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:259) 2024-05-30 18:59:39.586 2118-2248 System.err io.appium.uiautomator2.server W at io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:253) 2024-05-30 18:59:39.586 2118-2248 System.err io.appium.uiautomator2.server W at io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:77) 2024-05-30 18:59:39.586 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366) 2024-05-30 18:59:39.587 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352) 2024-05-30 18:59:39.587 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345) 2024-05-30 18:59:39.587 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) 2024-05-30 18:59:39.587 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366) 2024-05-30 18:59:39.587 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352) 2024-05-30 18:59:39.587 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345) 2024-05-30 18:59:39.587 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:435) 2024-05-30 18:59:39.587 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293) 2024-05-30 18:59:39.587 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267) 2024-05-30 18:59:39.587 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:250) 2024-05-30 18:59:39.587 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366) 2024-05-30 18:59:39.587 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352) 2024-05-30 18:59:39.588 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345) 2024-05-30 18:59:39.588 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:266) 2024-05-30 18:59:39.588 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366) 2024-05-30 18:59:39.588 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352) 2024-05-30 18:59:39.588 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345) 2024-05-30 18:59:39.588 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294) 2024-05-30 18:59:39.588 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366) 2024-05-30 18:59:39.588 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352) 2024-05-30 18:59:39.588 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911) 2024-05-30 18:59:39.588 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131) 2024-05-30 18:59:39.588 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:611) 2024-05-30 18:59:39.588 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:552) 2024-05-30 18:59:39.588 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:466) 2024-05-30 18:59:39.588 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438) 2024-05-30 18:59:39.588 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140) 2024-05-30 18:59:39.588 2118-2248 System.err io.appium.uiautomator2.server W at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144) 2024-05-30 18:59:39.588 2118-2248 System.err io.appium.uiautomator2.server W at java.lang.Thread.run(Thread.java:920) 2024-05-30 18:59:39.588 2118-2248 System.err io.appium.uiautomator2.server W Caused by: java.lang.NoSuchFieldException: No field mSealed in class Landroid/view/accessibility/AccessibilityNodeInfo; (declaration of 'android.view.accessibility.AccessibilityNodeInfo' appears in /system/framework/framework.jar!classes3.dex) 2024-05-30 18:59:39.588 2118-2248 System.err io.appium.uiautomator2.server W at java.lang.Class.getDeclaredField(Native Method) 2024-05-30 18:59:39.588 2118-2248 System.err io.appium.uiautomator2.server W at io.appium.uiautomator2.utils.ReflectionUtils.setField(ReflectionUtils.java:77) 2024-05-30 18:59:39.588 2118-2248 System.err io.appium.uiautomator2.server W ... 42 more
client code:
2024-05-30 18:59:39.514 2118-2248 appium io.appium.uiautomator2.server I method: 'xpath', selector: '//android.widget.Toast'
u2-server code :
cause:
AccessibilityNodeInfo > mSealed is a hidden filed, google marked UnsupportedAppUsage
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) private boolean mSealed;
solve:
add a dependencies at app:build.gradle