Solution to stack error in Android webveiw
Solution to stack error in Android webveiw
preface:
In a recent project, a debugging tool of the project debugging basic library displays the device information page using WebView. An application integration debugging base library appears when displaying content
Because the application is system level, Android: shareduserid = "Android. Uid. System" is added to androidmanifest.xml
According to the exception prompt, for security reasons, it is preliminarily concluded that the application is likely to have a great relationship with the application as a system application, so we started the journey of finding the source of the code
First, let's look at the specific error stack
The error prompt is "caused by: java.lang.unsupported operationexception: for security reasons, WebView is not allowed in privileged processes"
Security reasons are security reasons. To find out why, check the Android source code directly. After some searching, it is found that the exception thrown is
frameworks/base/master/core/java/android/webkit/WebViewFactory.java
WebView will check the ID of the initialization process during initialization
If the process ID is root or system, an unsupported operationexception will be thrown. Why is there such a security mechanism? Because WebView allows JS to run, if users inject security code through JS, JS can use system permissions unscrupulously. This is undoubtedly a vulnerability and the portal is wide open.
Sure enough, it's Android: shareduserid = "Android. Uid. System". Because it's a system application, you can only modify the display control of the basic debugging library and change the WebView displaying debugging information to textview.
Thank you for reading. I hope I can help you through this article. Thank you for your support to this site. If you have any questions, please leave a message or go to the community of this site for communication and discussion, and make common progress!